File tree 3 files changed +7
-9
lines changed
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 {
194
194
// FindTopics retrieves the topics via FindTopicOptions
195
195
func FindTopics (opts * FindTopicOptions ) ([]* Topic , int64 , error ) {
196
196
sess := db .GetEngine (db .DefaultContext ).Select ("topic.*" ).Where (opts .toConds ())
197
+ orderBy := "topic.repo_count DESC"
197
198
if opts .RepoID > 0 {
198
199
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
199
201
}
200
202
if opts .PageSize != 0 && opts .Page != 0 {
201
203
sess = db .SetSessionPagination (sess , opts )
202
204
}
203
205
topics := make ([]* Topic , 0 , 10 )
204
- total , err := sess .Desc ( "topic.repo_count" ).FindAndCount (& topics )
206
+ total , err := sess .OrderBy ( orderBy ).FindAndCount (& topics )
205
207
return topics , total , err
206
208
}
207
209
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
12
12
13
13
repo_model "code.gitea.io/gitea/models/repo"
14
14
user_model "code.gitea.io/gitea/models/user"
15
- "code.gitea.io/gitea/modules/base"
16
15
"code.gitea.io/gitea/modules/charset"
17
16
"code.gitea.io/gitea/modules/context"
18
17
"code.gitea.io/gitea/modules/git"
@@ -23,10 +22,6 @@ import (
23
22
"code.gitea.io/gitea/modules/util"
24
23
)
25
24
26
- const (
27
- tplBlame base.TplName = "repo/home"
28
- )
29
-
30
25
type blameRow struct {
31
26
RowNumber int
32
27
Avatar gotemplate.HTML
@@ -140,7 +135,7 @@ func RefBlame(ctx *context.Context) {
140
135
141
136
renderBlame (ctx , blameParts , commitNames , previousCommits )
142
137
143
- ctx .HTML (http .StatusOK , tplBlame )
138
+ ctx .HTML (http .StatusOK , tplRepoHome )
144
139
}
145
140
146
141
func 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() {
41
41
viewDiv . children ( '.topic' ) . remove ( ) ;
42
42
if ( topics . length ) {
43
43
const topicArray = topics . split ( ',' ) ;
44
+ topicArray . sort ( ) ;
44
45
for ( let i = 0 ; i < topicArray . length ; i ++ ) {
45
46
const link = $ ( '<a class="ui repo-topic large label topic"></a>' ) ;
46
47
link . attr ( 'href' , `${ appSubUrl } /explore/repos?q=${ encodeURIComponent ( topicArray [ i ] ) } &topic=1` ) ;
@@ -57,12 +58,12 @@ export function initRepoTopicBar() {
57
58
topicPrompts . formatPrompt = xhr . responseJSON . message ;
58
59
59
60
const { invalidTopics} = xhr . responseJSON ;
60
- const topicLables = topicDropdown . children ( 'a.ui.label' ) ;
61
+ const topicLabels = topicDropdown . children ( 'a.ui.label' ) ;
61
62
62
63
for ( const [ index , value ] of topics . split ( ',' ) . entries ( ) ) {
63
64
for ( let i = 0 ; i < invalidTopics . length ; i ++ ) {
64
65
if ( invalidTopics [ i ] === value ) {
65
- topicLables . eq ( index ) . removeClass ( 'green' ) . addClass ( 'red' ) ;
66
+ topicLabels . eq ( index ) . removeClass ( 'green' ) . addClass ( 'red' ) ;
66
67
}
67
68
}
68
69
}
You can’t perform that action at this time.
0 commit comments