mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-27 04:07:08 +00:00
#1384 add pagination for repositories
This commit is contained in:
parent
1f2e173a74
commit
e74630ae3b
21 changed files with 360 additions and 192 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue