diff options
Diffstat (limited to 'routers/user/profile.go')
-rw-r--r-- | routers/user/profile.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/routers/user/profile.go b/routers/user/profile.go index 0e436eac41..363705dd01 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -9,6 +9,8 @@ import ( "path" "strings" + "github.com/Unknwon/paginater" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" @@ -55,27 +57,27 @@ func Profile(ctx *context.Context) { isShowKeys = true } - u := GetUserByName(ctx, strings.TrimSuffix(uname, ".keys")) + ctxUser := GetUserByName(ctx, strings.TrimSuffix(uname, ".keys")) if ctx.Written() { return } // Show SSH keys. if isShowKeys { - ShowSSHKeys(ctx, u.ID) + ShowSSHKeys(ctx, ctxUser.ID) return } - if u.IsOrganization() { + if ctxUser.IsOrganization() { showOrgProfile(ctx) return } - ctx.Data["Title"] = u.DisplayName() + ctx.Data["Title"] = ctxUser.DisplayName() ctx.Data["PageIsUserProfile"] = true - ctx.Data["Owner"] = u + ctx.Data["Owner"] = ctxUser - orgs, err := models.GetOrgsByUserID(u.ID, ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == u.ID)) + orgs, err := models.GetOrgsByUserID(ctxUser.ID, ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID)) if err != nil { ctx.Handle(500, "GetOrgsByUserIDDesc", err) return @@ -87,17 +89,22 @@ func Profile(ctx *context.Context) { ctx.Data["TabName"] = tab switch tab { case "activity": - retrieveFeeds(ctx, u.ID, -1, 0, true) + retrieveFeeds(ctx, ctxUser, -1, 0, true) if ctx.Written() { return } default: - var err error - ctx.Data["Repos"], err = models.GetRepositories(u.ID, ctx.IsSigned && ctx.User.ID == u.ID) + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + + ctx.Data["Repos"], err = models.GetUserRepositories(ctxUser.ID, ctx.IsSigned && ctx.User.ID == ctxUser.ID, page, setting.UI.User.RepoPagingNum) if err != nil { ctx.Handle(500, "GetRepositories", err) return } + ctx.Data["Page"] = paginater.New(ctxUser.NumRepos, setting.UI.User.RepoPagingNum, page, 5) } ctx.HTML(200, PROFILE) |