You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/11/29 07:15:58 UTC

(incubator-answer) branch feat/1.4.2/seo created (now ce0ec4b8)

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a change to branch feat/1.4.2/seo
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


      at ce0ec4b8 feat(user): add top questions and answers to user homepage

This branch includes the following new commits:

     new ce0ec4b8 feat(user): add top questions and answers to user homepage

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-answer) 01/01: feat(user): add top questions and answers to user homepage

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch feat/1.4.2/seo
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit ce0ec4b806b602518bd8cd2a37ff1aa0834a302c
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Fri Nov 29 15:15:23 2024 +0800

    feat(user): add top questions and answers to user homepage
---
 internal/controller/template_controller.go | 12 +++++++++--
 ui/template/homepage.html                  | 33 +++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go
index df10931e..0b22360f 100644
--- a/internal/controller/template_controller.go
+++ b/internal/controller/template_controller.go
@@ -546,12 +546,20 @@ func (tc *TemplateController) UserInfo(ctx *gin.Context) {
 		return
 	}
 
+	questionList, answerList, err := tc.questionService.SearchUserTopList(ctx, req.Username, "")
+	if err != nil {
+		tc.Page404(ctx)
+		return
+	}
+
 	siteInfo := tc.SiteInfo(ctx)
 	siteInfo.Canonical = fmt.Sprintf("%s/users/%s", siteInfo.General.SiteUrl, username)
 	siteInfo.Title = fmt.Sprintf("%s - %s", username, siteInfo.General.Name)
 	tc.html(ctx, http.StatusOK, "homepage.html", siteInfo, gin.H{
-		"userinfo": userinfo,
-		"bio":      template.HTML(userinfo.BioHTML),
+		"userinfo":     userinfo,
+		"bio":          template.HTML(userinfo.BioHTML),
+		"topQuestions": questionList,
+		"topAnswers":   answerList,
 	})
 
 }
diff --git a/ui/template/homepage.html b/ui/template/homepage.html
index 2f68200d..84887a09 100644
--- a/ui/template/homepage.html
+++ b/ui/template/homepage.html
@@ -63,10 +63,41 @@
             <div>
                 <h5 class="mb-3">{{translator $.language "ui.personal.about_me"}}</h5>
                 {{if .bio }}
-                <div class="text-center mb-4">{{.bio}}</div>
+                <div class="mb-5 text-break fmt">{{.bio}}</div>
                 {{else}}
                 <div class="text-center py-5 mb-4">{{translator $.language "ui.personal.about_me_empty"}}</div>
                 {{end}}
+                <div class="mb-4 row">
+                    <div class="mb-4 col-md-6 col-sm-12">
+                        <h5 class="mb-3">Top Answers</h5>
+                        <ol class="list-unstyled">
+                            {{ range .topAnswers }}
+                            <li class="mb-2">
+                                <a class="text-truncate-1" href="{{$.baseURL}}/questions/{{.QuestionID}}/{{.AnswerID}}">{{.QuestionInfo.Title}}</a>
+                                <div class="text-secondary small">
+                                    <i class="br bi-hand-thumbs-up-fill me-1"></i><span>{{.VoteCount}} votes</span>
+                                </div>
+                            </li>
+                            {{ end }}
+                        </ol>
+                    </div>
+                    <div class="col-md-6 col-sm-12">
+                        <h5 class="mb-3">Top Questions</h5>
+                        <ol class="list-unstyled">
+                            {{ range .topQuestions }}
+                            <li class="mb-2">
+                                <a class="text-truncate-1" href="{{$.baseURL}}/questions/{{.ID}}">{{.Title}}</a>
+                                <div class="text-secondary small">
+                                    <i class="br bi-hand-thumbs-up-fill me-1"></i><span> {{.VoteCount}} votes</span>
+                                    <div class="d-inline-block text-secondary ms-3 small text-success">
+                                        <i class="br bi-check-circle-fill"></i><span> {{.AnswerCount}} answers</span>
+                                    </div>
+                                </div>
+                            </li>
+                            {{ end }}
+                        </ol>
+                    </div>
+                </div>
             </div>
         </div>
         <div class="mt-5 mt-lg-0 col-xxl-3 col-lg-4 col-sm-12">