Beispiel #1
0
func (this *MainController) Get() {
	var err error
	this.Data["isHome"] = true
	this.Data["isLogin"] = checkCookie(this.Ctx)
	this.TplNames = "home.html"
	category := this.Input().Get("category")
	label := this.Input().Get("label")

	/*if len(category) == 0 {
		this.Data["topics"], err = models.QueryTopics(true)
	} else {
		this.Data["topics"], err = models.QueryTopicsByCategory(true, category)
	}

	if len(label) == 0 {
		this.Data["topics"], err = models.QueryTopics(true)
	} else {
		this.Data["topics"], err = models.QueryTopicsByLabel(true, label)
	}*/
	this.Data["topics"], err = models.GetAllTopics(true, label, category)

	this.Data["categories"], err = models.QueryCategories(false)
	if err != nil {
		beego.Error(err)
		this.Redirect("/", 302)
		return
	}
}
Beispiel #2
0
func (this *HomeControllor) Get() {
	this.Data["IsHome"] = true
	this.TplName = "home.html"
	this.Data["IsLogin"] = checkAccount(this.Ctx)
	fmt.Println(checkAccount(this.Ctx))
	topics, err := models.GetAllTopics("", "", true)
	if err != nil {
		beego.Error(err)
	}
	this.Data["Topics"] = topics
}
Beispiel #3
0
func (this *TopicController) Get() {
	this.Data["IsTopic"] = true
	this.TplName = "topic.html"
	this.Data["IsLogin"] = checkAccount(this.Ctx)

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