Index question list
(ctx *gin.Context)
| 136 | |
| 137 | // Index question list |
| 138 | func (tc *TemplateController) Index(ctx *gin.Context) { |
| 139 | req := &schema.QuestionPageReq{ |
| 140 | OrderCond: "newest", |
| 141 | } |
| 142 | if handler.BindAndCheck(ctx, req) { |
| 143 | return |
| 144 | } |
| 145 | |
| 146 | var page = req.Page |
| 147 | |
| 148 | data, count, err := tc.templateRenderController.Index(ctx, req) |
| 149 | if err != nil || (len(data) == 0 && pager.ValPageOutOfRange(count, page, req.PageSize)) { |
| 150 | tc.Page404(ctx) |
| 151 | return |
| 152 | } |
| 153 | |
| 154 | hotQuestionReq := &schema.QuestionPageReq{ |
| 155 | Page: 1, |
| 156 | PageSize: 6, |
| 157 | OrderCond: "hot", |
| 158 | InDays: 7, |
| 159 | } |
| 160 | hotQuestion, _, _ := tc.templateRenderController.Index(ctx, hotQuestionReq) |
| 161 | |
| 162 | siteInfo := tc.SiteInfo(ctx) |
| 163 | siteInfo.Canonical = siteInfo.General.SiteUrl |
| 164 | |
| 165 | UrlUseTitle := siteInfo.SiteSeo.Permalink == constant.PermalinkQuestionIDAndTitle || |
| 166 | siteInfo.SiteSeo.Permalink == constant.PermalinkQuestionIDAndTitleByShortID |
| 167 | |
| 168 | siteInfo.Title = "" |
| 169 | tc.html(ctx, http.StatusOK, "question.html", siteInfo, gin.H{ |
| 170 | "data": data, |
| 171 | "useTitle": UrlUseTitle, |
| 172 | "page": templaterender.Paginator(page, req.PageSize, count), |
| 173 | "path": "questions", |
| 174 | "hotQuestion": hotQuestion, |
| 175 | }) |
| 176 | } |
| 177 | |
| 178 | func (tc *TemplateController) QuestionList(ctx *gin.Context) { |
| 179 | req := &schema.QuestionPageReq{ |
no test coverage detected