Esempio n. 1
0
//修改文章
func (this *TopicController) Modify() {
	this.TplNames = "topic_modify.html"

	tid := this.Input().Get("tid")
	topic, err := models.GetTopic(tid)
	if err != nil {
		beego.Error(err)
		this.Redirect("/", 302)
		return
	}

	this.Data["Topic"] = topic
	this.Data["Tid"] = tid

	this.Data["CategoryList"], _ = models.GetAllCategory()
}
Esempio n. 2
0
File: home.go Progetto: wbcz/beeblog
func (this *MainController) Get() {
	this.Data["IsHome"] = true
	this.TplNames = "home.html"

	this.Data["IsLogin"] = checkAccount(this.Ctx)
	var err error
	this.Data["Topics"], err = models.GetAllTopic(this.Input().Get("cate"), this.Input().Get("label"), true)
	if err != nil {
		beego.Error(err)
	}

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

}
Esempio n. 3
0
func (this *CategoryController) Get() {
	op := this.Input().Get("op")

	switch op {
	case "add":
		name := this.Input().Get("name")
		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.DelCategory(id)
		if err != nil {
			beego.Error(err)
		}
		this.Redirect("/category", 301)
		return

	}
	this.Data["IsLogin"] = checkAccount(this.Ctx)

	this.TplNames = "category.html"
	this.Data["IsCategory"] = true
	var err error
	this.Data["Categories"], err = models.GetAllCategory()
	if err != nil {
		beego.Error(err)
	}

}
Esempio n. 4
0
//增加文章
func (this *TopicController) Add() {
	this.TplNames = "topic_add.html"

	this.Data["CategoryList"], _ = models.GetAllCategory()
}