(ctx *gin.Context)
| 176 | } |
| 177 | |
| 178 | func (tc *TemplateController) QuestionList(ctx *gin.Context) { |
| 179 | req := &schema.QuestionPageReq{ |
| 180 | OrderCond: "newest", |
| 181 | } |
| 182 | if handler.BindAndCheck(ctx, req) { |
| 183 | return |
| 184 | } |
| 185 | var page = req.Page |
| 186 | data, count, err := tc.templateRenderController.Index(ctx, req) |
| 187 | if err != nil || (len(data) == 0 && pager.ValPageOutOfRange(count, page, req.PageSize)) { |
| 188 | tc.Page404(ctx) |
| 189 | return |
| 190 | } |
| 191 | |
| 192 | hotQuestionReq := &schema.QuestionPageReq{ |
| 193 | Page: 1, |
| 194 | PageSize: 6, |
| 195 | OrderCond: "hot", |
| 196 | InDays: 7, |
| 197 | } |
| 198 | hotQuestion, _, _ := tc.templateRenderController.Index(ctx, hotQuestionReq) |
| 199 | |
| 200 | siteInfo := tc.SiteInfo(ctx) |
| 201 | siteInfo.Canonical = fmt.Sprintf("%s/questions", siteInfo.General.SiteUrl) |
| 202 | if page > 1 { |
| 203 | siteInfo.Canonical = fmt.Sprintf("%s/questions?page=%d", siteInfo.General.SiteUrl, page) |
| 204 | } |
| 205 | |
| 206 | UrlUseTitle := siteInfo.SiteSeo.Permalink == constant.PermalinkQuestionIDAndTitle || |
| 207 | siteInfo.SiteSeo.Permalink == constant.PermalinkQuestionIDAndTitleByShortID |
| 208 | |
| 209 | siteInfo.Title = fmt.Sprintf("%s - %s", translator.Tr(handler.GetLangByCtx(ctx), constant.QuestionsTitleTrKey), siteInfo.General.Name) |
| 210 | tc.html(ctx, http.StatusOK, "question.html", siteInfo, gin.H{ |
| 211 | "data": data, |
| 212 | "useTitle": UrlUseTitle, |
| 213 | "page": templaterender.Paginator(page, req.PageSize, count), |
| 214 | "hotQuestion": hotQuestion, |
| 215 | }) |
| 216 | } |
| 217 | |
| 218 | func (tc *TemplateController) QuestionInfoRedirect(ctx *gin.Context, siteInfo *schema.TemplateSiteInfoResp, correctTitle bool) (jump bool, url string) { |
| 219 | questionID := ctx.Param("id") |
nothing calls this directly
no test coverage detected