diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 08cc52e0e0c..9d59ade3a38 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -475,12 +475,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 fd29a176229..b54a68db70f 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 @@ -164,6 +158,24 @@ func Profile(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") ctx.Data["Keyword"] = keyword switch tab { + case "followers": + items, err := ctxUser.GetFollowers(page) + if err != nil { + ctx.ServerError("GetFollowers", err) + return + } + ctx.Data["Cards"] = items + + total = ctxUser.NumFollowers + case "following": + items, err := ctxUser.GetFollowing(page) + if err != nil { + ctx.ServerError("GetFollowing", err) + return + } + ctx.Data["Cards"] = items + + total = ctxUser.NumFollowing case "activity": retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser, RequestingUserID: requestingUserID, @@ -229,32 +241,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 3677bab6357..cd7f15a710f 100644 --- a/templates/repo/user_cards.tmpl +++ b/templates/repo/user_cards.tmpl @@ -1,7 +1,9 @@
+ {{if .CardsTitle}}

{{.CardsTitle}}

+ {{end}}
@@ -126,6 +117,10 @@ {{template "explore/repo_list" .}} {{template "base/paginate" .}}
+ {{else if eq .TabName "following"}} + {{template "repo/user_cards" .}} + {{else if eq .TabName "followers"}} + {{template "repo/user_cards" .}} {{else}} {{template "explore/repo_search" .}} {{template "explore/repo_list" .}}