Followers

This commit is contained in:
Eduard Urbach 2017-07-21 11:01:34 +02:00
parent f9fa926644
commit c0e324cefd
4 changed files with 46 additions and 0 deletions

View File

@ -97,6 +97,7 @@ func configure(app *aero.Application) *aero.Application {
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
app.Ajax("/user/:nick/soundtracks", profile.GetSoundTracksByUser)
app.Ajax("/user/:nick/stats", profile.GetStatsByUser)
app.Ajax("/user/:nick/followers", profile.GetFollowers)
app.Ajax("/user/:nick/animelist", animelist.Get)
app.Ajax("/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching))
app.Ajax("/user/:nick/animelist/completed", animelist.FilterByStatus(arn.AnimeListStatusCompleted))

View File

@ -0,0 +1,30 @@
package profile
import (
"net/http"
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// GetFollowers shows the followers of a particular user.
func GetFollowers(ctx *aero.Context) string {
nick := ctx.Get("nick")
viewUser, err := arn.GetUserByNick(nick)
if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err)
}
followers := viewUser.Followers()
sort.Slice(followers, func(i, j int) bool {
return followers[i].LastSeen > followers[j].LastSeen
})
return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI()))
}

View File

@ -0,0 +1,11 @@
component ProfileFollowers(followers []*arn.User, viewUser *arn.User, user *arn.User, uri string)
ProfileHeader(viewUser, user, uri)
if len(followers) > 0
.user-avatars
each user in followers
if user.Nick != ""
.mountable
Avatar(user)
else
p.no-data.mountable= viewUser.Nick + " doesn't have a follower yet."

View File

@ -88,6 +88,10 @@ component ProfileNavigation(viewUser *arn.User, uri string)
a.button.tab.action(href="/+" + viewUser.Nick + "/stats", data-action="diff", data-trigger="click")
Icon("area-chart")
span.tab-text Stats
a.button.tab.action(href="/+" + viewUser.Nick + "/followers", data-action="diff", data-trigger="click")
Icon("users")
span.tab-text Followers
if strings.Contains(uri, "/animelist")
hr