コード例 #1
0
ファイル: post.go プロジェクト: Raysmond/RaysGo
// View a post
func (this *PostController) View() {
	id, _ := helpers.Str2Int64(this.GetParam(":id"))

	var node *models.Node
	if node = models.GetNode(id); node == nil {
		this.Abort("404")
	}

	node.UpdateCounter()

	if tags, err := models.GetNodeTags(node.IUser.Id, node.Id); err == nil {
		this.Data["Tags"] = *tags
	}

	if comments, err := models.GetNodeComments(id); err == nil {
		this.Data["Comments"] = comments
	}

	var form models.PostForm
	if err := this.ParseForm(&form); err == nil {
		this.Data["CommentForm"] = form
	}

	this.Data["Title"] = node.Title
	this.Data["Post"] = node
	this.Data["User"] = models.GetUser(node.IUser.Id)
	this.Data["CanEdit"] = this.canEditPost(node)
	this.TplNames = "post/view.html"
}