MCPcopy Create free account
hub / github.com/TruthHun/BookStack / Index

Method Index

controllers/LabelController.go:28–66  ·  view source on GitHub ↗

查看包含标签的文档列表.

()

Source from the content-addressed store, hash-verified

26
27// 查看包含标签的文档列表.
28func (this *LabelController) Index() {
29 this.TplName = "label/index.html"
30 this.Data["IsLabel"] = true
31
32 labelName := this.Ctx.Input.Param(":key")
33
34 this.Redirect(beego.URLFor("SearchController.Result")+"?wd="+labelName, 302)
35 return
36
37 this.Data["Keyword"] = labelName
38 pageIndex, _ := this.GetInt("page", 1)
39 if labelName == "" {
40 this.Abort("404")
41 }
42 pageSize := 24
43 memberId := 0
44 if this.Member != nil {
45 memberId = this.Member.MemberId
46 }
47 searchResult, totalCount, err := models.NewBook().FindForLabelToPager(labelName, pageIndex, pageSize, memberId)
48 if err != nil {
49 beego.Error(err)
50 return
51 }
52
53 if totalCount > 0 {
54 html := utils.NewPaginations(conf.RollPage, totalCount, pageSize, pageIndex, beego.URLFor("LabelController.Index", ":key", labelName), "")
55 this.Data["PageHtml"] = html
56 } else {
57 this.Data["PageHtml"] = ""
58 }
59 this.Data["Lists"] = searchResult
60 this.Data["LabelName"] = labelName
61 this.GetSeoByPage("label_list", map[string]string{
62 "title": "[标签]" + labelName,
63 "keywords": "标签," + labelName,
64 "description": this.Sitename + "专注于文档在线写作、协作、分享、阅读与托管,让每个人更方便地发布、分享和获得知识。",
65 })
66}
67
68// 标签列表
69func (this *LabelController) List() {

Callers

nothing calls this directly

Calls 4

NewBookFunction · 0.92
NewPaginationsFunction · 0.92
FindForLabelToPagerMethod · 0.80
GetSeoByPageMethod · 0.80

Tested by

no test coverage detected