Esempio n. 1
0
// zan或者like
func (a Article) ZanLike(res web.Resource) {
	id := res.URLValue("id")
	name := res.URLValue("type")
	article := model.NewArticleModel(id)
	article.PlusOne(name)
	a.Redirect(res, "/Article/Show/"+id)
}
Esempio n. 2
0
// 前台文章展示
func (a Article) Show(res web.Resource) {
	a.Layout = "index.html"
	a.LayoutData = make(map[string]interface{})
	a.LayoutData["BlogTitle"] = web.Conf.Get("Blog", "name")

	id := res.URLValue("id")
	if id == "" {
		a.Redirect(res, "/")
		return
	}

	article := model.NewArticleModel(id)

	if article == nil {
		a.ShowMessage(res, "您要查看的文章不存在", "/", 5)
	} else {
		data := make(map[string]interface{})
		data["article"] = article
		data["comments"] = model.NewCommentModelList(id, 10)
		a.Render(res, data)
	}
}