Example #1
0
func (this *NArticleController) Edit() {
	id, err := this.GetInt("id")
	if err != nil {
		this.Ctx.WriteString("get param id fail")
		return
	}

	b := blog.NOneById(int64(id))
	if b == nil {
		this.Ctx.WriteString("no such article")
		return
	}
	if this.UserName != b.Creator && !this.IsAdmin {
		this.Ctx.WriteString("you are not author or admin")
		return
	}
	this.Data["Content"] = blog.NReadBlogContent(b).Content
	this.Data["Blog"] = b
	tmp := catalog.NAll()
	this.Data["Catalogs"] = tmp
	p := ""
	for _, v := range tmp {
		if b.CatalogId == v.Id {
			p = v.Ident
		}
	}
	if p != "" {
		this.Data["RedirectPath"] = "/newemployee/catalog/" + p
	} else {
		this.Data["RedirectPath"] = "/newemployee"
	}
	this.Data["ReturnPath"] = this.Data["RedirectPath"]
	this.Layout = "main_newemployee/layout/admin.html"
	this.TplNames = "main_newemployee/article/edit.html"
}
Example #2
0
func (this *CommunicateController) Read() {
	ident := this.GetString(":ident")
	b := blog.NOneByIdent(ident)
	if b == nil {
		this.Ctx.WriteString("no such article")
		return
	}

	b.Views = b.Views + 1
	blog.NUpdate(b, "")

	this.Data["Blog"] = b
	this.Data["Content"] = blog.NReadBlogContent(b).Content
	this.Data["PageTitle"] = b.Title
	tmp := catalog.NOneById(b.CatalogId)
	this.Data["Catalog"] = tmp
	this.Data["Addblog"] = `<a href="/newemployee/catalog/` + tmp.Ident + `">返回</a>`
	this.Layout = "main_newemployee/layout/default.html"
	this.TplNames = "main_newemployee/article/read.html"
}