diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-08-25 20:38:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 20:38:41 +0200 |
commit | 27ac65a124f34ec3ed5f34aeb576f918ae1c70b1 (patch) | |
tree | 2c31f4d30e5bfce87056c397fcdae6c6e86c5788 /routers | |
parent | dc0253b0637bbf367ad330612900e780c6b2b0e6 (diff) | |
download | gitea-27ac65a124f34ec3ed5f34aeb576f918ae1c70b1.tar.gz gitea-27ac65a124f34ec3ed5f34aeb576f918ae1c70b1.zip |
Only show relevant repositories on explore page (#19361)
Adds a new option to only show relevant repo's on the explore page, for bigger Gitea instances like Codeberg this is a nice option to enable to make the explore page more populated with unique and "high" quality repo's. A note is shown that the results are filtered and have the possibility to see the unfiltered results.
Co-authored-by: vednoc <vednoc@protonmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/explore/repo.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index b5485f5832..8cb615b7bc 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -48,10 +48,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") @@ -60,8 +61,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": @@ -83,9 +82,16 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { default: ctx.Data["SortType"] = "recentupdate" orderBy = db.SearchOrderByRecentUpdated + onlyShowRelevant = setting.UI.OnlyShowRelevantRepos && !ctx.FormBool("no_filter") } keyword := ctx.FormTrim("q") + if keyword != "" { + onlyShowRelevant = false + } + + ctx.Data["OnlyShowRelevant"] = onlyShowRelevant + topicOnly := ctx.FormBool("topic") ctx.Data["TopicOnly"] = topicOnly @@ -107,6 +113,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) @@ -133,6 +140,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) |