diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-11-04 20:28:07 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-11-07 11:41:09 +0100 |
commit | 86fb1a0cb13de00a5ba49e29efa35573c01c9821 (patch) | |
tree | 3829d2b628ca20959c4e2bfb8b92ed5ee0aec923 /routers/repo/release.go | |
parent | be5607e510f410ac82247c3b4b8a4bc6504e7cee (diff) | |
download | gitea-86fb1a0cb13de00a5ba49e29efa35573c01c9821.tar.gz gitea-86fb1a0cb13de00a5ba49e29efa35573c01c9821.zip |
Add Pagination to Releases-page
Diffstat (limited to 'routers/repo/release.go')
-rw-r--r-- | routers/repo/release.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/repo/release.go b/routers/repo/release.go index 9d87f0967e..afdc61a22a 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -7,6 +7,7 @@ package repo import ( "fmt" + "github.com/Unknwon/paginater" "github.com/go-gitea/gitea/models" "github.com/go-gitea/gitea/modules/auth" "github.com/go-gitea/gitea/modules/base" @@ -58,7 +59,11 @@ func Releases(ctx *context.Context) { return } - releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID) + page := ctx.QueryInt("page") + if page <= 1 { + page = 1 + } + releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, page, 10) if err != nil { ctx.Handle(500, "GetReleasesByRepoID", err) return @@ -141,6 +146,8 @@ func Releases(ctx *context.Context) { r.Note = markdown.RenderString(r.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()) tags = append(tags, r) } + pager := paginater.New(ctx.Repo.Repository.NumTags, 10, page, 5) + ctx.Data["Page"] = pager models.SortReleases(tags) ctx.Data["Releases"] = tags ctx.HTML(200, RELEASES) |