Improved admin panel
This commit is contained in:
@ -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("/")
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
27
pages/admin/anilist.go
Normal file
27
pages/admin/anilist.go
Normal file
@ -0,0 +1,27 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// AniList ...
|
||||
func AniList(ctx *aero.Context) string {
|
||||
missing, err := arn.FilterAnime(func(anime *arn.Anime) bool {
|
||||
return anime.GetMapping("anilist/anime") == ""
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "Couldn't filter anime", err)
|
||||
}
|
||||
|
||||
sort.Slice(missing, func(i, j int) bool {
|
||||
return missing[i].StartDate > missing[j].StartDate
|
||||
})
|
||||
|
||||
return ctx.HTML(components.AniListMissingMapping(missing))
|
||||
}
|
16
pages/admin/anilist.pixy
Normal file
16
pages/admin/anilist.pixy
Normal file
@ -0,0 +1,16 @@
|
||||
component AniListMissingMapping(missing []*arn.Anime)
|
||||
h1.page-title Anime without Anilist links
|
||||
|
||||
AdminTabs
|
||||
|
||||
table
|
||||
tbody
|
||||
each anime in missing
|
||||
tr
|
||||
td
|
||||
if len(anime.StartDate) >= 4
|
||||
span= anime.StartDate[:4]
|
||||
td
|
||||
a(href=anime.Link(), target="_blank", rel="noopener")= anime.Title.Canonical
|
||||
td
|
||||
a(href="https://anilist.co/search?type=anime&q=" + anime.Title.Canonical, target="_blank", rel="noopener") Search
|
9
pages/admin/webdev.go
Normal file
9
pages/admin/webdev.go
Normal file
@ -0,0 +1,9 @@
|
||||
package admin
|
||||
|
||||
import "github.com/aerogo/aero"
|
||||
import "github.com/animenotifier/notify.moe/components"
|
||||
|
||||
// WebDev ...
|
||||
func WebDev(ctx *aero.Context) string {
|
||||
return ctx.HTML(components.WebDev())
|
||||
}
|
15
pages/admin/webdev.pixy
Normal file
15
pages/admin/webdev.pixy
Normal file
@ -0,0 +1,15 @@
|
||||
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")
|
||||
span Google PageSpeed
|
||||
a.light-button(href="https://observatory.mozilla.org/analyze.html?host=notify.moe", target="_blank", rel="noopener")
|
||||
Icon("external-link")
|
||||
span Mozilla Observatory
|
||||
a.light-button(href="https://html5.validator.nu/?doc=https://notify.moe", target="_blank", rel="noopener")
|
||||
Icon("external-link")
|
||||
span HTML5 Validator
|
Reference in New Issue
Block a user