Example #1
0
func (c *IndexController) Get() {
	page, _ := c.GetInt("page")
	step := 15

	c.Data["Blogs"] = models.GetBlogs(page*step, (page+1)*step)
	c.Data["LastestBlogs"] = models.GetBlogs(0, 5)
	c.Data["Tags"] = models.GetAllTags()
	c.Data["Category"] = models.GetAllCategory()
	c.Data["MonthBlog"] = models.GetAllMonth()

	c.LayoutSections["Sidebar"] = "sidebar.tpl"

	c.TplName = "list.tpl"
}
Example #2
0
File: tag.go Project: ckeyer/goblog
func (c *TagController) Get() {
	name := c.GetString("t")

	if tg := models.GetBlogsByTag(name); tg != nil {
		c.Data["Blogs"] = tg
	} else {
		log.Errorf("Tag Errer %s", name)
		c.Data["Blogs"] = models.GetBlogs(0, 10)
	}

	c.Data["LastestBlogs"] = models.GetBlogs(0, 5)
	c.Data["Tags"] = models.GetAllTags()
	c.Data["Category"] = models.GetAllCategory()
	c.Data["MonthBlog"] = models.GetAllMonth()

	c.LayoutSections["Sidebar"] = "sidebar.tpl"

	c.TplName = "list.tpl"
}
Example #3
0
// (b *BaseController)GetBlogs ...
func (b *BlogController) Get() {
	b.Data["LastestBlogs"] = models.GetBlogs(0, 5)
	b.Data["Tags"] = models.GetAllTags()
	b.Data["Category"] = models.GetAllCategory()
	b.Data["MonthBlog"] = models.GetAllMonth()

	name := b.Ctx.Input.Param(":name")
	blog := models.GetBlog(name)
	if blog == nil {
		log.Debug("name: ", name)
		return
	}
	b.Data["Blog"] = blog
	b.Data["BContent"] = string(blog.Content)

	b.LayoutSections["Sidebar"] = "sidebar.tpl"
	b.LayoutSections["Duoshuo"] = "duoshuo.tpl"
	b.TplName = "show.tpl"
}
Example #4
0
func (c *ArchiveController) Get() {
	year := c.Ctx.Input.Param(":year")
	month := c.Ctx.Input.Param(":month")
	name := year + "-" + month
	log.Debug("Archive name: ", name)
	if tg := models.GetBlogsByMonth(name); tg != nil {
		c.Data["Blogs"] = tg
	} else {
		log.Errorf("Tag Errer %s", name)
		c.Data["Blogs"] = models.GetBlogs(0, 10)
	}

	c.Data["LastestBlogs"] = models.GetBlogs(0, 5)
	c.Data["Tags"] = models.GetAllTags()
	c.Data["Category"] = models.GetAllCategory()
	c.Data["MonthBlog"] = models.GetAllMonth()

	c.LayoutSections["Sidebar"] = "sidebar.tpl"

	c.TplName = "list.tpl"
}