diff --git a/main.go b/main.go index 68db0cf7..8a0224aa 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,6 @@ import ( "github.com/animenotifier/notify.moe/pages/character" "github.com/animenotifier/notify.moe/pages/dashboard" "github.com/animenotifier/notify.moe/pages/editanime" - "github.com/animenotifier/notify.moe/pages/editor" "github.com/animenotifier/notify.moe/pages/embed" "github.com/animenotifier/notify.moe/pages/explore" "github.com/animenotifier/notify.moe/pages/forum" @@ -46,7 +45,6 @@ import ( "github.com/animenotifier/notify.moe/pages/threads" "github.com/animenotifier/notify.moe/pages/user" "github.com/animenotifier/notify.moe/pages/users" - "github.com/animenotifier/notify.moe/pages/webdev" ) var app = aero.New() @@ -94,6 +92,8 @@ func configure(app *aero.Application) *aero.Application { app.Ajax("/users/osu", users.Osu) app.Ajax("/users/staff", users.Staff) app.Ajax("/users/anime/watching", users.AnimeWatching) + app.Ajax("/statistics", statistics.Get) + app.Ajax("/statistics/anime", statistics.Anime) app.Ajax("/login", login.Get) // User profiles @@ -125,10 +125,8 @@ func configure(app *aero.Application) *aero.Application { // Admin app.Ajax("/admin", admin.Get) - app.Ajax("/editor", editor.Get) - app.Ajax("/statistics", statistics.Get) - app.Ajax("/statistics/anime", statistics.Anime) - app.Ajax("/webdev", webdev.Get) + app.Ajax("/admin/anilist", admin.AniList) + app.Ajax("/admin/webdev", admin.WebDev) // Import app.Ajax("/import", listimport.Get) diff --git a/mixins/Sidebar.pixy b/mixins/Sidebar.pixy index ab70f539..b6b66e8e 100644 --- a/mixins/Sidebar.pixy +++ b/mixins/Sidebar.pixy @@ -23,7 +23,7 @@ component Sidebar(user *arn.User) SidebarButton("Statistics", "/statistics", "pie-chart") SidebarButton("Settings", "/settings", "cog") - if user.Role == "admin" + if user.Role == "admin" || user.Role == "editor" SidebarButton("Admin", "/admin", "wrench") .spacer diff --git a/mixins/StatusTabs.pixy b/mixins/StatusTabs.pixy index c714b0ab..7732ab3b 100644 --- a/mixins/StatusTabs.pixy +++ b/mixins/StatusTabs.pixy @@ -1,12 +1,7 @@ component StatusTabs(urlPrefix string) - .tabs.status-tabs - StatusTab("Watching", "play", urlPrefix + "/watching") - StatusTab("Completed", "check", urlPrefix + "/completed") - StatusTab("Planned", "forward", urlPrefix + "/planned") - StatusTab("On Hold", "pause", urlPrefix + "/hold") - StatusTab("Dropped", "stop", urlPrefix + "/dropped") - -component StatusTab(label string, icon string, url string) - a.tab.status-tab.action(href=url, data-action="diff", data-trigger="click", aria-label=label) - Icon(icon) - span.tab-text= label \ No newline at end of file + .tabs + Tab("Watching", "play", urlPrefix + "/watching") + Tab("Completed", "check", urlPrefix + "/completed") + Tab("Planned", "forward", urlPrefix + "/planned") + Tab("On Hold", "pause", urlPrefix + "/hold") + Tab("Dropped", "stop", urlPrefix + "/dropped") \ No newline at end of file diff --git a/mixins/Tab.pixy b/mixins/Tab.pixy new file mode 100644 index 00000000..c4582768 --- /dev/null +++ b/mixins/Tab.pixy @@ -0,0 +1,4 @@ +component Tab(label string, icon string, url string) + a.tab.action(href=url, data-action="diff", data-trigger="click", aria-label=label) + Icon(icon) + span.tab-text= label \ No newline at end of file diff --git a/pages/admin/admin.go b/pages/admin/admin.go index 94912e64..cf674966 100644 --- a/pages/admin/admin.go +++ b/pages/admin/admin.go @@ -17,7 +17,7 @@ import ( func Get(ctx *aero.Context) string { user := utils.GetUser(ctx) - if user == nil || user.Role != "admin" { + if user == nil || (user.Role != "admin" && user.Role != "editor") { return ctx.Redirect("/") } diff --git a/pages/admin/admin.pixy b/pages/admin/admin.pixy index 77d8b121..bee55b01 100644 --- a/pages/admin/admin.pixy +++ b/pages/admin/admin.pixy @@ -1,6 +1,14 @@ +component AdminTabs + .tabs + Tab("Server", "server", "/admin") + Tab("AniList", "list", "/admin/anilist") + Tab("WebDev", "html5", "/admin/webdev") + component Admin(user *arn.User, cpuUsage, memUsage, diskUsage float64, platform, family, platformVersion, kernelVersion string) h1.page-title Admin Panel + AdminTabs + .widgets .widget.mountable h3.widget-title Usage diff --git a/pages/editor/editor.go b/pages/admin/anilist.go similarity index 88% rename from pages/editor/editor.go rename to pages/admin/anilist.go index 73de1f37..bcd74838 100644 --- a/pages/editor/editor.go +++ b/pages/admin/anilist.go @@ -1,4 +1,4 @@ -package editor +package admin import ( "net/http" @@ -9,8 +9,8 @@ import ( "github.com/animenotifier/notify.moe/components" ) -// Get ... -func Get(ctx *aero.Context) string { +// AniList ... +func AniList(ctx *aero.Context) string { missing, err := arn.FilterAnime(func(anime *arn.Anime) bool { return anime.GetMapping("anilist/anime") == "" }) diff --git a/pages/editor/editor.pixy b/pages/admin/anilist.pixy similarity index 87% rename from pages/editor/editor.pixy rename to pages/admin/anilist.pixy index f9a1cd52..cbed563c 100644 --- a/pages/editor/editor.pixy +++ b/pages/admin/anilist.pixy @@ -1,5 +1,7 @@ component AniListMissingMapping(missing []*arn.Anime) - h1 Anime without Anilist links + h1.page-title Anime without Anilist links + + AdminTabs table tbody diff --git a/pages/webdev/webdev.go b/pages/admin/webdev.go similarity index 65% rename from pages/webdev/webdev.go rename to pages/admin/webdev.go index e25bcd67..15d7c97c 100644 --- a/pages/webdev/webdev.go +++ b/pages/admin/webdev.go @@ -1,9 +1,9 @@ -package webdev +package admin import "github.com/aerogo/aero" import "github.com/animenotifier/notify.moe/components" -// Get ... -func Get(ctx *aero.Context) string { +// WebDev ... +func WebDev(ctx *aero.Context) string { return ctx.HTML(components.WebDev()) } diff --git a/pages/webdev/webdev.pixy b/pages/admin/webdev.pixy similarity index 98% rename from pages/webdev/webdev.pixy rename to pages/admin/webdev.pixy index 11ae5d3b..ffe3db70 100644 --- a/pages/webdev/webdev.pixy +++ b/pages/admin/webdev.pixy @@ -1,6 +1,8 @@ component WebDev h1.page-title WebDev + AdminTabs + .light-button-group a.light-button(href="https://developers.google.com/speed/pagespeed/insights/?url=https://notify.moe/&tab=desktop", target="_blank", rel="noopener") Icon("external-link") diff --git a/pages/profile/watching.scarlet b/pages/profile/watching.scarlet index 128749b9..0e37f03a 100644 --- a/pages/profile/watching.scarlet +++ b/pages/profile/watching.scarlet @@ -13,18 +13,4 @@ transition filter transition-speed ease, opacity transition-speed ease :hover - filter saturate(1.3) - -.status-tabs - // margin-top 2px -// position fixed -// top 4.6rem -// right 1.6rem -// flex-direction column - -// .status-tab -// font-size 0.9rem - -// < 380px -// .profile-watching-list -// justify-content center \ No newline at end of file + filter saturate(1.3) \ No newline at end of file diff --git a/tests.go b/tests.go index d4079096..65e568d8 100644 --- a/tests.go +++ b/tests.go @@ -229,7 +229,7 @@ var routeTests = map[string][]string{ "/anime/:id/edit": nil, "/new/thread": nil, "/new/soundtrack": nil, - "/editor": nil, + "/admin/anilist": nil, "/user": nil, "/settings": nil, "/extension/embed": nil,