Skip to content

Commit d985d4b

Browse files
lunny6543
andauthored
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 <[email protected]>
1 parent f5b0e2c commit d985d4b

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

custom/conf/app.example.ini

+1
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ PATH =
907907
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
908908
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
909909
;ALLOWED_TYPES =
910+
;DEFAULT_PAGING_NUM = 10
910911

911912
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
912913
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
115115
### Repository - Release (`repository.release`)
116116

117117
- `ALLOWED_TYPES`: **\<empty\>**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
118+
- `DEFAULT_PAGING_NUM`: **10**: The default paging number of releases user interface
118119

119120
### Repository - Signing (`repository.signing`)
120121

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ menu:
3636
- `MAX_CREATION_LIMIT`: 全局最大每个用户创建的git工程数目, `-1` 表示没限制。
3737
- `PULL_REQUEST_QUEUE_LENGTH`: 小心:合并请求测试队列的长度,尽量放大。
3838

39+
### Repository - Release (`repository.release`)
40+
41+
- `ALLOWED_TYPES`: **\<empty\>**: 允许扩展名的列表,用逗号分隔 (`.zip`), mime 类型 (`text/plain`) 或者匹配符号 (`image/*`, `audio/*`, `video/*`). 空值或者 `*/*` 允许所有类型。
42+
- `DEFAULT_PAGING_NUM`: **10**: 默认的发布版本页面分页。
43+
3944
## UI (`ui`)
4045

4146
- `EXPLORE_PAGING_NUM`: 探索页面每页显示的仓库数量。

modules/setting/repository.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ var (
8787
} `ini:"repository.issue"`
8888

8989
Release struct {
90-
AllowedTypes string
90+
AllowedTypes string
91+
DefaultPagingNum int
9192
} `ini:"repository.release"`
9293

9394
Signing struct {
@@ -223,9 +224,11 @@ var (
223224
},
224225

225226
Release: struct {
226-
AllowedTypes string
227+
AllowedTypes string
228+
DefaultPagingNum int
227229
}{
228-
AllowedTypes: "",
230+
AllowedTypes: "",
231+
DefaultPagingNum: 10,
229232
},
230233

231234
// Signing settings

routers/web/repo/release.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"code.gitea.io/gitea/models"
1414
"code.gitea.io/gitea/modules/base"
1515
"code.gitea.io/gitea/modules/context"
16-
"code.gitea.io/gitea/modules/convert"
1716
"code.gitea.io/gitea/modules/log"
1817
"code.gitea.io/gitea/modules/markup"
1918
"code.gitea.io/gitea/modules/markup/markdown"
@@ -93,11 +92,18 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
9392

9493
writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases)
9594
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
95+
limit := ctx.FormInt("limit")
96+
if limit == 0 {
97+
limit = setting.Repository.Release.DefaultPagingNum
98+
}
99+
if limit > setting.API.MaxResponseItems {
100+
limit = setting.API.MaxResponseItems
101+
}
96102

97103
opts := models.FindReleasesOptions{
98104
ListOptions: models.ListOptions{
99105
Page: ctx.FormInt("page"),
100-
PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
106+
PageSize: limit,
101107
},
102108
IncludeDrafts: writeAccess && !isTagList,
103109
IncludeTags: isTagList,

0 commit comments

Comments
 (0)