Пример #1
0
func (c *AdminController) Get() {
	var scposts []models.BlogPost

	count := models.Count(models.DbPost, nil)
	page := pagination.NewPaginator(c.Ctx.Request, 10, count)
	c.Data["paginator"] = page

	models.GetDataByQuery(models.DbPost, page.Offset(), 10, "-created", nil, &scposts)
	c.Data["Lists"] = scposts

	c.TplNames = "admin/admin.html"
}
Пример #2
0
func (c *UserController) Index() {
	var scposts []models.BlogPost

	count := models.Count(models.DbPost, nil)
	page := pagination.NewPaginator(c.Ctx.Request, 10, count)
	c.Data["paginator"] = page

	models.GetDataByQuery(models.DbPost, page.Offset(), 10, "-created", nil, &scposts)
	c.Data["Lists"] = scposts

	c.Data["SiteName"] = beego.AppConfig.String("sitename")
	c.Data["SubTitle"] = beego.AppConfig.String("subtitle")

	c.TplNames = "user/index.html"
}
Пример #3
0
func (this *UserController) TagList() {
	tag := this.Ctx.Input.Param(":tag")
	if tag == "" {
		this.Abort("404")
	}

	var sctag models.BlogTag

	models.GetOneByQuery(models.DbTag, bson.M{"slug": tag}, &sctag)

	if sctag.Id.Hex() == "" {
		this.Data["NotSearch"] = true
		this.TplNames = "home/index.html"
		return
	}

	tag = sctag.Caption

	//      this.Data["SiteName"] = tag
	//      this.Data["SubTitle"] = models.Option.SiteName
	//      this.Data["Keywords"] = models.Option.Keywords
	//      this.Data["Description"] = models.Option.Description

	var scposts []models.BlogPost

	count := models.Count(models.DbPost, bson.M{"type": "post", "tags": tag})

	page := pagination.NewPaginator(this.Ctx.Request, 10, count)

	this.Data["paginator"] = page

	models.GetDataByQuery(models.DbPost, page.Offset(), 10, "-created", bson.M{"type": "post", "tags": tag}, &scposts)
	this.Data["Lists"] = scposts

	if len(scposts) <= 0 {
		this.Data["NotSearch"] = true
	}

	this.TplNames = "user/index.html"
}