예제 #1
0
파일: home.go 프로젝트: xuzhenglun/Blog-Go
func (this *MainController) Get() {
	this.Data["IsHome"] = true
	this.TplNames = "index.html"
	this.Data["IsLogin"] = checkAccount(this.Ctx)
	topics, err := models.GetAllTopics(this.Input().Get("cate"), this.Input().Get("tag"), true)

	for _, topic := range topics {
		if len(topic.Content) > 200 {
			topic.Content = string([]byte(topic.Content)[:200])
		}
	}

	if err != nil {
		beego.Error(err)
	} else {
		this.Data["Topics"] = topics
	}

	Categories, err := models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
	this.Data["Categories"] = Categories

	this.locale() //locale
}
예제 #2
0
파일: topic.go 프로젝트: xuzhenglun/Blog-Go
func (this *TopicController) Get() {
	this.Data["IsTopic"] = true
	this.TplNames = "topic.html"
	this.Data["IsLogin"] = checkAccount(this.Ctx)

	topics, err := models.GetAllTopics("", "", false)
	if err != nil {
		beego.Error(err)
	} else {
		this.Data["Topics"] = topics
	}

	this.locale()
}