File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Expand file tree Collapse file tree 3 files changed +7
-10
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 @@ -39,7 +39,7 @@ export function initRepoTopicBar() {
39
39
viewDiv . children ( '.topic' ) . remove ( ) ;
40
40
if ( topics . length ) {
41
41
const topicArray = topics . split ( ',' ) ;
42
-
42
+ topicArray . sort ( ) ;
43
43
const last = viewDiv . children ( 'a' ) . last ( ) ;
44
44
for ( let i = 0 ; i < topicArray . length ; i ++ ) {
45
45
const link = $ ( '<a class="ui repo-topic large label topic"></a>' ) ;
@@ -57,12 +57,12 @@ export function initRepoTopicBar() {
57
57
topicPrompts . formatPrompt = xhr . responseJSON . message ;
58
58
59
59
const { invalidTopics} = xhr . responseJSON ;
60
- const topicLables = topicDropdown . children ( 'a.ui.label' ) ;
60
+ const topicLabels = topicDropdown . children ( 'a.ui.label' ) ;
61
61
62
62
for ( const [ index , value ] of topics . split ( ',' ) . entries ( ) ) {
63
63
for ( let i = 0 ; i < invalidTopics . length ; i ++ ) {
64
64
if ( invalidTopics [ i ] === value ) {
65
- topicLables . eq ( index ) . removeClass ( 'green' ) . addClass ( 'red' ) ;
65
+ topicLabels . eq ( index ) . removeClass ( 'green' ) . addClass ( 'red' ) ;
66
66
}
67
67
}
68
68
}
You can’t perform that action at this time.
0 commit comments