Example #1
0
// 按Tag展示文章列表
func (a Article) Tags(res web.Resource) {
	a.Layout = "index.html"
	a.LayoutData = make(map[string]interface{})
	a.LayoutData["BlogTitle"] = web.Conf.Get("Blog", "name")

	data := make(map[string]interface{})
	tags := model.NewClassifyModelList("tags")
	//defer category.Close()

	id := res.URLValue("id")

	if tags == nil {
		a.Render(res, nil)
		return
	} else {
		data["tags"] = tags
	}

	if id == "" {
		// 这里如果ID为空则默认显示第一个分类的信息
		id = tags[0].Id.Hex()
	}

	// 获得对应ID的文章列表
	con := make(map[string]interface{})
	con["tags"] = id
	data["list"] = model.NewArticleModelList(con, 10)

	a.Render(res, data)
}
Example #2
0
// 响应首页的处理函数
func (i Index) Index(res web.Resource) {
	i.Layout = "index.html"
	i.LayoutData = make(map[string]interface{})
	i.LayoutData["BlogTitle"] = web.Conf.Get("Blog", "name")

	data := make(map[string]interface{})
	// 处理文章数据
	data["articlelist"] = model.NewArticleModelList(nil, 6)
	// 处理评论数据
	data["comments"] = model.NewCommentModelList("", 5)

	i.Render(res, data)
}