Better number for UserCards pagination
This commit is contained in:
parent
d759bec64f
commit
498a3f988d
|
@ -22,8 +22,12 @@ const (
|
||||||
|
|
||||||
var RecognisedRepositoryDownloadOrCloneMethods = []string{"download-zip", "download-targz", "download-bundle", "vscode-clone", "vscodium-clone", "cite"}
|
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
|
// MaxUserCardsPerPage sets maximum amount of watchers and stargazers shown per page
|
||||||
const ItemsPerPage = 40
|
// 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
|
// Repository settings
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -1127,12 +1127,12 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOp
|
||||||
if page <= 0 {
|
if page <= 0 {
|
||||||
page = 1
|
page = 1
|
||||||
}
|
}
|
||||||
pager := context.NewPagination(total, setting.ItemsPerPage, page, 5)
|
pager := context.NewPagination(total, setting.MaxUserCardsPerPage, page, 5)
|
||||||
ctx.Data["Page"] = pager
|
ctx.Data["Page"] = pager
|
||||||
|
|
||||||
items, err := getter(db.ListOptions{
|
items, err := getter(db.ListOptions{
|
||||||
Page: pager.Paginater.Current(),
|
Page: pager.Paginater.Current(),
|
||||||
PageSize: setting.ItemsPerPage,
|
PageSize: setting.MaxUserCardsPerPage,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("getter", err)
|
ctx.ServerError("getter", err)
|
||||||
|
@ -1173,12 +1173,12 @@ func Forks(ctx *context.Context) {
|
||||||
page = 1
|
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
|
ctx.Data["Page"] = pager
|
||||||
|
|
||||||
forks, err := repo_model.GetForks(ctx, ctx.Repo.Repository, db.ListOptions{
|
forks, err := repo_model.GetForks(ctx, ctx.Repo.Repository, db.ListOptions{
|
||||||
Page: pager.Paginater.Current(),
|
Page: pager.Paginater.Current(),
|
||||||
PageSize: setting.ItemsPerPage,
|
PageSize: setting.MaxForksPerPage,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetForks", err)
|
ctx.ServerError("GetForks", err)
|
||||||
|
|
Loading…
Reference in a new issue