Remove ONLY_SHOW_RELEVANT_REPOS setting (#21962)
Every user can already disable the filter manually, so the explicit setting is absolutely useless and only complicates the logic. Previously, there was also unexpected behavior when multiple query parameters were present. --------- Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
ea13b23349
commit
4d20a4a1ba
|
@ -1222,10 +1222,6 @@ ROUTER = console
|
||||||
;;
|
;;
|
||||||
;; Whether to enable a Service Worker to cache frontend assets
|
;; Whether to enable a Service Worker to cache frontend assets
|
||||||
;USE_SERVICE_WORKER = false
|
;USE_SERVICE_WORKER = 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).
|
|
||||||
;ONLY_SHOW_RELEVANT_REPOS = false
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -231,8 +231,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||||
- `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.
|
||||||
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
|
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
|
||||||
- `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).
|
|
||||||
|
|
||||||
### UI - Admin (`ui.admin`)
|
### UI - Admin (`ui.admin`)
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.OnlyShowRelevant {
|
if opts.OnlyShowRelevant {
|
||||||
// Only show a repo that either has a topic or description.
|
// Only show a repo that has at least a topic, an icon, or a description
|
||||||
subQueryCond := builder.NewCond()
|
subQueryCond := builder.NewCond()
|
||||||
|
|
||||||
// Topic checking. Topics are present.
|
// Topic checking. Topics are present.
|
||||||
|
@ -504,13 +504,13 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
|
||||||
subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"}))
|
subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description checking. Description not empty.
|
// Description checking. Description not empty
|
||||||
subQueryCond = subQueryCond.Or(builder.Neq{"description": ""})
|
subQueryCond = subQueryCond.Or(builder.Neq{"description": ""})
|
||||||
|
|
||||||
// Repo has a avatar.
|
// Repo has a avatar
|
||||||
subQueryCond = subQueryCond.Or(builder.Neq{"avatar": ""})
|
subQueryCond = subQueryCond.Or(builder.Neq{"avatar": ""})
|
||||||
|
|
||||||
// Always hide repo's that are empty.
|
// Always hide repo's that are empty
|
||||||
subQueryCond = subQueryCond.And(builder.Eq{"is_empty": false})
|
subQueryCond = subQueryCond.And(builder.Eq{"is_empty": false})
|
||||||
|
|
||||||
cond = cond.And(subQueryCond)
|
cond = cond.And(subQueryCond)
|
||||||
|
|
|
@ -241,7 +241,6 @@ var (
|
||||||
CustomEmojisMap map[string]string `ini:"-"`
|
CustomEmojisMap map[string]string `ini:"-"`
|
||||||
SearchRepoDescription bool
|
SearchRepoDescription bool
|
||||||
UseServiceWorker bool
|
UseServiceWorker bool
|
||||||
OnlyShowRelevantRepos bool
|
|
||||||
|
|
||||||
Notification struct {
|
Notification struct {
|
||||||
MinTimeout time.Duration
|
MinTimeout time.Duration
|
||||||
|
@ -1123,7 +1122,6 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
|
||||||
UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
|
UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
|
||||||
UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
|
UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
|
||||||
UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false)
|
UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false)
|
||||||
UI.OnlyShowRelevantRepos = Cfg.Section("ui").Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false)
|
|
||||||
|
|
||||||
HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt"))
|
HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
const (
|
const (
|
||||||
// tplExploreRepos explore repositories page template
|
// tplExploreRepos explore repositories page template
|
||||||
tplExploreRepos base.TplName = "explore/repos"
|
tplExploreRepos base.TplName = "explore/repos"
|
||||||
|
relevantReposOnlyParam string = "no_filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RepoSearchOptions when calling search repositories
|
// RepoSearchOptions when calling search repositories
|
||||||
|
@ -81,13 +82,11 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||||
default:
|
default:
|
||||||
ctx.Data["SortType"] = "recentupdate"
|
ctx.Data["SortType"] = "recentupdate"
|
||||||
orderBy = db.SearchOrderByRecentUpdated
|
orderBy = db.SearchOrderByRecentUpdated
|
||||||
onlyShowRelevant = setting.UI.OnlyShowRelevantRepos && !ctx.FormBool("no_filter")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onlyShowRelevant = !ctx.FormBool(relevantReposOnlyParam)
|
||||||
|
|
||||||
keyword := ctx.FormTrim("q")
|
keyword := ctx.FormTrim("q")
|
||||||
if keyword != "" {
|
|
||||||
onlyShowRelevant = false
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
|
ctx.Data["OnlyShowRelevant"] = onlyShowRelevant
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||||
pager.SetDefaultParams(ctx)
|
pager.SetDefaultParams(ctx)
|
||||||
pager.AddParam(ctx, "topic", "TopicOnly")
|
pager.AddParam(ctx, "topic", "TopicOnly")
|
||||||
pager.AddParam(ctx, "language", "Language")
|
pager.AddParam(ctx, "language", "Language")
|
||||||
pager.AddParamString("no_filter", ctx.FormString("no_filter"))
|
pager.AddParamString(relevantReposOnlyParam, ctx.FormString(relevantReposOnlyParam))
|
||||||
ctx.Data["Page"] = pager
|
ctx.Data["Page"] = pager
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, opts.TplName)
|
ctx.HTML(http.StatusOK, opts.TplName)
|
||||||
|
|
Loading…
Reference in New Issue