|
|
@ -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) |
|
|
|