diff options
author | Gusted <williamzijl7@hotmail.com> | 2021-11-18 14:45:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 22:45:56 +0800 |
commit | c3e020ca3404cc07e78e13e975eb7e712670e137 (patch) | |
tree | 34a4c85222fbb050e18f15fd89c34699ed161931 /routers | |
parent | 257b7171c34446e73fc83186f859e9b9ce67be76 (diff) | |
download | gitea-c3e020ca3404cc07e78e13e975eb7e712670e137.tar.gz gitea-c3e020ca3404cc07e78e13e975eb7e712670e137.zip |
Add pagination to fork list (#17639)
- Resolves #14574
- Adds the necessary code to have pagination working in the forks list of
a repo. The code is mostly in par with the stars/watcher implementation.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/view.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index d455dc1039..72726f0545 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -935,8 +935,18 @@ func Stars(ctx *context.Context) { func Forks(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repos.forks") - // TODO: need pagination - forks, err := ctx.Repo.Repository.GetForks(db.ListOptions{}) + page := ctx.FormInt("page") + if page <= 0 { + page = 1 + } + + pager := context.NewPagination(ctx.Repo.Repository.NumForks, models.ItemsPerPage, page, 5) + ctx.Data["Page"] = pager + + forks, err := ctx.Repo.Repository.GetForks(db.ListOptions{ + Page: pager.Paginater.Current(), + PageSize: models.ItemsPerPage, + }) if err != nil { ctx.ServerError("GetForks", err) return @@ -948,6 +958,7 @@ func Forks(ctx *context.Context) { return } } + ctx.Data["Forks"] = forks ctx.HTML(http.StatusOK, tplForks) |