diff options
author | Lauris BH <lauris@nix.lv> | 2022-01-28 13:29:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 13:29:04 +0200 |
commit | 604ce776287545b31991f0c78b13854b36ed2f59 (patch) | |
tree | 6a3cb4ce33d8b4044548c0841730884384b41881 /routers/web | |
parent | 401e5c817474436218af08602da5135774d2c0eb (diff) | |
download | gitea-604ce776287545b31991f0c78b13854b36ed2f59.tar.gz gitea-604ce776287545b31991f0c78b13854b36ed2f59.zip |
Allow to filter repositories by language in explore, user and organization repositories lists (#18430)
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/explore/repo.go | 5 | ||||
-rw-r--r-- | routers/web/org/home.go | 5 | ||||
-rw-r--r-- | routers/web/user/profile.go | 10 |
3 files changed, 20 insertions, 0 deletions
diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 0a78e9e29d..ce3aefe26f 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -78,6 +78,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { topicOnly := ctx.FormBool("topic") ctx.Data["TopicOnly"] = topicOnly + language := ctx.FormTrim("language") + ctx.Data["Language"] = language + repos, count, err = models.SearchRepository(&models.SearchRepoOptions{ ListOptions: db.ListOptions{ Page: page, @@ -91,6 +94,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { AllPublic: true, AllLimited: true, TopicOnly: topicOnly, + Language: language, IncludeDescription: setting.UI.SearchRepoDescription, }) if err != nil { @@ -105,6 +109,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { pager := context.NewPagination(int(count), opts.PageSize, page, 5) pager.SetDefaultParams(ctx) pager.AddParam(ctx, "topic", "TopicOnly") + pager.AddParam(ctx, "language", "Language") ctx.Data["Page"] = pager ctx.HTML(http.StatusOK, opts.TplName) diff --git a/routers/web/org/home.go b/routers/web/org/home.go index cf23a1e291..d07e2993b2 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -83,6 +83,9 @@ func Home(ctx *context.Context) { keyword := ctx.FormTrim("q") ctx.Data["Keyword"] = keyword + language := ctx.FormTrim("language") + ctx.Data["Language"] = language + page := ctx.FormInt("page") if page <= 0 { page = 1 @@ -103,6 +106,7 @@ func Home(ctx *context.Context) { OrderBy: orderBy, Private: ctx.IsSigned, Actor: ctx.User, + Language: language, IncludeDescription: setting.UI.SearchRepoDescription, }) if err != nil { @@ -148,6 +152,7 @@ func Home(ctx *context.Context) { pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5) pager.SetDefaultParams(ctx) + pager.AddParam(ctx, "language", "Language") ctx.Data["Page"] = pager ctx.HTML(http.StatusOK, tplOrgHome) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 86ecb7c02c..9c0ce10dae 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -232,6 +232,10 @@ func Profile(ctx *context.Context) { keyword := ctx.FormTrim("q") ctx.Data["Keyword"] = keyword + + language := ctx.FormTrim("language") + ctx.Data["Language"] = language + switch tab { case "followers": items, err := user_model.GetUserFollowers(ctxUser, db.ListOptions{ @@ -283,6 +287,7 @@ func Profile(ctx *context.Context) { StarredByID: ctxUser.ID, Collaborate: util.OptionalBoolFalse, TopicOnly: topicOnly, + Language: language, IncludeDescription: setting.UI.SearchRepoDescription, }) if err != nil { @@ -314,6 +319,7 @@ func Profile(ctx *context.Context) { WatchedByID: ctxUser.ID, Collaborate: util.OptionalBoolFalse, TopicOnly: topicOnly, + Language: language, IncludeDescription: setting.UI.SearchRepoDescription, }) if err != nil { @@ -335,6 +341,7 @@ func Profile(ctx *context.Context) { Private: ctx.IsSigned, Collaborate: util.OptionalBoolFalse, TopicOnly: topicOnly, + Language: language, IncludeDescription: setting.UI.SearchRepoDescription, }) if err != nil { @@ -349,6 +356,9 @@ func Profile(ctx *context.Context) { pager := context.NewPagination(total, setting.UI.User.RepoPagingNum, page, 5) pager.SetDefaultParams(ctx) + if tab != "followers" && tab != "following" && tab != "activity" && tab != "projects" { + pager.AddParam(ctx, "language", "Language") + } ctx.Data["Page"] = pager ctx.Data["ShowUserEmail"] = len(ctxUser.Email) > 0 && ctx.IsSigned && (!ctxUser.KeepEmailPrivate || ctxUser.ID == ctx.User.ID) |