Exemplo n.º 1
0
// search list
// @router /list.html [get]
func (this *IndexController) List() {
	var err error

	this.TplNames = "front/list.html"

	numPerPage := 10
	keywords := this.GetString("keywords")
	all := strings.HasPrefix(keywords, "all:")
	if all {
		keywords = strings.Split(keywords, "all:")[1]
	}

	maxCount, _ := models.SearchCount(keywords, all)
	this.Data["count"] = maxCount

	paginator := pagination.SetPaginator(this.Ctx, numPerPage, maxCount)
	data, err := models.Search(keywords, all, numPerPage, paginator.Offset(), "-create_at")
	if err != nil {
		beego.Error(err)
	}

	for _, torrent := range data {
		if len(torrent.FileList) > 5 {
			torrent.FileList = torrent.FileList[:5]
		}
	}

	this.Data["torrents"] = data
	this.Render()
}
Exemplo n.º 2
0
// index page
// @router / [get]
func (this *IndexController) Index() {
	this.TplNames = "front/index.html"

	this.Data["hots"], _ = models.Search("", false, 4, 0, "-hot")

	this.Render()
}