Exemplo n.º 1
0
// 帖子列表
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)
}
Exemplo n.º 2
0
// 帖子分类查询,帖子列表按时间排序
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")
}
Exemplo n.º 3
0
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")
}
Exemplo n.º 4
0
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")
}
Exemplo n.º 5
0
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")
}
Exemplo n.º 6
0
// 帖子详细
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)
}
Exemplo n.º 7
0
func (c *Topic) New() revel.Result {
	title := "发表新帖"
	categories := models.GetCategories()

	return c.Render(title, categories)
}