diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-02-07 19:54:16 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-07 19:54:16 +0800 |
commit | b13232f52454b72c414e8bf686daccee712346e1 (patch) | |
tree | d83cba64b231aa17853cf9c135760847cb5b072f /routers/user | |
parent | ceae143e78dabe9c5ef6bafff739aa487f79ca70 (diff) | |
download | gitea-b13232f52454b72c414e8bf686daccee712346e1.tar.gz gitea-b13232f52454b72c414e8bf686daccee712346e1.zip |
feat: support paginater on star tab of user profile. (#845)
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/profile.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/routers/user/profile.go b/routers/user/profile.go index ef6cb9cd9d..1f5acbec0d 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -97,12 +97,27 @@ func Profile(ctx *context.Context) { return } case "stars": - starredRepos, err := ctxUser.GetStarredRepos(showPrivate) + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + + repos, err := ctxUser.GetStarredRepos(showPrivate, page, setting.UI.User.RepoPagingNum, "") if err != nil { ctx.Handle(500, "GetStarredRepos", err) return } - ctx.Data["Repos"] = starredRepos + + counts, err := ctxUser.GetStarredRepoCount(showPrivate) + if err != nil { + ctx.Handle(500, "GetStarredRepoCount", err) + return + } + + ctx.Data["Repos"] = repos + ctx.Data["Page"] = paginater.New(int(counts), setting.UI.User.RepoPagingNum, page, 5) + ctx.Data["Total"] = int(counts) + ctx.Data["Tabs"] = "stars" default: page := ctx.QueryInt("page") if page <= 0 { |