From 1dc8fde569e818354597a9246acc1d0b8a462fbb Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 17:25:25 +0200 Subject: [PATCH 01/16] Only show relevant repositories (part 1) - By default on explore pages only show relevant repositories, this means the repo isn't a fork and either has a description or topic. - This Commit implements the backend for this idea. --- models/repo_list.go | 25 +++++++++++++++++++++++-- routers/web/explore/repo.go | 17 +++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/models/repo_list.go b/models/repo_list.go index 2c6be0a5768ac..0d6712da6d9e6 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -147,6 +147,10 @@ type SearchRepoOptions struct { HasMilestones util.OptionalBool // LowerNames represents valid lower names to restrict to LowerNames []string + // When specified true, apply some filters over the conditions: + // - Don't show forks, when opts.Fork is OptionalBoolNone. + // - Do not display repositories that lacks a description, icon and topic. + OnlyShowRelevant bool } // SearchOrderBy is used to sort the result @@ -449,8 +453,12 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { Where(builder.Eq{"language": opts.Language}).And(builder.Eq{"is_primary": true}))) } - if opts.Fork != util.OptionalBoolNone { - cond = cond.And(builder.Eq{"is_fork": opts.Fork == util.OptionalBoolTrue}) + if opts.Fork != util.OptionalBoolNone || opts.OnlyShowRelevant { + if opts.OnlyShowRelevant { + cond = cond.And(builder.Eq{"is_fork": false}) + } else { + cond = cond.And(builder.Eq{"is_fork": opts.Fork == util.OptionalBoolTrue}) + } } if opts.Mirror != util.OptionalBoolNone { @@ -472,6 +480,19 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { cond = cond.And(builder.Eq{"num_milestones": 0}.Or(builder.IsNull{"num_milestones"})) } + if opts.OnlyShowRelevant { + // Only show a repo that either has a topic, description or custom icon. + subQueryCond := builder.NewCond() + + // Topic checking. topics is non-null. + subQueryCond = subQueryCond.Or(builder.Neq{"topics": "null"}) + + // Description checking. Description not empty. + subQueryCond = subQueryCond.Or(builder.Neq{"description": ""}) + + cond = cond.And(subQueryCond) + } + return cond } diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 3e8aa2bb0fda7..588e4732c6f00 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -37,10 +37,11 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { } var ( - repos []*repo_model.Repository - count int64 - err error - orderBy db.SearchOrderBy + repos []*repo_model.Repository + count int64 + err error + orderBy db.SearchOrderBy + onlyShowRelevant bool ) ctx.Data["SortType"] = ctx.FormString("sort") @@ -72,9 +73,16 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { default: ctx.Data["SortType"] = "recentupdate" orderBy = db.SearchOrderByRecentUpdated + onlyShowRelevant = true } keyword := ctx.FormTrim("q") + if keyword != "" { + onlyShowRelevant = false + } + + ctx.Data["OnlyShowRelevant"] = onlyShowRelevant + topicOnly := ctx.FormBool("topic") ctx.Data["TopicOnly"] = topicOnly @@ -96,6 +104,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { TopicOnly: topicOnly, Language: language, IncludeDescription: setting.UI.SearchRepoDescription, + OnlyShowRelevant: onlyShowRelevant, }) if err != nil { ctx.ServerError("SearchRepository", err) From 89caf08d0b870b5d20ed0b3997f66af49319216e Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 18:12:59 +0200 Subject: [PATCH 02/16] Show information message to indicate filtered results - When the explore results are filtered(so no user query + default sorting), show a information message to indicate it has been filtered. Also offer users a easy way to unfilter the results. --- options/locale/locale_en-US.ini | 3 +++ routers/web/explore/repo.go | 2 +- templates/explore/repo_search.tmpl | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 5662ed2c40200..648027e93982a 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -275,6 +275,9 @@ org_no_results = No matching organizations found. code_no_results = No source code matching your search term found. code_search_results = Search results for '%s' code_last_indexed_at = Last indexed %s +relevant_repositories_tooltip = Repositories that are forks or don't have a topic and description aren't being shown. +relevant_repositories = Only relevant repositories are being shown, show unfiltered results. + [auth] create_new_account = Register Account diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 588e4732c6f00..117affaf540a0 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -73,7 +73,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { default: ctx.Data["SortType"] = "recentupdate" orderBy = db.SearchOrderByRecentUpdated - onlyShowRelevant = true + onlyShowRelevant = !ctx.FormBool("no_filter") } keyword := ctx.FormTrim("q") diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl index bc4572dfcdb26..56992222a9bd5 100644 --- a/templates/explore/repo_search.tmpl +++ b/templates/explore/repo_search.tmpl @@ -30,4 +30,9 @@ +{{if .OnlyShowRelevant}} +
+ {{.i18n.Tr "explore.relevant_repositories" ((printf "%s%s" $.Link "?no_filter=1")|Escape) | Safe}} +
+{{end}}
From 254c4c734c359f2e70c6d17395d1d589f4e59843 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 19:29:56 +0200 Subject: [PATCH 03/16] Add control logic --- custom/conf/app.example.ini | 4 ++++ docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 ++ modules/setting/setting.go | 2 ++ routers/web/explore/repo.go | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 4b5c2b1022725..09a3158820b52 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1133,6 +1133,10 @@ PATH = ;; ;; Whether to enable a Service Worker to cache frontend assets ;USE_SERVICE_WORKER = false +;; +;; Whether to only show relevant repo's on the explore page(when no keyword is specified and default sorting is used). +;; A repo is considered to be irrelevant if it's a fork or doesn't have a description or topic. +;HIDE_IRRELEVANT_REPOS = false ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 9d70269bf2fd4..352dc097b41a1 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -190,6 +190,8 @@ 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. - `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. +- `HIDE_IRRELEVANT_REPOS`: **false** Whether to only show relevant repo's on the explore page(when no keyword is specified and default sorting is used). + A repo is considered to be irrelevant if it's a fork or doesn't have a description or topic. ### UI - Admin (`ui.admin`) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 5e317b39ea289..89ce282fc6535 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -228,6 +228,7 @@ var ( CustomEmojisMap map[string]string `ini:"-"` SearchRepoDescription bool UseServiceWorker bool + HideIrrelevantRepo bool Notification struct { MinTimeout time.Duration @@ -1069,6 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true) UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false) + UI.HideIrrelevantRepo = Cfg.Section("ui").Key("HIDE_IRRELEVANT_REPOS").MustBool(false) HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt")) if err != nil { diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 117affaf540a0..47a64db7d4f10 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -73,7 +73,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { default: ctx.Data["SortType"] = "recentupdate" orderBy = db.SearchOrderByRecentUpdated - onlyShowRelevant = !ctx.FormBool("no_filter") + onlyShowRelevant = setting.UI.HideIrrelevantRepo && !ctx.FormBool("no_filter") } keyword := ctx.FormTrim("q") From 08bb17f670f31b6a392489113ae98d4797ce3cbd Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 19:41:13 +0200 Subject: [PATCH 04/16] Fix grammar Co-authored-by: vednoc --- custom/conf/app.example.ini | 4 ++-- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 09a3158820b52..249aba6e43222 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1134,8 +1134,8 @@ PATH = ;; Whether to enable a Service Worker to cache frontend assets ;USE_SERVICE_WORKER = false ;; -;; Whether to only show relevant repo's on the explore page(when no keyword is specified and default sorting is used). -;; A repo is considered to be irrelevant if it's a fork or doesn't have a description or topic. +;; 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 doesn't have set metadata (description, topic). ;HIDE_IRRELEVANT_REPOS = false ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 352dc097b41a1..0d427c659fe70 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -190,8 +190,8 @@ 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. - `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. -- `HIDE_IRRELEVANT_REPOS`: **false** Whether to only show relevant repo's on the explore page(when no keyword is specified and default sorting is used). - A repo is considered to be irrelevant if it's a fork or doesn't have a description or topic. +- `HIDE_IRRELEVANT_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 doesn't have set metadata (description, topic). ### UI - Admin (`ui.admin`) From 29985800a6e47c25c39aa049139a2ba9ba2a26cc Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 19:51:53 +0200 Subject: [PATCH 05/16] Move inline style to _explore.less --- templates/explore/repo_search.tmpl | 2 +- web_src/less/_explore.less | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl index 56992222a9bd5..89e3c463ff251 100644 --- a/templates/explore/repo_search.tmpl +++ b/templates/explore/repo_search.tmpl @@ -31,7 +31,7 @@ {{if .OnlyShowRelevant}} -
+
{{.i18n.Tr "explore.relevant_repositories" ((printf "%s%s" $.Link "?no_filter=1")|Escape) | Safe}}
{{end}} diff --git a/web_src/less/_explore.less b/web_src/less/_explore.less index 0939f98fa13bd..3a31fe44d8475 100644 --- a/web_src/less/_explore.less +++ b/web_src/less/_explore.less @@ -89,3 +89,9 @@ } } } + +.ui.explore-relevancy-note { + border-top: 0; + margin-top: 0; + max-width: 90%; +} From 95b3be9cab6b4fd54c4627f20ae437e8d64eb01c Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 19:53:12 +0200 Subject: [PATCH 06/16] Correctify comment --- models/repo_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo_list.go b/models/repo_list.go index 0d6712da6d9e6..268eaaf72832f 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -481,7 +481,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { } if opts.OnlyShowRelevant { - // Only show a repo that either has a topic, description or custom icon. + // Only show a repo that either has a topic or description. subQueryCond := builder.NewCond() // Topic checking. topics is non-null. From 47f7419e18eea3b36cbfc6ceeb4c43b8bdbcf5ad Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 19:59:08 +0200 Subject: [PATCH 07/16] Fix linter --- templates/explore/repo_search.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl index 89e3c463ff251..8d6696714946e 100644 --- a/templates/explore/repo_search.tmpl +++ b/templates/explore/repo_search.tmpl @@ -31,8 +31,8 @@
{{if .OnlyShowRelevant}} -
- {{.i18n.Tr "explore.relevant_repositories" ((printf "%s%s" $.Link "?no_filter=1")|Escape) | Safe}} -
+
+ {{.i18n.Tr "explore.relevant_repositories" ((printf "%s%s" $.Link "?no_filter=1")|Escape) | Safe}} +
{{end}}
From 68a23950f28795f84c7fa6767086a0597706abaa Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 9 Apr 2022 20:29:58 +0200 Subject: [PATCH 08/16] Restrict if statement --- models/repo_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo_list.go b/models/repo_list.go index 268eaaf72832f..ab1f8259d4b79 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -454,7 +454,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { } if opts.Fork != util.OptionalBoolNone || opts.OnlyShowRelevant { - if opts.OnlyShowRelevant { + if opts.OnlyShowRelevant && opts.Fork == util.OptionalBoolNone { cond = cond.And(builder.Eq{"is_fork": false}) } else { cond = cond.And(builder.Eq{"is_fork": opts.Fork == util.OptionalBoolTrue}) From aa8223ff54d3819536703b72ba657b3a97cc23ae Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 15 Apr 2022 21:12:40 +0200 Subject: [PATCH 09/16] Enhance setting naming --- custom/conf/app.example.ini | 2 +- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- modules/setting/setting.go | 4 ++-- routers/web/explore/repo.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 249aba6e43222..687f1bf6c5dfe 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1136,7 +1136,7 @@ PATH = ;; ;; 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 doesn't have set metadata (description, topic). -;HIDE_IRRELEVANT_REPOS = false +;ONLY_SHOW_RELEVANT_REPOS = false ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 0d427c659fe70..d0e16cf283ba1 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -190,7 +190,7 @@ 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. - `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. -- `HIDE_IRRELEVANT_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 doesn't have set metadata (description, topic). ### UI - Admin (`ui.admin`) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 89ce282fc6535..906a23ecbad81 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -228,7 +228,7 @@ var ( CustomEmojisMap map[string]string `ini:"-"` SearchRepoDescription bool UseServiceWorker bool - HideIrrelevantRepo bool + OnlyShowRelevantRepos bool Notification struct { MinTimeout time.Duration @@ -1070,7 +1070,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true) UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false) - UI.HideIrrelevantRepo = Cfg.Section("ui").Key("HIDE_IRRELEVANT_REPOS").MustBool(false) + UI.OnlyShowRelevantRepos = Cfg.Section("ui").Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false) HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt")) if err != nil { diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 47a64db7d4f10..51f54169c39fd 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -73,7 +73,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { default: ctx.Data["SortType"] = "recentupdate" orderBy = db.SearchOrderByRecentUpdated - onlyShowRelevant = setting.UI.HideIrrelevantRepo && !ctx.FormBool("no_filter") + onlyShowRelevant = setting.UI.OnlyShowRelevantRepos && !ctx.FormBool("no_filter") } keyword := ctx.FormTrim("q") From 5d5a501b30c879a9476bbce8cc17fc4013aeef81 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 25 Apr 2022 11:54:55 +0200 Subject: [PATCH 10/16] Fix empty topics --- models/repo_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo_list.go b/models/repo_list.go index ab1f8259d4b79..fbd89145859fd 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -485,7 +485,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { subQueryCond := builder.NewCond() // Topic checking. topics is non-null. - subQueryCond = subQueryCond.Or(builder.Neq{"topics": "null"}) + subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"})) // Description checking. Description not empty. subQueryCond = subQueryCond.Or(builder.Neq{"description": ""}) From db9d821ad7f4969f555228dc06007b9bc4457e1b Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 25 Apr 2022 12:02:39 +0200 Subject: [PATCH 11/16] Always use filtering logic for recentupdate sort --- routers/web/explore/repo.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 51f54169c39fd..d544bea404ff9 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -50,8 +50,6 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { orderBy = db.SearchOrderByNewest case "oldest": orderBy = db.SearchOrderByOldest - case "recentupdate": - orderBy = db.SearchOrderByRecentUpdated case "leastupdate": orderBy = db.SearchOrderByLeastUpdated case "reversealphabetically": From 4fe22effe87aafb5bb0a8866e5ea2bb616df756c Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 1 May 2022 00:48:03 +0200 Subject: [PATCH 12/16] Add no_filter to pager --- routers/web/explore/repo.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index d544bea404ff9..d52c20862fc58 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -117,6 +117,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { pager.SetDefaultParams(ctx) pager.AddParam(ctx, "topic", "TopicOnly") pager.AddParam(ctx, "language", "Language") + pager.AddParamString("no_filter", ctx.FormString("no_filter")) ctx.Data["Page"] = pager ctx.HTML(http.StatusOK, opts.TplName) From b7d6a4cb7f7dc20bfa194816c922f6490e0742a9 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 14 May 2022 02:55:10 +0200 Subject: [PATCH 13/16] Add more checks --- models/repo_list.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/repo_list.go b/models/repo_list.go index fbd89145859fd..bbb69f826ecae 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -484,12 +484,18 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond { // Only show a repo that either has a topic or description. subQueryCond := builder.NewCond() - // Topic checking. topics is non-null. + // Topic checking. Topics is non-null. subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"})) // Description checking. Description not empty. subQueryCond = subQueryCond.Or(builder.Neq{"description": ""}) + // Repo has a avatar. + subQueryCond = subQueryCond.Or(builder.Neq{"avatar": ""}) + + // Always hide repo's that are empty. + subQueryCond = subQueryCond.And(builder.Eq{"is_empty": false}) + cond = cond.And(subQueryCond) } From d11a339accb07cdf55099a7a5eebf043267f8f01 Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 17 Jun 2022 20:49:51 +0000 Subject: [PATCH 14/16] Apply suggestions from code review Co-authored-by: delvh --- custom/conf/app.example.ini | 2 +- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- models/repo_list.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 387f410208cf0..a025f76428f6d 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1136,7 +1136,7 @@ PATH = ;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 doesn't have set metadata (description, 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 288bf41bd0758..fe78b08de1160 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -191,7 +191,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `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. - `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 doesn't have set metadata (description, topic). + 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`) diff --git a/models/repo_list.go b/models/repo_list.go index 6d708200f51c7..920d54fe697a1 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -160,7 +160,7 @@ type SearchRepoOptions struct { LowerNames []string // When specified true, apply some filters over the conditions: // - Don't show forks, when opts.Fork is OptionalBoolNone. - // - Do not display repositories that lacks a description, icon and topic. + // - Do not display repositories that don't have a description, an icon and topics. OnlyShowRelevant bool } From bc970ec8a660ae91eb449ecd5622e7ccb56776d3 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 4 Jul 2022 03:11:25 +0200 Subject: [PATCH 15/16] Improve wording Co-authored-by: delvh --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 575729722f3ca..f5e6657615984 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -277,7 +277,7 @@ org_no_results = No matching organizations found. code_no_results = No source code matching your search term found. code_search_results = Search results for '%s' code_last_indexed_at = Last indexed %s -relevant_repositories_tooltip = Repositories that are forks or don't have a topic and description aren't being shown. +relevant_repositories_tooltip = Repositories that are forks or that have no topic, no icon, and no description are hidden. relevant_repositories = Only relevant repositories are being shown, show unfiltered results. From d385200301d1f081670fc5115feddbf99430e1e3 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 4 Jul 2022 03:13:10 +0200 Subject: [PATCH 16/16] Fix translation --- templates/explore/repo_search.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl index 2f8260010bc99..1dabfede8cd89 100644 --- a/templates/explore/repo_search.tmpl +++ b/templates/explore/repo_search.tmpl @@ -31,7 +31,7 @@ {{if .OnlyShowRelevant}}
- {{.i18n.Tr "explore.relevant_repositories" ((printf "%s%s" $.Link "?no_filter=1")|Escape) | Safe}} + {{.locale.Tr "explore.relevant_repositories" ((printf "%s%s" $.Link "?no_filter=1")|Escape) | Safe}}
{{end}}