diff --git a/routers/routes/routes.go b/routers/routes/routes.go index a06eb46ad1..ff9e0da220 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -490,12 +490,7 @@ func RegisterRoutes(m *macaron.Macaron) { // ***** END: Admin ***** m.Group("", func() { - m.Group("/:username", func() { - m.Get("", user.Profile) - m.Get("/followers", user.Followers) - m.Get("/following", user.Following) - }) - + m.Get("/:username", user.Profile) m.Get("/attachments/:uuid", repo.GetAttachment) }, ignSignIn) diff --git a/routers/user/profile.go b/routers/user/profile.go index 808ce382c7..a151884d76 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -11,16 +11,10 @@ import ( "strings" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/org" - "code.gitea.io/gitea/routers/repo" -) - -const ( - tplFollowers base.TplName = "user/meta/followers" ) // GetUserByName get user by name @@ -159,6 +153,30 @@ func Profile(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") ctx.Data["Keyword"] = keyword switch tab { + case "followers": + items, err := ctxUser.GetFollowers(models.ListOptions{ + PageSize: setting.UI.User.RepoPagingNum, + Page: page, + }) + if err != nil { + ctx.ServerError("GetFollowers", err) + return + } + ctx.Data["Cards"] = items + + total = ctxUser.NumFollowers + case "following": + items, err := ctxUser.GetFollowing(models.ListOptions{ + PageSize: setting.UI.User.RepoPagingNum, + Page: page, + }) + if err != nil { + ctx.ServerError("GetFollowing", err) + return + } + ctx.Data["Cards"] = items + + total = ctxUser.NumFollowing case "activity": retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser, Actor: ctx.User, @@ -226,32 +244,6 @@ func Profile(ctx *context.Context) { ctx.HTML(200, tplProfile) } -// Followers render user's followers page -func Followers(ctx *context.Context) { - u := GetUserByParams(ctx) - if ctx.Written() { - return - } - ctx.Data["Title"] = u.DisplayName() - ctx.Data["CardsTitle"] = ctx.Tr("user.followers") - ctx.Data["PageIsFollowers"] = true - ctx.Data["Owner"] = u - repo.RenderUserCards(ctx, u.NumFollowers, u.GetFollowers, tplFollowers) -} - -// Following render user's followering page -func Following(ctx *context.Context) { - u := GetUserByParams(ctx) - if ctx.Written() { - return - } - ctx.Data["Title"] = u.DisplayName() - ctx.Data["CardsTitle"] = ctx.Tr("user.following") - ctx.Data["PageIsFollowing"] = true - ctx.Data["Owner"] = u - repo.RenderUserCards(ctx, u.NumFollowing, u.GetFollowing, tplFollowers) -} - // Action response for follow/unfollow user request func Action(ctx *context.Context) { u := GetUserByParams(ctx) diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl index 3677bab635..cd7f15a710 100644 --- a/templates/repo/user_cards.tmpl +++ b/templates/repo/user_cards.tmpl @@ -1,7 +1,9 @@