diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-08-30 00:25:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-29 18:25:16 +0200 |
commit | d985d4bc2f69439aafc8e516a3f0929d47cfb0e2 (patch) | |
tree | 1cb1bfd264c6d6ae0098ec781676162a42fc470f /routers | |
parent | f5b0e2c9d2336367dfcf121be6ff5154017192cf (diff) | |
download | gitea-d985d4bc2f69439aafc8e516a3f0929d47cfb0e2.tar.gz gitea-d985d4bc2f69439aafc8e516a3f0929d47cfb0e2.zip |
Paginate releases page & set default page size to 10 (#16857)
* Add release default page and set it to 10
* use limit
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/release.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index d37955c559..ef98790f52 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" @@ -93,11 +92,18 @@ func releasesOrTags(ctx *context.Context, isTagList bool) { writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases) ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived + limit := ctx.FormInt("limit") + if limit == 0 { + limit = setting.Repository.Release.DefaultPagingNum + } + if limit > setting.API.MaxResponseItems { + limit = setting.API.MaxResponseItems + } opts := models.FindReleasesOptions{ ListOptions: models.ListOptions{ Page: ctx.FormInt("page"), - PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")), + PageSize: limit, }, IncludeDrafts: writeAccess && !isTagList, IncludeTags: isTagList, |