예제 #1
0
파일: article.go 프로젝트: fanflash/GoBlog
/*
 * Get article data
 */
func getArticleData(dbQuery *datastore.Query, MDOutput bool, c appengine.Context) (articleData []ArticleData, err error) {
	var articleDB []*ArticleDB
	_, err = dbQuery.GetAll(c, &articleDB)
	if err != nil {
		return
	}

	articleData = make([]ArticleData, len(articleDB))
	for i := 0; i < len(articleDB); i++ {
		articleData[i].ID = articleDB[i].ID
		articleData[i].Title = articleDB[i].Title
		if MDOutput {
			articleData[i].Content = string(blackfriday.MarkdownCommon(articleDB[i].Content))
		} else {
			articleData[i].Content = string(articleDB[i].Content)
		}
		articleData[i].Date = articleDB[i].Date
	}

	return
}
예제 #2
0
파일: widget.go 프로젝트: fanflash/GoBlog
/*
 * Get widget data
 */
func getWidgetData(dbQuery *datastore.Query, MDOutput bool, c appengine.Context) (widgetData []WidgetData, err error) {
	var widgetDB []*WidgetDB
	_, err = dbQuery.GetAll(c, &widgetDB)
	if err != nil {
		return
	}

	widgetData = make([]WidgetData, len(widgetDB))
	for i := 0; i < len(widgetDB); i++ {
		widgetData[i].ID = widgetDB[i].ID
		widgetData[i].Title = widgetDB[i].Title
		widgetData[i].Sequence = widgetDB[i].Sequence
		if MDOutput {
			widgetData[i].Content = string(blackfriday.MarkdownCommon(widgetDB[i].Content))
		} else {
			widgetData[i].Content = string(widgetDB[i].Content)
		}
	}

	return
}