コード例 #1
0
ファイル: topic.go プロジェクト: jsli/gorevel
// 帖子列表
func (c *Topic) Index(page int) revel.Result {
	title := "最近发表"

	categories := models.GetCategories()
	topics, pagination := models.GetTopics(page, "", "", "created", routes.Topic.Index(page))

	return c.Render(title, topics, pagination, categories)
}
コード例 #2
0
ファイル: topic.go プロジェクト: jsli/gorevel
// 帖子分类查询,帖子列表按时间排序
func (c *Topic) Category(id int64, page int) revel.Result {
	title := "最近发表"

	categories := models.GetCategories()
	topics, pagination := models.GetTopics(page, "category_id", id, "created", routes.Topic.Category(id, page))

	c.Render(title, topics, pagination, categories)
	return c.RenderTemplate("Topic/Index.html")
}
コード例 #3
0
ファイル: topic.go プロジェクト: jsli/gorevel
func (c *Topic) Good(page int) revel.Result {
	title := "好帖推荐"

	categories := models.GetCategories()
	topics, pagination := models.GetTopics(page, "good", true, "created", routes.Topic.Good(page))

	c.Render(title, topics, pagination, categories)
	return c.RenderTemplate("Topic/Index.html")
}
コード例 #4
0
ファイル: topic.go プロジェクト: jsli/gorevel
func (c *Topic) Hot(page int) revel.Result {
	title := "最多点击"

	categories := models.GetCategories()
	topics, pagination := models.GetTopics(page, "", "", "hits", routes.Topic.Hot(page))

	c.Render(title, topics, pagination, categories)
	return c.RenderTemplate("Topic/Index.html")
}
コード例 #5
0
ファイル: topic.go プロジェクト: jsli/gorevel
func (c *Topic) Edit(id int64) revel.Result {
	title := "编辑帖子"

	topic := models.FindTopicById(id)

	if topic.Id == 0 {
		return c.NotFound("帖子不存在")
	}

	categories := models.GetCategories()

	c.Render(title, topic, categories)
	return c.RenderTemplate("Topic/New.html")
}
コード例 #6
0
ファイル: topic.go プロジェクト: jsli/gorevel
// 帖子详细
func (c *Topic) Show(id int64) revel.Result {
	topic := models.FindTopicById(id)

	if topic.Id == 0 {
		return c.NotFound("帖子不存在")
	}

	topic.Hits += 1
	topic.Save()

	replies := models.GetReplies(id)
	categories := models.GetCategories()

	title := topic.Title
	return c.Render(title, topic, replies, categories)
}
コード例 #7
0
ファイル: topic.go プロジェクト: jsli/gorevel
func (c *Topic) New() revel.Result {
	title := "发表新帖"
	categories := models.GetCategories()

	return c.Render(title, categories)
}