mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	| @@ -194,14 +194,16 @@ func (opts *FindTopicOptions) toConds() builder.Cond { | |||||||
| // FindTopics retrieves the topics via FindTopicOptions | // FindTopics retrieves the topics via FindTopicOptions | ||||||
| func FindTopics(opts *FindTopicOptions) ([]*Topic, int64, error) { | func FindTopics(opts *FindTopicOptions) ([]*Topic, int64, error) { | ||||||
| 	sess := db.GetEngine(db.DefaultContext).Select("topic.*").Where(opts.toConds()) | 	sess := db.GetEngine(db.DefaultContext).Select("topic.*").Where(opts.toConds()) | ||||||
|  | 	orderBy := "topic.repo_count DESC" | ||||||
| 	if opts.RepoID > 0 { | 	if opts.RepoID > 0 { | ||||||
| 		sess.Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id") | 		sess.Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id") | ||||||
|  | 		orderBy = "topic.name" // when render topics for a repo, it's better to sort them by name, to get consistent result | ||||||
| 	} | 	} | ||||||
| 	if opts.PageSize != 0 && opts.Page != 0 { | 	if opts.PageSize != 0 && opts.Page != 0 { | ||||||
| 		sess = db.SetSessionPagination(sess, opts) | 		sess = db.SetSessionPagination(sess, opts) | ||||||
| 	} | 	} | ||||||
| 	topics := make([]*Topic, 0, 10) | 	topics := make([]*Topic, 0, 10) | ||||||
| 	total, err := sess.Desc("topic.repo_count").FindAndCount(&topics) | 	total, err := sess.OrderBy(orderBy).FindAndCount(&topics) | ||||||
| 	return topics, total, err | 	return topics, total, err | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,7 +12,6 @@ import ( | |||||||
|  |  | ||||||
| 	repo_model "code.gitea.io/gitea/models/repo" | 	repo_model "code.gitea.io/gitea/models/repo" | ||||||
| 	user_model "code.gitea.io/gitea/models/user" | 	user_model "code.gitea.io/gitea/models/user" | ||||||
| 	"code.gitea.io/gitea/modules/base" |  | ||||||
| 	"code.gitea.io/gitea/modules/charset" | 	"code.gitea.io/gitea/modules/charset" | ||||||
| 	"code.gitea.io/gitea/modules/context" | 	"code.gitea.io/gitea/modules/context" | ||||||
| 	"code.gitea.io/gitea/modules/git" | 	"code.gitea.io/gitea/modules/git" | ||||||
| @@ -23,10 +22,6 @@ import ( | |||||||
| 	"code.gitea.io/gitea/modules/util" | 	"code.gitea.io/gitea/modules/util" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( |  | ||||||
| 	tplBlame base.TplName = "repo/home" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| type blameRow struct { | type blameRow struct { | ||||||
| 	RowNumber      int | 	RowNumber      int | ||||||
| 	Avatar         gotemplate.HTML | 	Avatar         gotemplate.HTML | ||||||
| @@ -140,7 +135,7 @@ func RefBlame(ctx *context.Context) { | |||||||
|  |  | ||||||
| 	renderBlame(ctx, blameParts, commitNames, previousCommits) | 	renderBlame(ctx, blameParts, commitNames, previousCommits) | ||||||
|  |  | ||||||
| 	ctx.HTML(http.StatusOK, tplBlame) | 	ctx.HTML(http.StatusOK, tplRepoHome) | ||||||
| } | } | ||||||
|  |  | ||||||
| func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*user_model.UserCommit, map[string]string) { | func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*user_model.UserCommit, map[string]string) { | ||||||
|   | |||||||
| @@ -41,6 +41,7 @@ export function initRepoTopicBar() { | |||||||
|         viewDiv.children('.topic').remove(); |         viewDiv.children('.topic').remove(); | ||||||
|         if (topics.length) { |         if (topics.length) { | ||||||
|           const topicArray = topics.split(','); |           const topicArray = topics.split(','); | ||||||
|  |           topicArray.sort(); | ||||||
|           for (let i = 0; i < topicArray.length; i++) { |           for (let i = 0; i < topicArray.length; i++) { | ||||||
|             const link = $('<a class="ui repo-topic large label topic"></a>'); |             const link = $('<a class="ui repo-topic large label topic"></a>'); | ||||||
|             link.attr('href', `${appSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`); |             link.attr('href', `${appSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`); | ||||||
| @@ -57,12 +58,12 @@ export function initRepoTopicBar() { | |||||||
|           topicPrompts.formatPrompt = xhr.responseJSON.message; |           topicPrompts.formatPrompt = xhr.responseJSON.message; | ||||||
|  |  | ||||||
|           const {invalidTopics} = xhr.responseJSON; |           const {invalidTopics} = xhr.responseJSON; | ||||||
|           const topicLables = topicDropdown.children('a.ui.label'); |           const topicLabels = topicDropdown.children('a.ui.label'); | ||||||
|  |  | ||||||
|           for (const [index, value] of topics.split(',').entries()) { |           for (const [index, value] of topics.split(',').entries()) { | ||||||
|             for (let i = 0; i < invalidTopics.length; i++) { |             for (let i = 0; i < invalidTopics.length; i++) { | ||||||
|               if (invalidTopics[i] === value) { |               if (invalidTopics[i] === value) { | ||||||
|                 topicLables.eq(index).removeClass('green').addClass('red'); |                 topicLabels.eq(index).removeClass('green').addClass('red'); | ||||||
|               } |               } | ||||||
|             } |             } | ||||||
|           } |           } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 wxiaoguang
					wxiaoguang