mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 11:21:19 +01:00
Allow to set explore page default sort (#27951)
as title --- *Sponsored by Kithara Software GmbH*
This commit is contained in:
parent
69d98f83f9
commit
16ba16dbe9
8 changed files with 28 additions and 15 deletions
|
@ -1238,6 +1238,10 @@ LEVEL = Info
|
||||||
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
|
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
|
||||||
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
|
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
|
||||||
;ONLY_SHOW_RELEVANT_REPOS = false
|
;ONLY_SHOW_RELEVANT_REPOS = false
|
||||||
|
;;
|
||||||
|
;; Change the sort type of the explore pages.
|
||||||
|
;; Default is "recentupdate", but you also have "alphabetically", "reverselastlogin", "newest", "oldest".
|
||||||
|
;EXPLORE_PAGING_DEFAULT_SORT = recentupdate
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -229,8 +229,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||||
add it to this config.
|
add it to this config.
|
||||||
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
|
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
|
||||||
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
|
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
|
||||||
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
|
- `ONLY_SHOW_RELEVANT_REPOS`: **false**: Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
|
||||||
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
|
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
|
||||||
|
- `EXPLORE_PAGING_DEFAULT_SORT`: **recentupdate**: Change the sort type of the explore pages. Valid values are "recentupdate", "alphabetically", "reverselastlogin", "newest" and "oldest"
|
||||||
|
|
||||||
### UI - Admin (`ui.admin`)
|
### UI - Admin (`ui.admin`)
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ var UI = struct {
|
||||||
CustomEmojisMap map[string]string `ini:"-"`
|
CustomEmojisMap map[string]string `ini:"-"`
|
||||||
SearchRepoDescription bool
|
SearchRepoDescription bool
|
||||||
OnlyShowRelevantRepos bool
|
OnlyShowRelevantRepos bool
|
||||||
|
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
|
||||||
|
|
||||||
Notification struct {
|
Notification struct {
|
||||||
MinTimeout time.Duration
|
MinTimeout time.Duration
|
||||||
|
|
|
@ -24,7 +24,7 @@ func Organizations(ctx *context.Context) {
|
||||||
ctx.Data["PageIsAdminOrganizations"] = true
|
ctx.Data["PageIsAdminOrganizations"] = true
|
||||||
|
|
||||||
if ctx.FormString("sort") == "" {
|
if ctx.FormString("sort") == "" {
|
||||||
ctx.SetFormString("sort", explore.UserSearchDefaultAdminSort)
|
ctx.SetFormString("sort", UserSearchDefaultAdminSort)
|
||||||
}
|
}
|
||||||
|
|
||||||
explore.RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
explore.RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
||||||
|
|
|
@ -37,6 +37,9 @@ const (
|
||||||
tplUserEdit base.TplName = "admin/user/edit"
|
tplUserEdit base.TplName = "admin/user/edit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UserSearchDefaultAdminSort is the default sort type for admin view
|
||||||
|
const UserSearchDefaultAdminSort = "alphabetically"
|
||||||
|
|
||||||
// Users show all the users
|
// Users show all the users
|
||||||
func Users(ctx *context.Context) {
|
func Users(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("admin.users")
|
ctx.Data["Title"] = ctx.Tr("admin.users")
|
||||||
|
@ -56,7 +59,7 @@ func Users(ctx *context.Context) {
|
||||||
|
|
||||||
sortType := ctx.FormString("sort")
|
sortType := ctx.FormString("sort")
|
||||||
if sortType == "" {
|
if sortType == "" {
|
||||||
sortType = explore.UserSearchDefaultAdminSort
|
sortType = UserSearchDefaultAdminSort
|
||||||
ctx.SetFormString("sort", sortType)
|
ctx.SetFormString("sort", sortType)
|
||||||
}
|
}
|
||||||
ctx.PageData["adminUserListSearchForm"] = map[string]any{
|
ctx.PageData["adminUserListSearchForm"] = map[string]any{
|
||||||
|
|
|
@ -25,7 +25,7 @@ func Organizations(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.FormString("sort") == "" {
|
if ctx.FormString("sort") == "" {
|
||||||
ctx.SetFormString("sort", UserSearchDefaultSortType)
|
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
||||||
|
|
|
@ -57,8 +57,13 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||||
orderBy db.SearchOrderBy
|
orderBy db.SearchOrderBy
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
sortOrder := ctx.FormString("sort")
|
||||||
switch ctx.FormString("sort") {
|
if sortOrder == "" {
|
||||||
|
sortOrder = setting.UI.ExploreDefaultSort
|
||||||
|
}
|
||||||
|
ctx.Data["SortType"] = sortOrder
|
||||||
|
|
||||||
|
switch sortOrder {
|
||||||
case "newest":
|
case "newest":
|
||||||
orderBy = db.SearchOrderByNewest
|
orderBy = db.SearchOrderByNewest
|
||||||
case "oldest":
|
case "oldest":
|
||||||
|
|
|
@ -23,12 +23,6 @@ const (
|
||||||
tplExploreUsers base.TplName = "explore/users"
|
tplExploreUsers base.TplName = "explore/users"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserSearchDefaultSortType is the default sort type for user search
|
|
||||||
const (
|
|
||||||
UserSearchDefaultSortType = "recentupdate"
|
|
||||||
UserSearchDefaultAdminSort = "alphabetically"
|
|
||||||
)
|
|
||||||
|
|
||||||
var nullByte = []byte{0x00}
|
var nullByte = []byte{0x00}
|
||||||
|
|
||||||
func isKeywordValid(keyword string) bool {
|
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
|
// 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")
|
sortOrder := ctx.FormString("sort")
|
||||||
switch ctx.FormString("sort") {
|
if sortOrder == "" {
|
||||||
|
sortOrder = setting.UI.ExploreDefaultSort
|
||||||
|
}
|
||||||
|
ctx.Data["SortType"] = sortOrder
|
||||||
|
|
||||||
|
switch sortOrder {
|
||||||
case "newest":
|
case "newest":
|
||||||
orderBy = "`user`.id DESC"
|
orderBy = "`user`.id DESC"
|
||||||
case "oldest":
|
case "oldest":
|
||||||
|
@ -134,7 +133,7 @@ func Users(ctx *context.Context) {
|
||||||
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||||
|
|
||||||
if ctx.FormString("sort") == "" {
|
if ctx.FormString("sort") == "" {
|
||||||
ctx.SetFormString("sort", UserSearchDefaultSortType)
|
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
RenderUserSearch(ctx, &user_model.SearchUserOptions{
|
||||||
|
|
Loading…
Reference in a new issue