summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorMario Lubenka <mario.lubenka@googlemail.com>2019-04-20 06:15:19 +0200
committertechknowlogick <matti@mdranta.net>2019-04-20 00:15:19 -0400
commitfcbac38d6fd8c91be0da5e7f37e7bc69b071253a (patch)
treecdf7c901df75d0d2f26567d1090ed0e3c1af138d /routers/user
parent40dc458bb69f9827e804e2fe51c9f42caf3d3ddc (diff)
downloadgitea-fcbac38d6fd8c91be0da5e7f37e7bc69b071253a.tar.gz
gitea-fcbac38d6fd8c91be0da5e7f37e7bc69b071253a.zip
Unifies pagination template usage (#6531) (#6533)
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/home.go17
-rw-r--r--routers/user/notification.go12
-rw-r--r--routers/user/profile.go22
3 files changed, 32 insertions, 19 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index 8eedeb70bd..79377ac500 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/modules/util"
"github.com/Unknwon/com"
- "github.com/Unknwon/paginater"
"github.com/keybase/go-crypto/openpgp"
"github.com/keybase/go-crypto/openpgp/armor"
)
@@ -354,7 +353,6 @@ func Issues(ctx *context.Context) {
ctx.Data["CommitStatus"] = commitStatus
ctx.Data["Repos"] = showRepos
ctx.Data["Counts"] = counts
- ctx.Data["Page"] = paginater.New(total, setting.UI.IssuePagingNum, page, 5)
ctx.Data["IssueStats"] = issueStats
ctx.Data["ViewType"] = viewType
ctx.Data["SortType"] = sortType
@@ -367,6 +365,16 @@ func Issues(ctx *context.Context) {
ctx.Data["State"] = "open"
}
+ pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5)
+ pager.AddParam(ctx, "type", "ViewType")
+ pager.AddParam(ctx, "repo", "RepoID")
+ pager.AddParam(ctx, "sort", "SortType")
+ pager.AddParam(ctx, "state", "State")
+ pager.AddParam(ctx, "labels", "SelectLabels")
+ pager.AddParam(ctx, "milestone", "MilestoneID")
+ pager.AddParam(ctx, "assignee", "AssigneeID")
+ ctx.Data["Page"] = pager
+
ctx.HTML(200, tplIssues)
}
@@ -534,10 +542,13 @@ func showOrgProfile(ctx *context.Context) {
ctx.Data["Repos"] = repos
ctx.Data["Total"] = count
- ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
ctx.Data["Members"] = org.Members
ctx.Data["Teams"] = org.Teams
+ pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
+ pager.SetDefaultParams(ctx)
+ ctx.Data["Page"] = pager
+
ctx.HTML(200, tplOrgHome)
}
diff --git a/routers/user/notification.go b/routers/user/notification.go
index 32cacdd2c4..8c23d76fa9 100644
--- a/routers/user/notification.go
+++ b/routers/user/notification.go
@@ -1,3 +1,7 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
package user
import (
@@ -6,8 +10,6 @@ import (
"strconv"
"strings"
- "github.com/Unknwon/paginater"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
@@ -80,7 +82,11 @@ func Notifications(c *context.Context) {
c.Data["Keyword"] = keyword
c.Data["Status"] = status
c.Data["Notifications"] = notifications
- c.Data["Page"] = paginater.New(int(total), perPage, page, 5)
+
+ pager := context.NewPagination(int(total), perPage, page, 5)
+ pager.SetDefaultParams(c)
+ c.Data["Page"] = pager
+
c.HTML(200, tplNotification)
}
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 675c1dc3f4..a7dab18c7a 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -10,8 +10,6 @@ import (
"path"
"strings"
- "github.com/Unknwon/paginater"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
@@ -127,6 +125,7 @@ func Profile(ctx *context.Context) {
var (
repos []*models.Repository
count int64
+ total int
orderBy models.SearchOrderBy
)
@@ -201,18 +200,14 @@ func Profile(ctx *context.Context) {
}
}
- ctx.Data["Repos"] = repos
- ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
- ctx.Data["Total"] = count
+ total = int(count)
default:
if len(keyword) == 0 {
- var total int
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy.String())
if err != nil {
ctx.ServerError("GetRepositories", err)
return
}
- ctx.Data["Repos"] = repos
if showPrivate {
total = ctxUser.NumRepos
@@ -224,9 +219,6 @@ func Profile(ctx *context.Context) {
}
total = int(count)
}
-
- ctx.Data["Page"] = paginater.New(total, setting.UI.User.RepoPagingNum, page, 5)
- ctx.Data["Total"] = total
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,
@@ -244,11 +236,15 @@ func Profile(ctx *context.Context) {
return
}
- ctx.Data["Repos"] = repos
- ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
- ctx.Data["Total"] = count
+ total = int(count)
}
}
+ ctx.Data["Repos"] = repos
+ ctx.Data["Total"] = total
+
+ pager := context.NewPagination(total, setting.UI.User.RepoPagingNum, page, 5)
+ pager.SetDefaultParams(ctx)
+ ctx.Data["Page"] = pager
ctx.Data["ShowUserEmail"] = len(ctxUser.Email) > 0 && ctx.IsSigned && (!ctxUser.KeepEmailPrivate || ctxUser.ID == ctx.User.ID)