summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author0ko <0ko@noreply.codeberg.org>2024-03-07 09:30:12 +0100
committer0ko <0ko@noreply.codeberg.org>2024-03-07 09:30:12 +0100
commit498a3f988db67927b538c2224d5637dba965588f (patch)
tree7d8d1ba4356641d796177afd64da39d9dd696ce5
parentMerge pull request '[BUG] Remember topic only in repo search' (#2575) from gu... (diff)
downloadforgejo-498a3f988db67927b538c2224d5637dba965588f.tar.xz
forgejo-498a3f988db67927b538c2224d5637dba965588f.zip
Better number for UserCards pagination
-rw-r--r--modules/setting/repository.go8
-rw-r--r--routers/web/repo/view.go8
2 files changed, 10 insertions, 6 deletions
diff --git a/modules/setting/repository.go b/modules/setting/repository.go
index 7a07fec85c..8f8c82b004 100644
--- a/modules/setting/repository.go
+++ b/modules/setting/repository.go
@@ -22,8 +22,12 @@ const (
var RecognisedRepositoryDownloadOrCloneMethods = []string{"download-zip", "download-targz", "download-bundle", "vscode-clone", "vscodium-clone", "cite"}
-// ItemsPerPage maximum items per page in forks, watchers and stars of a repo
-const ItemsPerPage = 40
+// MaxUserCardsPerPage sets maximum amount of watchers and stargazers shown per page
+// those pages use 2 or 3 column layout, so the value should be divisible by 2 and 3
+const MaxUserCardsPerPage = 36
+
+// MaxForksPerPage sets maximum amount of forks shown per page
+const MaxForksPerPage = 40
// Repository settings
var (
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 27984e7621..9f8d1fcdfd 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -1127,12 +1127,12 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOp
if page <= 0 {
page = 1
}
- pager := context.NewPagination(total, setting.ItemsPerPage, page, 5)
+ pager := context.NewPagination(total, setting.MaxUserCardsPerPage, page, 5)
ctx.Data["Page"] = pager
items, err := getter(db.ListOptions{
Page: pager.Paginater.Current(),
- PageSize: setting.ItemsPerPage,
+ PageSize: setting.MaxUserCardsPerPage,
})
if err != nil {
ctx.ServerError("getter", err)
@@ -1173,12 +1173,12 @@ func Forks(ctx *context.Context) {
page = 1
}
- pager := context.NewPagination(ctx.Repo.Repository.NumForks, setting.ItemsPerPage, page, 5)
+ pager := context.NewPagination(ctx.Repo.Repository.NumForks, setting.MaxForksPerPage, page, 5)
ctx.Data["Page"] = pager
forks, err := repo_model.GetForks(ctx, ctx.Repo.Repository, db.ListOptions{
Page: pager.Paginater.Current(),
- PageSize: setting.ItemsPerPage,
+ PageSize: setting.MaxForksPerPage,
})
if err != nil {
ctx.ServerError("GetForks", err)