Change default sort order (#2647)
* sort repositories by `updated_unix` in Explore * Fix UI problem * Added missing sort order "newest" * Change default sort order * fmt
This commit is contained in:
parent
aa962deec0
commit
43253202e9
|
@ -88,9 +88,11 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||||
err error
|
err error
|
||||||
orderBy models.SearchOrderBy
|
orderBy models.SearchOrderBy
|
||||||
)
|
)
|
||||||
ctx.Data["SortType"] = ctx.Query("sort")
|
|
||||||
|
|
||||||
|
ctx.Data["SortType"] = ctx.Query("sort")
|
||||||
switch ctx.Query("sort") {
|
switch ctx.Query("sort") {
|
||||||
|
case "newest":
|
||||||
|
orderBy = models.SearchOrderByNewest
|
||||||
case "oldest":
|
case "oldest":
|
||||||
orderBy = models.SearchOrderByOldest
|
orderBy = models.SearchOrderByOldest
|
||||||
case "recentupdate":
|
case "recentupdate":
|
||||||
|
@ -106,7 +108,8 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||||
case "size":
|
case "size":
|
||||||
orderBy = models.SearchOrderBySize
|
orderBy = models.SearchOrderBySize
|
||||||
default:
|
default:
|
||||||
orderBy = models.SearchOrderByNewest
|
ctx.Data["SortType"] = "recentupdate"
|
||||||
|
orderBy = models.SearchOrderByRecentUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword := strings.Trim(ctx.Query("q"), " ")
|
keyword := strings.Trim(ctx.Query("q"), " ")
|
||||||
|
@ -188,6 +191,8 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
|
||||||
|
|
||||||
ctx.Data["SortType"] = ctx.Query("sort")
|
ctx.Data["SortType"] = ctx.Query("sort")
|
||||||
switch ctx.Query("sort") {
|
switch ctx.Query("sort") {
|
||||||
|
case "newest":
|
||||||
|
orderBy = "id DESC"
|
||||||
case "oldest":
|
case "oldest":
|
||||||
orderBy = "id ASC"
|
orderBy = "id ASC"
|
||||||
case "recentupdate":
|
case "recentupdate":
|
||||||
|
@ -199,7 +204,8 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
|
||||||
case "alphabetically":
|
case "alphabetically":
|
||||||
orderBy = "name ASC"
|
orderBy = "name ASC"
|
||||||
default:
|
default:
|
||||||
orderBy = "id DESC"
|
ctx.Data["SortType"] = "alphabetically"
|
||||||
|
orderBy = "name ASC"
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword := strings.Trim(ctx.Query("q"), " ")
|
keyword := strings.Trim(ctx.Query("q"), " ")
|
||||||
|
|
|
@ -126,12 +126,7 @@ func Profile(ctx *context.Context) {
|
||||||
orderBy = models.SearchOrderByAlphabetically
|
orderBy = models.SearchOrderByAlphabetically
|
||||||
default:
|
default:
|
||||||
ctx.Data["SortType"] = "recentupdate"
|
ctx.Data["SortType"] = "recentupdate"
|
||||||
orderBy = models.SearchOrderByNewest
|
orderBy = models.SearchOrderByRecentUpdated
|
||||||
}
|
|
||||||
|
|
||||||
// set default sort value if sort is empty.
|
|
||||||
if ctx.Query("sort") == "" {
|
|
||||||
ctx.Data["SortType"] = "recentupdate"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword := strings.Trim(ctx.Query("q"), " ")
|
keyword := strings.Trim(ctx.Query("q"), " ")
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
</span>
|
</span>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a class="{{if or (eq .SortType "newest") (not .SortType)}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
|
<a class="{{if eq .SortType "newest"}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
|
||||||
<a class="{{if eq .SortType "oldest"}}active{{end}} item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a>
|
<a class="{{if eq .SortType "oldest"}}active{{end}} item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a>
|
||||||
<a class="{{if eq .SortType "alphabetically"}}active{{end}} item" href="{{$.Link}}?sort=alphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
|
<a class="{{if eq .SortType "alphabetically"}}active{{end}} item" href="{{$.Link}}?sort=alphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
|
||||||
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
|
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user