Skip to content
4 changes: 4 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,10 @@ LEVEL = Info
;; 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).
;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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
3 changes: 2 additions & 1 deletion docs/content/administration/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
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.
- `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).
- `EXPLORE_PAGING_DEFAULT_SORT`: **recentupdate**: Change the sort type of the explore pages. Valid vaules are "recentupdate", "alphabetically", "reverselastlogin", "newest" and "oldest"

### UI - Admin (`ui.admin`)

Expand Down
1 change: 1 addition & 0 deletions modules/setting/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var UI = struct {
CustomEmojisMap map[string]string `ini:"-"`
SearchRepoDescription bool
OnlyShowRelevantRepos bool
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`

Notification struct {
MinTimeout time.Duration
Expand Down
2 changes: 1 addition & 1 deletion routers/web/explore/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
9 changes: 7 additions & 2 deletions routers/web/explore/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
11 changes: 8 additions & 3 deletions routers/web/explore/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,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":
Expand Down Expand Up @@ -134,7 +139,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{
Expand Down