A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
update tags
aichy1269ff2979899f5
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.goindex a0349a25..f8b2064b 100644--- a/internal/controller/template_controller.go+++ b/internal/controller/template_controller.go@@ -138,8 +138,17 @@ func (tc *TemplateController) TagList(ctx *gin.Context) {// TagInfo taginfofunc (tc *TemplateController) TagInfo(ctx *gin.Context) {tag := ctx.Param("tag")-req := &schema.GetTamplateTagInfoReq{}+ if handler.BindAndCheck(ctx, req) {+ ctx.HTML(http.StatusOK, "404.html", gin.H{+ "scriptPath": tc.scriptPath,+ "cssPath": tc.cssPath,+ "err": "",+ "siteinfo": tc.SiteInfo(ctx),+ })+ return+ }+ nowPage := req.Pagereq.Name = tagtaginifo, questionList, questionCount, err := tc.templateRenderController.TagInfo(ctx, req)if err != nil {@@ -151,6 +160,8 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {})return}+ page := templaterender.Paginator(nowPage, req.PageSize, questionCount)+ctx.HTML(http.StatusOK, "tag-detail.html", gin.H{"tag": taginifo,"questionList": questionList,@@ -158,6 +169,7 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {"scriptPath": tc.scriptPath,"cssPath": tc.cssPath,"siteinfo": tc.SiteInfo(ctx),+ "page": page,})}diff --git a/internal/controller/template_render/tags.go b/internal/controller/template_render/tags.goindex f62539b4..1ef990cd 100644--- a/internal/controller/template_render/tags.go+++ b/internal/controller/template_render/tags.go@@ -22,7 +22,7 @@ func (q *TemplateRenderController) TagInfo(ctx context.Context, req *schema.GetTsearchQuestion := &schema.QuestionSearch{}searchQuestion.Page = req.PagesearchQuestion.PageSize = req.PageSize- searchQuestion.Order = "news"+ searchQuestion.Order = "newest"searchQuestion.Tag = req.NamequestionList, questionCount, err = q.questionService.SearchList(ctx, searchQuestion, "")if err != nil {diff --git a/internal/schema/tag_schema.go b/internal/schema/tag_schema.goindex 48f335c2..0dc53dae 100644--- a/internal/schema/tag_schema.go+++ b/internal/schema/tag_schema.go@@ -29,7 +29,7 @@ type GetTamplateTagInfoReq struct {// tag idID string `validate:"omitempty" form:"id"`// tag slug name- Name string `validate:"omitempty,gt=0,lte=35" form:"name"`+ Name string `validate:"omitempty" form:"name"`// user idUserID string `json:"-"`Page int `validate:"omitempty,min=1" form:"page"`diff --git a/ui/template/tag-detail.html b/ui/template/tag-detail.htmlindex a6a2fd6d..ee2268cb 100644--- a/ui/template/tag-detail.html+++ b/ui/template/tag-detail.html@@ -1,130 +1,66 @@{{template "header" . }}- <div class="pt-4 mt-2 mb-5 container">- <div class="justify-content-center row">- <div class="col-xxl-7 col-lg-8 col-sm-12">- <div class="tag-box mb-5">- <h3 class="mb-3">- <a class="link-dark" href="/tags/{{$.tag.SlugName}}">{{$.tag.SlugName}}</a>- </h3>- <p class="text-break">- {{templateHTML $.tag.ParsedText}}- </p>- </div>- <div>- <div class="mb-3 d-flex flex-wrap justify-content-between">- <h5 class="fs-5 text-nowrap mb-3 mb-md-0">{{.tag.QuestionCount}} Questions</h5>- </div>- <div class="border-top border-bottom-0 list-group list-group-flush">- <div class="border-bottom pt-3 pb-2 px-0 list-group-item">- <h5 class="text-wrap text-break">- <a class="link-dark" href="/questions/10010000000000875">测试标签处理</a>- </h5>- <div- class="d-flex flex-column flex-md-row align-items-md-center fs-14 text-secondary">- <div class="d-flex">- <div class="text-secondary me-1">- <a href="/users/str234ing"><span- class="me-1 text-break">str234ing</span></a><span- class="fw-bold" title="Reputation">1,000</span>- </div>- •<time class="text-secondary ms-1" datetime="2022-11-25T17:53:59.000Z"- title="Nov 26, 2022 at 01:53">modified Nov 26</time>- </div>- <div class="ms-0 ms-md-3 mt-2 mt-md-0">- <span><i class="br bi-hand-thumbs-up-fill"></i><em- class="fst-normal ms-1">0</em></span><span class="ms-3"><i- class="br bi-chat-square-text-fill"></i><em- class="fst-normal ms-1">0</em></span><span- class="summary-stat ms-3"><i class="br bi-eye-fill"></i><em- class="fst-normal ms-1">56</em></span>- </div>- </div>- <div class="question-tags mx-n1 mt-2">- <a href="/tags/discussion"- class="badge-tag rounded-1 badge-tag-required m-1"><span- class="">discussion</span></a><a- href="/tags/%E9%BB%84%E9%A9%AC%E7%94%B2"- class="badge-tag rounded-1 badge-tag-reserved m-1"><span- class="">黄马甲</span></a><a href="/tags/apple"- class="badge-tag rounded-1 m-1"><span class="">apple</span></a><a- href="/tags/string" class="badge-tag rounded-1 m-1"><span- class="">string</span></a>- </div>- </div>- <div class="border-bottom pt-3 pb-2 px-0 list-group-item">- <h5 class="text-wrap text-break">- <a class="link-dark" href="/questions/10010000000000762">Examples and usage- guidelines for form control- styles</a>- </h5>- <div- class="d-flex flex-column flex-md-row align-items-md-center fs-14 text-secondary">- <div class="d-flex">- <div class="text-secondary me-1">- <a href="/users/fenbox"><span- class="me-1 text-break">fen</span></a><span class="fw-bold"- title="Reputation">162</span>- </div>- •<time class="text-secondary ms-1" datetime="2022-11-23T02:55:02.000Z"- title="Nov 23, 2022 at 10:55">answered Nov 23</time>- </div>- <div class="ms-0 ms-md-3 mt-2 mt-md-0">- <span><i class="br bi-hand-thumbs-up-fill"></i><em- class="fst-normal ms-1">1</em></span><span- class="ms-3 text-success"><i class="br bi-check-circle-fill"></i><em- class="fst-normal ms-1">4</em></span><span- class="summary-stat ms-3"><i class="br bi-eye-fill"></i><em- class="fst-normal ms-1">225</em></span>- </div>- </div>- <div class="question-tags mx-n1 mt-2">- <a href="/tags/apple" class="badge-tag rounded-1 m-1"><span- class="">apple</span></a><a href="/tags/spring%20boot"- class="badge-tag rounded-1 m-1"><span class="">spring boot</span></a>- </div>- </div>- <div class="border-bottom pt-3 pb-2 px-0 list-group-item">- <h5 class="text-wrap text-break">- <a class="link-dark" href="/questions/10010000000000550">test date [closed]</a>- </h5>- <div- class="d-flex flex-column flex-md-row align-items-md-center fs-14 text-secondary">- <div class="d-flex">- <div class="text-secondary me-1">- <a href="/users/bmm11uodayryy"><span- class="me-1 text-break">robin</span></a><span class="fw-bold"- title="Reputation">89</span>- </div>- •<time class="text-secondary ms-1" datetime="2022-09-29T12:16:18.000Z"- title="Sep 29, 2022 at 20:16">answered Sep 29</time>- </div>- <div class="ms-0 ms-md-3 mt-2 mt-md-0">- <span><i class="br bi-hand-thumbs-up-fill"></i><em- class="fst-normal ms-1">1</em></span><span class="ms-3"><i- class="br bi-chat-square-text-fill"></i><em- class="fst-normal ms-1">1</em></span><span- class="summary-stat ms-3"><i class="br bi-eye-fill"></i><em- class="fst-normal ms-1">691</em></span>- </div>- </div>- <div class="question-tags mx-n1 mt-2">- <a href="/tags/javascript" class="badge-tag rounded-1 m-1"><span- class="">js</span></a><a href="/tags/apple"- class="badge-tag rounded-1 m-1"><span class="">apple</span></a><a- href="/tags/flutter" class="badge-tag rounded-1 m-1"><span- class="">flutter</span></a><a href="/tags/nextjs"- class="badge-tag rounded-1 m-1"><span class="">nextjs</span></a><a- href="/tags/umijs" class="badge-tag rounded-1 m-1"><span- class="">umijs</span></a>- </div>- </div>- </div>- <div class="mt-4 mb-2 d-flex justify-content-center"></div>- </div>- </div>- <div class="mt-5 mt-lg-0 col-xxl-3 col-lg-4 col-sm-12">-- </div>+<div class="pt-4 mt-2 mb-5 container">+ <div class="justify-content-center row">+ <div class="col-xxl-7 col-lg-8 col-sm-12">+ <div class="tag-box mb-5">+ <h3 class="mb-3">+ <a class="link-dark" href="/tags/{{$.tag.SlugName}}">{{$.tag.SlugName}}</a>+ </h3>+ <p class="text-break">+ {{templateHTML $.tag.ParsedText}}+ </p>+ </div>+ <div>+ <div class="mb-3 d-flex flex-wrap justify-content-between">+ <h5 class="fs-5 text-nowrap mb-3 mb-md-0">{{.questionCount}} Questions</h5>+ </div>+ <div class="border-top border-bottom-0 list-group list-group-flush">+ {{range .questionList}}+ <div class="border-bottom pt-3 pb-2 px-0 list-group-item">+ <h5 class="text-wrap text-break">+ <a class="link-dark" href="/questions/{{.ID}}">{{.Title}}</a>+ </h5>+ <div+ class="d-flex flex-column flex-md-row align-items-md-center fs-14 text-secondary">+ <div class="d-flex">+ <div class="text-secondary me-1">+ <a href="/users/{{.UserInfo.Username}}"><span+ class="me-1 text-break">{{.UserInfo.DisplayName}}</span></a><span+ class="fw-bold" title="Reputation">{{.UserInfo.Rank}}</span>+ </div>+ •+ <time class="text-secondary ms-1"+ datetime="2022-11-29T07:38:07.000Z"+ title="Nov 29, 2022 at 15:38">asked 1h ago+ </time>+ </div>+ <div class="ms-0 ms-md-3 mt-2 mt-md-0">+ <span><i class="br bi-hand-thumbs-up-fill"></i><em+ class="fst-normal ms-1">{{.VoteCount}}</em></span>+ <span class="ms-3"><i+ class="br bi-chat-square-text-fill"></i><em+ class="fst-normal ms-1">{{.AnswerCount}}</em></span>+ <span class="summary-stat ms-3"><i+ class="br bi-eye-fill"></i><em class="fst-normal ms-1">{{.ViewCount}}</em></span>+ </div>+ </div>+ <div class="question-tags mx-n1 mt-2">+ {{range .Tags }}+ <a href="/tags/{{.SlugName}}"+ class="badge-tag rounded-1 {{if .Reserved}}badge-tag-reserved{{end}} {{if .Recommend}}badge-tag-required{{end}} m-1">+ <span class="">{{.SlugName}}</span>+ </a>+ {{end}}+ </div>+ </div>+ {{end}}</div>+ <div class="mt-4 mb-2 d-flex justify-content-center"></div></div>+ </div>+ <div class="d-flex justify-content-center">+ {{template "page" .}}+ </div>+ </div>+</div>{{template "footer" .}}