mirror of https://github.com/go-gitea/gitea.git
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.
This commit is contained in:
parent
257b7171c3
commit
c3e020ca34
|
@ -935,8 +935,18 @@ func Stars(ctx *context.Context) {
|
||||||
func Forks(ctx *context.Context) {
|
func Forks(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repos.forks")
|
ctx.Data["Title"] = ctx.Tr("repos.forks")
|
||||||
|
|
||||||
// TODO: need pagination
|
page := ctx.FormInt("page")
|
||||||
forks, err := ctx.Repo.Repository.GetForks(db.ListOptions{})
|
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 {
|
if err != nil {
|
||||||
ctx.ServerError("GetForks", err)
|
ctx.ServerError("GetForks", err)
|
||||||
return
|
return
|
||||||
|
@ -948,6 +958,7 @@ func Forks(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Forks"] = forks
|
ctx.Data["Forks"] = forks
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplForks)
|
ctx.HTML(http.StatusOK, tplForks)
|
||||||
|
|
|
@ -18,5 +18,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ template "base/paginate" . }}
|
||||||
</div>
|
</div>
|
||||||
{{template "base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
Loading…
Reference in New Issue