Ejemplo n.º 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
	}
}
Ejemplo n.º 2
0
func (this *TopicController) Add() {
	this.Data["isLogin"] = "******"
	var err error
	this.Data["Categories"], err = models.QueryCategories(true)
	if err != nil {
		beego.Error(err)
	}
	this.TplNames = "addTopic.html"
}
Ejemplo n.º 3
0
func (this *CategoryController) Get() {
	if !checkCookie(this.Ctx) {
		this.Redirect("/login", 302)
		return
	}

	/*op := this.Input().Get("op")

	switch op {
	case "add":
		name := this.Input().Get("category")
		if len(name) == 0 {
			break
		}
		err := models.AddCategory(name)
		if err != nil {
			beego.Error(err)
		}

		this.Redirect("/category", 301)
		return
	case "del":
		id := this.Input().Get("id")
		if len(id) == 0 {
			break
		}
		err := models.DeleteCategory(id)
		if err != nil {
			beego.Error(err)
		}
		this.Redirect("/category", 301)
		return
	}*/

	this.Data["isLogin"] = "******"
	this.TplNames = "category.html"
	this.Data["isCategory"] = "true"
	var err error
	this.Data["categories"], err = models.QueryCategories(false)
	if err != nil {
		beego.Error(err)
	}
}
Ejemplo n.º 4
0
func (this *TopicController) Modify() {
	if !checkCookie(this.Ctx) {
		this.Redirect("/login", 302)
		return
	}
	this.Data["isLogin"] = "******"
	tid := this.Ctx.Input.Param("0")
	var err error
	this.Data["Topic"], err = models.QueryTopic(tid, true)
	this.Data["Categories"], err = models.QueryCategories(true)
	if err != nil {
		beego.Error(err)
		this.Redirect("/", 302)
		return
	}

	this.TplNames = "modifyTopic.html"
	this.Data["Tid"] = tid
}