diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-11-08 10:39:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-08 10:39:03 +0800 |
commit | 5667d4daae2df8c648d3c30cd7f6aadd5cb0e698 (patch) | |
tree | 24b739896a721abb794a9a9bc0a97ea16c25ed79 /routers/repo | |
parent | 864d1b1f9f6a72589d77ec0f08b21c476b8e13d4 (diff) | |
parent | 562f9b6eae72e3f952a2ce1e74249bcd44e69272 (diff) | |
download | gitea-5667d4daae2df8c648d3c30cd7f6aadd5cb0e698.tar.gz gitea-5667d4daae2df8c648d3c30cd7f6aadd5cb0e698.zip |
Merge pull request #73 from bkcsoft/gt/2164-release-pagination
Add Pagination to Releases-page (and de-duplicate pagination templates)
Diffstat (limited to 'routers/repo')
-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) |