mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 23:03:34 +01:00
Fix sort order for organization home and user profile page (#31921)
Fix #31916 In #30876, `sortOrder` has been changed into a map, but it is only implemented in explore. ~~But it seems that size sort order has no effect from long long ago,~~ not directly caused by the PR above. I think it is still caused by #29231. In #29231, it merged the sort orders from `templates/explore/repo_search.tmpl` and `templates/admin/repo/search.tmpl`. In `templates/admin/repo/search.tmpl`, it contains size sort orders, but not in `templates/explore/repo_search.tmpl`, which is used in non-admin pages. So `order by size` is added from #29231, but the handler was not added. --------- Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit 661a1e10f7abd3527d2abc027dec936022db9379)
This commit is contained in:
parent
3ad20e27ae
commit
5a0bc35799
2 changed files with 10 additions and 50 deletions
|
@ -48,32 +48,12 @@ func Home(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = org.DisplayName()
|
ctx.Data["Title"] = org.DisplayName()
|
||||||
|
|
||||||
var orderBy db.SearchOrderBy
|
var orderBy db.SearchOrderBy
|
||||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
sortOrder := ctx.FormString("sort")
|
||||||
switch ctx.FormString("sort") {
|
if _, ok := repo_model.OrderByFlatMap[sortOrder]; !ok {
|
||||||
case "newest":
|
sortOrder = setting.UI.ExploreDefaultSort // TODO: add new default sort order for org home?
|
||||||
orderBy = db.SearchOrderByNewest
|
|
||||||
case "oldest":
|
|
||||||
orderBy = db.SearchOrderByOldest
|
|
||||||
case "recentupdate":
|
|
||||||
orderBy = db.SearchOrderByRecentUpdated
|
|
||||||
case "leastupdate":
|
|
||||||
orderBy = db.SearchOrderByLeastUpdated
|
|
||||||
case "reversealphabetically":
|
|
||||||
orderBy = db.SearchOrderByAlphabeticallyReverse
|
|
||||||
case "alphabetically":
|
|
||||||
orderBy = db.SearchOrderByAlphabetically
|
|
||||||
case "moststars":
|
|
||||||
orderBy = db.SearchOrderByStarsReverse
|
|
||||||
case "feweststars":
|
|
||||||
orderBy = db.SearchOrderByStars
|
|
||||||
case "mostforks":
|
|
||||||
orderBy = db.SearchOrderByForksReverse
|
|
||||||
case "fewestforks":
|
|
||||||
orderBy = db.SearchOrderByForks
|
|
||||||
default:
|
|
||||||
ctx.Data["SortType"] = "recentupdate"
|
|
||||||
orderBy = db.SearchOrderByRecentUpdated
|
|
||||||
}
|
}
|
||||||
|
ctx.Data["SortType"] = sortOrder
|
||||||
|
orderBy = repo_model.OrderByFlatMap[sortOrder]
|
||||||
|
|
||||||
keyword := ctx.FormTrim("q")
|
keyword := ctx.FormTrim("q")
|
||||||
ctx.Data["Keyword"] = keyword
|
ctx.Data["Keyword"] = keyword
|
||||||
|
|
|
@ -112,32 +112,12 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb
|
||||||
orderBy db.SearchOrderBy
|
orderBy db.SearchOrderBy
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
sortOrder := ctx.FormString("sort")
|
||||||
switch ctx.FormString("sort") {
|
if _, ok := repo_model.OrderByFlatMap[sortOrder]; !ok {
|
||||||
case "newest":
|
sortOrder = setting.UI.ExploreDefaultSort // TODO: add new default sort order for org home?
|
||||||
orderBy = db.SearchOrderByNewest
|
|
||||||
case "oldest":
|
|
||||||
orderBy = db.SearchOrderByOldest
|
|
||||||
case "recentupdate":
|
|
||||||
orderBy = db.SearchOrderByRecentUpdated
|
|
||||||
case "leastupdate":
|
|
||||||
orderBy = db.SearchOrderByLeastUpdated
|
|
||||||
case "reversealphabetically":
|
|
||||||
orderBy = db.SearchOrderByAlphabeticallyReverse
|
|
||||||
case "alphabetically":
|
|
||||||
orderBy = db.SearchOrderByAlphabetically
|
|
||||||
case "moststars":
|
|
||||||
orderBy = db.SearchOrderByStarsReverse
|
|
||||||
case "feweststars":
|
|
||||||
orderBy = db.SearchOrderByStars
|
|
||||||
case "mostforks":
|
|
||||||
orderBy = db.SearchOrderByForksReverse
|
|
||||||
case "fewestforks":
|
|
||||||
orderBy = db.SearchOrderByForks
|
|
||||||
default:
|
|
||||||
ctx.Data["SortType"] = "recentupdate"
|
|
||||||
orderBy = db.SearchOrderByRecentUpdated
|
|
||||||
}
|
}
|
||||||
|
ctx.Data["SortType"] = sortOrder
|
||||||
|
orderBy = repo_model.OrderByFlatMap[sortOrder]
|
||||||
|
|
||||||
keyword := ctx.FormTrim("q")
|
keyword := ctx.FormTrim("q")
|
||||||
ctx.Data["Keyword"] = keyword
|
ctx.Data["Keyword"] = keyword
|
||||||
|
|
Loading…
Reference in a new issue