File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -194,14 +194,16 @@ func (opts *FindTopicOptions) toConds() builder.Cond {
194194// FindTopics retrieves the topics via FindTopicOptions
195195func FindTopics (opts * FindTopicOptions ) ([]* Topic , int64 , error ) {
196196 sess := db .GetEngine (db .DefaultContext ).Select ("topic.*" ).Where (opts .toConds ())
197+ orderBy := "topic.repo_count DESC"
197198 if opts .RepoID > 0 {
198199 sess .Join ("INNER" , "repo_topic" , "repo_topic.topic_id = topic.id" )
200+ orderBy = "topic.name" // when render topics for a repo, it's better to sort them by name, to get consistent result
199201 }
200202 if opts .PageSize != 0 && opts .Page != 0 {
201203 sess = db .SetSessionPagination (sess , opts )
202204 }
203205 topics := make ([]* Topic , 0 , 10 )
204- total , err := sess .Desc ( "topic.repo_count" ).FindAndCount (& topics )
206+ total , err := sess .OrderBy ( orderBy ).FindAndCount (& topics )
205207 return topics , total , err
206208}
207209
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
1212
1313 repo_model "code.gitea.io/gitea/models/repo"
1414 user_model "code.gitea.io/gitea/models/user"
15- "code.gitea.io/gitea/modules/base"
1615 "code.gitea.io/gitea/modules/charset"
1716 "code.gitea.io/gitea/modules/context"
1817 "code.gitea.io/gitea/modules/git"
@@ -23,10 +22,6 @@ import (
2322 "code.gitea.io/gitea/modules/util"
2423)
2524
26- const (
27- tplBlame base.TplName = "repo/home"
28- )
29-
3025type blameRow struct {
3126 RowNumber int
3227 Avatar gotemplate.HTML
@@ -140,7 +135,7 @@ func RefBlame(ctx *context.Context) {
140135
141136 renderBlame (ctx , blameParts , commitNames , previousCommits )
142137
143- ctx .HTML (http .StatusOK , tplBlame )
138+ ctx .HTML (http .StatusOK , tplRepoHome )
144139}
145140
146141func processBlameParts (ctx * context.Context , blameParts []git.BlamePart ) (map [string ]* user_model.UserCommit , map [string ]string ) {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export function initRepoTopicBar() {
4141 viewDiv . children ( '.topic' ) . remove ( ) ;
4242 if ( topics . length ) {
4343 const topicArray = topics . split ( ',' ) ;
44+ topicArray . sort ( ) ;
4445 for ( let i = 0 ; i < topicArray . length ; i ++ ) {
4546 const link = $ ( '<a class="ui repo-topic large label topic"></a>' ) ;
4647 link . attr ( 'href' , `${ appSubUrl } /explore/repos?q=${ encodeURIComponent ( topicArray [ i ] ) } &topic=1` ) ;
@@ -57,12 +58,12 @@ export function initRepoTopicBar() {
5758 topicPrompts . formatPrompt = xhr . responseJSON . message ;
5859
5960 const { invalidTopics} = xhr . responseJSON ;
60- const topicLables = topicDropdown . children ( 'a.ui.label' ) ;
61+ const topicLabels = topicDropdown . children ( 'a.ui.label' ) ;
6162
6263 for ( const [ index , value ] of topics . split ( ',' ) . entries ( ) ) {
6364 for ( let i = 0 ; i < invalidTopics . length ; i ++ ) {
6465 if ( invalidTopics [ i ] === value ) {
65- topicLables . eq ( index ) . removeClass ( 'green' ) . addClass ( 'red' ) ;
66+ topicLabels . eq ( index ) . removeClass ( 'green' ) . addClass ( 'red' ) ;
6667 }
6768 }
6869 }
You can’t perform that action at this time.
0 commit comments