loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

authored by

Gusted and committed by
GitHub
c3e020ca 257b7171

+15 -2
+13 -2
routers/web/repo/view.go
··· 935 935 func Forks(ctx *context.Context) { 936 936 ctx.Data["Title"] = ctx.Tr("repos.forks") 937 937 938 - // TODO: need pagination 939 - forks, err := ctx.Repo.Repository.GetForks(db.ListOptions{}) 938 + page := ctx.FormInt("page") 939 + if page <= 0 { 940 + page = 1 941 + } 942 + 943 + pager := context.NewPagination(ctx.Repo.Repository.NumForks, models.ItemsPerPage, page, 5) 944 + ctx.Data["Page"] = pager 945 + 946 + forks, err := ctx.Repo.Repository.GetForks(db.ListOptions{ 947 + Page: pager.Paginater.Current(), 948 + PageSize: models.ItemsPerPage, 949 + }) 940 950 if err != nil { 941 951 ctx.ServerError("GetForks", err) 942 952 return ··· 948 958 return 949 959 } 950 960 } 961 + 951 962 ctx.Data["Forks"] = forks 952 963 953 964 ctx.HTML(http.StatusOK, tplForks)
+2
templates/repo/forks.tmpl
··· 18 18 {{end}} 19 19 </div> 20 20 </div> 21 + 22 + {{ template "base/paginate" . }} 21 23 </div> 22 24 {{template "base/footer" .}}