mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-17 19:46:18 +00:00
Fix followers and following tabs in profile (#10202)
This commit is contained in:
parent
e273817154
commit
fe00886bef
|
@ -490,12 +490,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
// ***** END: Admin *****
|
// ***** END: Admin *****
|
||||||
|
|
||||||
m.Group("", func() {
|
m.Group("", func() {
|
||||||
m.Group("/:username", func() {
|
m.Get("/:username", user.Profile)
|
||||||
m.Get("", user.Profile)
|
|
||||||
m.Get("/followers", user.Followers)
|
|
||||||
m.Get("/following", user.Following)
|
|
||||||
})
|
|
||||||
|
|
||||||
m.Get("/attachments/:uuid", repo.GetAttachment)
|
m.Get("/attachments/:uuid", repo.GetAttachment)
|
||||||
}, ignSignIn)
|
}, ignSignIn)
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/base"
|
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
"code.gitea.io/gitea/routers/org"
|
"code.gitea.io/gitea/routers/org"
|
||||||
"code.gitea.io/gitea/routers/repo"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
tplFollowers base.TplName = "user/meta/followers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetUserByName get user by name
|
// GetUserByName get user by name
|
||||||
|
@ -159,6 +153,30 @@ func Profile(ctx *context.Context) {
|
||||||
keyword := strings.Trim(ctx.Query("q"), " ")
|
keyword := strings.Trim(ctx.Query("q"), " ")
|
||||||
ctx.Data["Keyword"] = keyword
|
ctx.Data["Keyword"] = keyword
|
||||||
switch tab {
|
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":
|
case "activity":
|
||||||
retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser,
|
retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser,
|
||||||
Actor: ctx.User,
|
Actor: ctx.User,
|
||||||
|
@ -226,32 +244,6 @@ func Profile(ctx *context.Context) {
|
||||||
ctx.HTML(200, tplProfile)
|
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
|
// Action response for follow/unfollow user request
|
||||||
func Action(ctx *context.Context) {
|
func Action(ctx *context.Context) {
|
||||||
u := GetUserByParams(ctx)
|
u := GetUserByParams(ctx)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<div class="ui container user-cards">
|
<div class="ui container user-cards">
|
||||||
|
{{if .CardsTitle}}
|
||||||
<h2 class="ui dividing header">
|
<h2 class="ui dividing header">
|
||||||
{{.CardsTitle}}
|
{{.CardsTitle}}
|
||||||
</h2>
|
</h2>
|
||||||
|
{{end}}
|
||||||
<ul class="list">
|
<ul class="list">
|
||||||
{{range .Cards}}
|
{{range .Cards}}
|
||||||
<li class="item ui segment">
|
<li class="item ui segment">
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{template "base/head" .}}
|
|
||||||
<div class="user followers">
|
|
||||||
{{template "user/meta/header" .}}
|
|
||||||
{{template "repo/user_cards" .}}
|
|
||||||
</div>
|
|
||||||
{{template "base/footer" .}}
|
|
|
@ -1,24 +0,0 @@
|
||||||
{{with .Owner}}
|
|
||||||
<div class="ui container">
|
|
||||||
<img class="ui avatar image" src="{{.RelAvatarLink}}">
|
|
||||||
<span class="header name">
|
|
||||||
<a href="{{.HomeLink}}">{{.Name}}</a>
|
|
||||||
{{with .FullName}}({{.}}){{end}}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div class="ui right">
|
|
||||||
{{if or $.PageIsFollowers $.PageIsFollowing}}
|
|
||||||
{{if and $.IsSigned (ne $.SignedUserName .Name)}}
|
|
||||||
<div class="follow">
|
|
||||||
{{if $.SignedUser.IsFollowing .ID}}
|
|
||||||
<a class="ui small basic red button" href="{{.HomeLink}}/action/unfollow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{$.i18n.Tr "user.unfollow"}}</a>
|
|
||||||
{{else}}
|
|
||||||
<a class="ui small basic green button" href="{{.HomeLink}}/action/follow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{$.i18n.Tr "user.follow"}}</a>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
<div class="ui divider"></div>
|
|
|
@ -49,24 +49,6 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<li><i class="octicon octicon-clock"></i> {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}}</li>
|
<li><i class="octicon octicon-clock"></i> {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}}</li>
|
||||||
<li>
|
|
||||||
<i class="octicon octicon-person"></i>
|
|
||||||
<a href="{{.Owner.HomeLink}}/followers">
|
|
||||||
{{.Owner.NumFollowers}} {{.i18n.Tr "user.followers"}}
|
|
||||||
</a>
|
|
||||||
-
|
|
||||||
<a href="{{.Owner.HomeLink}}/following">
|
|
||||||
{{.Owner.NumFollowing}} {{.i18n.Tr "user.following"}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{/*
|
|
||||||
<li>
|
|
||||||
<i class="octicon octicon-star"></i>
|
|
||||||
<a href="{{.Owner.HomeLink}}/stars">
|
|
||||||
{{.Owner.NumStars}} {{.i18n.Tr "user.starred"}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
*/}}
|
|
||||||
{{if and .Orgs .HasOrgsVisible}}
|
{{if and .Orgs .HasOrgsVisible}}
|
||||||
<li>
|
<li>
|
||||||
<ul class="user-orgs">
|
<ul class="user-orgs">
|
||||||
|
@ -95,7 +77,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="ui eleven wide column">
|
<div class="ui eleven wide column">
|
||||||
<div class="ui secondary stackable pointing menu">
|
<div class="ui secondary stackable pointing menu">
|
||||||
<a class='{{if and (ne .TabName "activity") (ne .TabName "stars")}}active{{end}} item' href="{{.Owner.HomeLink}}">
|
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars")}}active{{end}} item' href="{{.Owner.HomeLink}}">
|
||||||
<i class="octicon octicon-repo"></i> {{.i18n.Tr "user.repositories"}}
|
<i class="octicon octicon-repo"></i> {{.i18n.Tr "user.repositories"}}
|
||||||
</a>
|
</a>
|
||||||
<a class='{{if eq .TabName "activity"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=activity">
|
<a class='{{if eq .TabName "activity"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=activity">
|
||||||
|
@ -103,6 +85,15 @@
|
||||||
</a>
|
</a>
|
||||||
<a class='{{if eq .TabName "stars"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=stars">
|
<a class='{{if eq .TabName "stars"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=stars">
|
||||||
<i class="octicon octicon-star"></i> {{.i18n.Tr "user.starred"}}
|
<i class="octicon octicon-star"></i> {{.i18n.Tr "user.starred"}}
|
||||||
|
<div class="ui label">{{.Owner.NumStars}}</div>
|
||||||
|
</a>
|
||||||
|
<a class='{{if eq .TabName "following"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=following">
|
||||||
|
<i class="octicon octicon-person"></i> {{.i18n.Tr "user.following"}}
|
||||||
|
<div class="ui label">{{.Owner.NumFollowing}}</div>
|
||||||
|
</a>
|
||||||
|
<a class='{{if eq .TabName "followers"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=followers">
|
||||||
|
<i class="octicon octicon-person"></i> {{.i18n.Tr "user.followers"}}
|
||||||
|
<div class="ui label">{{.Owner.NumFollowers}}</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -126,6 +117,10 @@
|
||||||
{{template "explore/repo_list" .}}
|
{{template "explore/repo_list" .}}
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
</div>
|
</div>
|
||||||
|
{{else if eq .TabName "following"}}
|
||||||
|
{{template "repo/user_cards" .}}
|
||||||
|
{{else if eq .TabName "followers"}}
|
||||||
|
{{template "repo/user_cards" .}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{template "explore/repo_search" .}}
|
{{template "explore/repo_search" .}}
|
||||||
{{template "explore/repo_list" .}}
|
{{template "explore/repo_list" .}}
|
||||||
|
|
Loading…
Reference in a new issue