From 589618c8a53f11395fca3465d8ad936ad46caaf0 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 28 Jul 2015 03:14:37 +0800 Subject: better paging --- routers/repo/issue.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'routers') diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 79f8e363..6adf9649 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -15,6 +15,7 @@ import ( "time" "github.com/Unknwon/com" + "github.com/Unknwon/paginater" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" @@ -100,13 +101,15 @@ func Issues(ctx *middleware.Context) { page := ctx.QueryInt("page") if page <= 1 { page = 1 - } else { - ctx.Data["PreviousPage"] = page - 1 } - if (!isShowClosed && int(issueStats.OpenCount) > setting.IssuePagingNum*page) || - (isShowClosed && int(issueStats.ClosedCount) > setting.IssuePagingNum*page) { - ctx.Data["NextPage"] = page + 1 + + var total int + if !isShowClosed { + total = int(issueStats.OpenCount) + } else { + total = int(issueStats.ClosedCount) } + ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5) // Get issues. issues, err := models.GetIssues(uid, assigneeID, repo.Id, posterID, milestoneID, -- cgit v1.2.3