From 498a3f988db67927b538c2224d5637dba965588f Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Thu, 7 Mar 2024 13:30:12 +0500 Subject: [PATCH] Better number for UserCards pagination --- modules/setting/repository.go | 8 ++++++-- routers/web/repo/view.go | 8 ++++---- 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)