diff --git a/pages/editor/editor.go b/pages/editor/editor.go index d0731aeb..1db2d741 100644 --- a/pages/editor/editor.go +++ b/pages/editor/editor.go @@ -2,7 +2,6 @@ package editor import ( "github.com/aerogo/aero" - "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/utils" ) @@ -15,35 +14,5 @@ func Get(ctx *aero.Context) string { return ctx.Redirect("/") } - ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool { - return entry.CreatedBy == user.ID - }) - - logEntries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool { - return entry.UserID == user.ID - }) - - score := len(ignoreDifferences) - - for _, entry := range logEntries { - switch entry.Action { - case "create": - score += 10 - - case "edit": - score += 2 - - if entry.ObjectType == "Anime" && (entry.Key == "Summary" || entry.Key == "Synopsis") { - score += 2 - } - - case "delete", "arrayRemove": - score++ - - case "arrayAppend": - // No score - } - } - - return ctx.HTML(components.Editor(ctx.URI(), score, user)) + return ctx.HTML(components.Editor(ctx.URI(), user.EditorScore(), user)) } diff --git a/pages/index.go b/pages/index.go index 1bbd897f..25042c9b 100644 --- a/pages/index.go +++ b/pages/index.go @@ -88,9 +88,11 @@ func Configure(app *aero.Application) { // User lists l.Page("/users", users.Active) l.Page("/users/noavatar", users.ActiveNoAvatar) - l.Page("/users/osu", users.Osu) - l.Page("/users/overwatch", users.Overwatch) + l.Page("/users/games/osu", users.Osu) + l.Page("/users/games/overwatch", users.Overwatch) l.Page("/users/staff", users.Staff) + l.Page("/users/pro", users.Pro) + l.Page("/users/editors", users.Editors) // Statistics l.Page("/statistics", statistics.Get) diff --git a/pages/profile/profile.scarlet b/pages/profile/profile.scarlet index 0ec70900..13eff343 100644 --- a/pages/profile/profile.scarlet +++ b/pages/profile/profile.scarlet @@ -114,7 +114,7 @@ profile-boot-duration = 2s .profile-image object-fit cover width 100% - height auto + height 100% .profile-image-container flex 1 diff --git a/pages/users/editors.pixy b/pages/users/editors.pixy new file mode 100644 index 00000000..499d7b4a --- /dev/null +++ b/pages/users/editors.pixy @@ -0,0 +1,21 @@ +component EditorRankingList(users []*arn.User, url string) + h1.page-title Editor ranking list + UsersTabs(url) + + table.ranking-list + thead + tr.mountable + th # + th User + th.ranking-score Score + tbody + for index, user := range users + tr.ranking.mountable + td= toString(index + 1) + "." + td.ranking-user + Avatar(user) + a.ajax(href=user.Link())= user.Nick + td.ranking-score= user.EditorScore() + + .footer.mountable + p Score is generated from new data submissions and data fixes. \ No newline at end of file diff --git a/pages/users/osu.pixy b/pages/users/osu.pixy index 05d4efd1..933eb6d9 100644 --- a/pages/users/osu.pixy +++ b/pages/users/osu.pixy @@ -1,7 +1,6 @@ -component OsuRankingList(users []*arn.User) +component OsuRankingList(users []*arn.User, url string) h1.page-title osu! ranking list - - UsersTabs + UsersTabs(url) table.ranking-list thead diff --git a/pages/users/overwatch.pixy b/pages/users/overwatch.pixy index 007b2b61..9aafaf6e 100644 --- a/pages/users/overwatch.pixy +++ b/pages/users/overwatch.pixy @@ -1,7 +1,6 @@ -component OverwatchRankingList(users []*arn.User) +component OverwatchRankingList(users []*arn.User, url string) h1.page-title Overwatch ranking list - - UsersTabs + UsersTabs(url) table.ranking-list thead diff --git a/pages/users/users.go b/pages/users/users.go index ff7ce9ab..2cae9c83 100644 --- a/pages/users/users.go +++ b/pages/users/users.go @@ -36,7 +36,55 @@ func Active(ctx *aero.Context) string { return followersA > followersB }) - return ctx.HTML(components.Users(users)) + return ctx.HTML(components.Users(users, ctx.URI())) +} + +// Pro ... +func Pro(ctx *aero.Context) string { + users := arn.FilterUsers(func(user *arn.User) bool { + return user.IsPro() + }) + + sort.Slice(users, func(i, j int) bool { + return users[i].Registered > users[j].Registered + }) + + return ctx.HTML(components.ProUsers(users, ctx.URI())) +} + +// Editors ... +func Editors(ctx *aero.Context) string { + score := map[string]int{} + users := []*arn.User{} + + for entry := range arn.StreamEditLogEntries() { + entryScore := entry.EditorScore() + + if entryScore == 0 { + continue + } + + current, exists := score[entry.UserID] + + if !exists { + users = append(users, entry.User()) + } + + score[entry.UserID] = current + entryScore + } + + sort.Slice(users, func(i, j int) bool { + scoreA := score[users[i].ID] + scoreB := score[users[j].ID] + + if scoreA == scoreB { + return users[i].Registered > users[j].Registered + } + + return scoreA > scoreB + }) + + return ctx.HTML(components.EditorRankingList(users, ctx.URI())) } // ActiveNoAvatar ... @@ -66,7 +114,7 @@ func ActiveNoAvatar(ctx *aero.Context) string { return followersA > followersB }) - return ctx.HTML(components.Users(users)) + return ctx.HTML(components.Users(users, ctx.URI())) } // Osu ... @@ -84,7 +132,7 @@ func Osu(ctx *aero.Context) string { users = users[:50] } - return ctx.HTML(components.OsuRankingList(users)) + return ctx.HTML(components.OsuRankingList(users, ctx.URI())) } // Overwatch ... @@ -102,7 +150,7 @@ func Overwatch(ctx *aero.Context) string { users = users[:50] } - return ctx.HTML(components.OverwatchRankingList(users)) + return ctx.HTML(components.OverwatchRankingList(users, ctx.URI())) } // Staff ... @@ -156,5 +204,5 @@ func Staff(ctx *aero.Context) string { editors, } - return ctx.HTML(components.UserLists(userLists) + components.StaffRecruitment()) + return ctx.HTML(components.UserLists(userLists, ctx.URI()) + components.StaffRecruitment()) } diff --git a/pages/users/users.pixy b/pages/users/users.pixy index fd23bd7e..8d6e462c 100644 --- a/pages/users/users.pixy +++ b/pages/users/users.pixy @@ -1,17 +1,29 @@ -component Users(users []*arn.User) +component Users(users []*arn.User, url string) h1.page-title Users - - UsersTabs + UsersTabs(url) .user-avatars each user in users .mountable Avatar(user) -component UserLists(groups []*utils.UserList) - h1.page-title Users +component ProUsers(users []*arn.User, url string) + h1.page-title Supporters + UsersTabs(url) - UsersTabs + .pro-avatars + each user in users + a.profile-image-container.mountable.ajax(href=user.Link()) + ProfileImage(user) + .anime-grid-title + .anime-grid-title-text= user.Nick + + .footer.mountable + p We are thankful to everyone supporting the site! + +component UserLists(groups []*utils.UserList, url string) + h1.page-title Users + UsersTabs(url) each group in groups h3.user-list-name.mountable= group.Name @@ -28,10 +40,15 @@ component StaffRecruitment br a(href="https://discord.gg/0kimAmMCeXGXuzNF", target="_blank", rel="noopener") Interested in editing data? -component UsersTabs +component UsersTabs(url string) .tabs Tab("Active", "users", "/users") - //- Tab("No Avatar", "users", "/users/noavatar") - Tab("Osu", "gamepad", "/users/osu") - Tab("Overwatch", "overwatch", "/users/overwatch") - Tab("Staff", "user-secret", "/users/staff") \ No newline at end of file + Tab("Games", "gamepad", "/users/games/osu") + Tab("Editors", "pencil", "/users/editors") + Tab("Supporters", "heart", "/users/pro") + Tab("Staff", "user-secret", "/users/staff") + + if strings.Contains(url, "/users/games") + .tabs + Tab("Osu", "gamepad", "/users/games/osu") + Tab("Overwatch", "overwatch", "/users/games/overwatch") \ No newline at end of file diff --git a/pages/users/users.scarlet b/pages/users/users.scarlet index 7df23240..30f89ba1 100644 --- a/pages/users/users.scarlet +++ b/pages/users/users.scarlet @@ -6,6 +6,24 @@ .user-image margin 0.4rem +.pro-avatars + horizontal-wrap + justify-content center + + .profile-image-container + width 140px + height 140px + max-width 140px + max-height 140px + margin 0.4rem + position relative + border ui-border + box-shadow shadow-light + + :hover + .anime-grid-title + opacity 1 + .user display flex diff --git a/scripts/Actions/Serialization.ts b/scripts/Actions/Serialization.ts index bd3e6f07..f477c14a 100644 --- a/scripts/Actions/Serialization.ts +++ b/scripts/Actions/Serialization.ts @@ -10,6 +10,9 @@ export function save(arn: AnimeNotifier, input: HTMLElement) { return } + // Trim value + value = value.trim() + if((input as HTMLInputElement).type === "number" || input.dataset.type === "number") { if(input.getAttribute("step") === "1" || input.dataset.step === "1") { obj[input.dataset.field] = parseInt(value)