diff options
Diffstat (limited to 'routers/user/profile.go')
-rw-r--r-- | routers/user/profile.go | 22 |
1 files changed, 9 insertions, 13 deletions
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) |