mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Allow to set explore page default sort (#27951)
as title --- *Sponsored by Kithara Software GmbH*
This commit is contained in:
@@ -25,7 +25,7 @@ func Organizations(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if ctx.FormString("sort") == "" {
|
||||
ctx.SetFormString("sort", UserSearchDefaultSortType)
|
||||
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
|
||||
}
|
||||
|
||||
RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
||||
|
@@ -57,8 +57,13 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||
orderBy db.SearchOrderBy
|
||||
)
|
||||
|
||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
||||
switch ctx.FormString("sort") {
|
||||
sortOrder := ctx.FormString("sort")
|
||||
if sortOrder == "" {
|
||||
sortOrder = setting.UI.ExploreDefaultSort
|
||||
}
|
||||
ctx.Data["SortType"] = sortOrder
|
||||
|
||||
switch sortOrder {
|
||||
case "newest":
|
||||
orderBy = db.SearchOrderByNewest
|
||||
case "oldest":
|
||||
|
@@ -23,12 +23,6 @@ const (
|
||||
tplExploreUsers base.TplName = "explore/users"
|
||||
)
|
||||
|
||||
// UserSearchDefaultSortType is the default sort type for user search
|
||||
const (
|
||||
UserSearchDefaultSortType = "recentupdate"
|
||||
UserSearchDefaultAdminSort = "alphabetically"
|
||||
)
|
||||
|
||||
var nullByte = []byte{0x00}
|
||||
|
||||
func isKeywordValid(keyword string) bool {
|
||||
@@ -60,8 +54,13 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,
|
||||
|
||||
// we can not set orderBy to `models.SearchOrderByXxx`, because there may be a JOIN in the statement, different tables may have the same name columns
|
||||
|
||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
||||
switch ctx.FormString("sort") {
|
||||
sortOrder := ctx.FormString("sort")
|
||||
if sortOrder == "" {
|
||||
sortOrder = setting.UI.ExploreDefaultSort
|
||||
}
|
||||
ctx.Data["SortType"] = sortOrder
|
||||
|
||||
switch sortOrder {
|
||||
case "newest":
|
||||
orderBy = "`user`.id DESC"
|
||||
case "oldest":
|
||||
@@ -134,7 +133,7 @@ func Users(ctx *context.Context) {
|
||||
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||
|
||||
if ctx.FormString("sort") == "" {
|
||||
ctx.SetFormString("sort", UserSearchDefaultSortType)
|
||||
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
|
||||
}
|
||||
|
||||
RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
||||
|
Reference in New Issue
Block a user