Added user lists by country

This commit is contained in:
Eduard Urbach 2018-11-06 20:20:19 +09:00
parent 57297c7de2
commit de8fec3114
5 changed files with 30 additions and 18 deletions

View File

@ -17,4 +17,5 @@ func Register(l *layout.Layout) {
l.Page("/users/staff", users.Staff)
l.Page("/users/pro", users.Pro)
l.Page("/users/editors", users.Editors)
l.Page("/users/country/:country", users.ByCountry)
}

View File

@ -70,7 +70,7 @@ component ProfileHead(viewUser *arn.User, user *arn.User, uri string)
span= viewUser.AgeInYears()
if user != nil && viewUser.Settings().Privacy.ShowLocation && viewUser.Location.CountryName != ""
.profile-tag.mountable.never-unmount(data-mountable-type="header")
a.profile-tag.mountable.never-unmount(href="/users/country/" + strings.ToLower(viewUser.Location.CountryName), data-mountable-type="header")
Icon("map-marker")
span= viewUser.Location.CountryName

View File

@ -2,6 +2,7 @@ package users
import (
"sort"
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
@ -15,23 +16,7 @@ func Active(ctx *aero.Context) string {
return user.HasAvatar() && user.HasNick() && user.IsActive()
})
followCount := arn.UserFollowerCountMap()
sort.Slice(users, func(i, j int) bool {
if users[i].HasAvatar() != users[j].HasAvatar() {
return users[i].HasAvatar()
}
followersA := followCount[users[i].ID]
followersB := followCount[users[j].ID]
if followersA == followersB {
return users[i].Nick < users[j].Nick
}
return followersA > followersB
})
arn.SortUsersFollowers(users)
return ctx.HTML(components.Users(users, ctx.URI()))
}
@ -171,6 +156,18 @@ func FFXIV(ctx *aero.Context) string {
return ctx.HTML(components.FinalFantasyXIVRankingList(users, ctx.URI()))
}
// ByCountry ...
func ByCountry(ctx *aero.Context) string {
countryName := ctx.Get("country")
users := arn.FilterUsers(func(user *arn.User) bool {
return strings.ToLower(user.Location.CountryName) == countryName && user.Settings().Privacy.ShowLocation && user.HasAvatar() && user.HasNick() && user.IsActive()
})
arn.SortUsersFollowers(users)
return ctx.HTML(components.UsersByCountry(users, countryName))
}
// Staff ...
func Staff(ctx *aero.Context) string {
users := arn.FilterUsers(func(user *arn.User) bool {

View File

@ -6,6 +6,16 @@ component Users(users []*arn.User, url string)
each user in users
Avatar(user)
component UsersByCountry(users []*arn.User, countryName string)
if len(users) == 0
p.no-data.mountable= "Seems like there are no users in " + stringutils.Capitalize(countryName)
else
h1= "Users in " + users[0].Location.CountryName
.user-avatars.mountable
each user in users
Avatar(user)
component ProUsers(users []*arn.User, url string)
h1.page-title Supporters
UsersTabs(url)

View File

@ -106,6 +106,10 @@ var routeTests = map[string][]string{
"/+Akyoto/recommended/anime",
},
"/users/country/:country": []string{
"/users/country/japan",
},
// Pages
"/anime/:id": []string{
"/anime/74y2cFiiR",