Improved editor tools
This commit is contained in:
parent
b250f2ea7e
commit
c9f51037dc
8
main.go
8
main.go
@ -20,6 +20,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/charge"
|
||||
"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"
|
||||
@ -134,10 +135,13 @@ func configure(app *aero.Application) *aero.Application {
|
||||
|
||||
// Admin
|
||||
app.Ajax("/admin", admin.Get)
|
||||
app.Ajax("/admin/anilist", admin.AniList)
|
||||
app.Ajax("/admin/shoboi", admin.Shoboi)
|
||||
app.Ajax("/admin/webdev", admin.WebDev)
|
||||
|
||||
// Editor
|
||||
app.Ajax("/editor", editor.Get)
|
||||
app.Ajax("/editor/anilist", editor.AniList)
|
||||
app.Ajax("/editor/shoboi", editor.Shoboi)
|
||||
|
||||
// Import
|
||||
app.Ajax("/import", listimport.Get)
|
||||
app.Ajax("/import/anilist/animelist", listimportanilist.Preview)
|
||||
|
@ -2,8 +2,10 @@ component AdminTabs
|
||||
.tabs
|
||||
Tab("Server", "server", "/admin")
|
||||
Tab("WebDev", "html5", "/admin/webdev")
|
||||
Tab("Shoboi", "calendar", "/admin/shoboi")
|
||||
Tab("AniList", "list", "/admin/anilist")
|
||||
|
||||
a.tab.ajax(href="/editor", aria-label="Editor")
|
||||
Icon("pencil")
|
||||
span.tab-text Editor
|
||||
|
||||
component Admin(user *arn.User, cpuUsage, memUsage, diskUsage float64, platform, family, platformVersion, kernelVersion string)
|
||||
h1.page-title Admin Panel
|
||||
|
@ -3,7 +3,9 @@ component WebDev
|
||||
|
||||
h1.page-title WebDev
|
||||
|
||||
h2 Tests
|
||||
.widgets
|
||||
.widget.mountable
|
||||
h3.widget-title Tests
|
||||
|
||||
.buttons
|
||||
a.button.mountable(href="https://developers.google.com/speed/pagespeed/insights/?url=https://notify.moe/&tab=desktop", target="_blank", rel="noopener")
|
||||
@ -22,7 +24,8 @@ component WebDev
|
||||
Icon("external-link")
|
||||
span Web Page Test
|
||||
|
||||
h2 Browser Support
|
||||
.widget.mountable
|
||||
h3.widget-title Browser Support
|
||||
|
||||
.buttons
|
||||
a.button.mountable(href="http://caniuse.com/#feat=webp", target="_blank", rel="noopener")
|
||||
|
@ -1,4 +1,4 @@
|
||||
package admin
|
||||
package editor
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@ -9,6 +9,8 @@ import (
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
const maxAniListEntries = 70
|
||||
|
||||
// AniList ...
|
||||
func AniList(ctx *aero.Context) string {
|
||||
missing, err := arn.FilterAnime(func(anime *arn.Anime) bool {
|
||||
@ -20,8 +22,22 @@ func AniList(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
sort.Slice(missing, func(i, j int) bool {
|
||||
return missing[i].StartDate > missing[j].StartDate
|
||||
a := missing[i]
|
||||
b := missing[j]
|
||||
|
||||
aPop := a.Popularity.Total()
|
||||
bPop := b.Popularity.Total()
|
||||
|
||||
if aPop == bPop {
|
||||
return a.Title.Canonical < b.Title.Canonical
|
||||
}
|
||||
|
||||
return aPop > bPop
|
||||
})
|
||||
|
||||
if len(missing) > maxAniListEntries {
|
||||
missing = missing[:maxAniListEntries]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AniListMissingMapping(missing))
|
||||
}
|
@ -1,16 +1,25 @@
|
||||
component AniListMissingMapping(missing []*arn.Anime)
|
||||
h1.page-title Anime without Anilist links
|
||||
|
||||
AdminTabs
|
||||
EditorTabs
|
||||
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th(title="Popularity") Pop.
|
||||
th Title
|
||||
th Type
|
||||
th Year
|
||||
th Tools
|
||||
tbody
|
||||
each anime in missing
|
||||
tr
|
||||
td= anime.Popularity.Total()
|
||||
td
|
||||
a(href=anime.Link(), target="_blank", rel="noopener")= anime.Title.Canonical
|
||||
td= anime.Type
|
||||
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
|
18
pages/editor/editor.go
Normal file
18
pages/editor/editor.go
Normal file
@ -0,0 +1,18 @@
|
||||
package editor
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||
return ctx.Redirect("/")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Editor())
|
||||
}
|
16
pages/editor/editor.pixy
Normal file
16
pages/editor/editor.pixy
Normal file
@ -0,0 +1,16 @@
|
||||
component Editor
|
||||
h1.page-title Editor Panel
|
||||
|
||||
EditorTabs
|
||||
|
||||
p Welcome to the Editor Panel!
|
||||
|
||||
component EditorTabs
|
||||
.tabs
|
||||
Tab("Editor", "pencil", "/editor")
|
||||
Tab("Shoboi", "calendar", "/editor/shoboi")
|
||||
Tab("AniList", "list", "/editor/anilist")
|
||||
|
||||
a.tab.ajax(href="/admin", aria-label="Admin")
|
||||
Icon("wrench")
|
||||
span.tab-text Admin
|
@ -1,4 +1,4 @@
|
||||
package admin
|
||||
package editor
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@ -9,6 +9,8 @@ import (
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
const maxShoboiEntries = 70
|
||||
|
||||
// Shoboi ...
|
||||
func Shoboi(ctx *aero.Context) string {
|
||||
missing, err := arn.FilterAnime(func(anime *arn.Anime) bool {
|
||||
@ -20,8 +22,22 @@ func Shoboi(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
sort.Slice(missing, func(i, j int) bool {
|
||||
return missing[i].StartDate > missing[j].StartDate
|
||||
a := missing[i]
|
||||
b := missing[j]
|
||||
|
||||
aPop := a.Popularity.Total()
|
||||
bPop := b.Popularity.Total()
|
||||
|
||||
if aPop == bPop {
|
||||
return a.Title.Canonical < b.Title.Canonical
|
||||
}
|
||||
|
||||
return aPop > bPop
|
||||
})
|
||||
|
||||
if len(missing) > maxShoboiEntries {
|
||||
missing = missing[:maxShoboiEntries]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.ShoboiMissingMapping(missing))
|
||||
}
|
@ -1,16 +1,25 @@
|
||||
component ShoboiMissingMapping(missing []*arn.Anime)
|
||||
h1.page-title Anime without Shoboi links
|
||||
|
||||
AdminTabs
|
||||
EditorTabs
|
||||
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th(title="Popularity") Pop.
|
||||
th Title
|
||||
th Type
|
||||
th Year
|
||||
th Tools
|
||||
tbody
|
||||
each anime in missing
|
||||
tr
|
||||
td= anime.Popularity.Total()
|
||||
td
|
||||
a(href=anime.Link(), target="_blank", rel="noopener")= anime.Title.Canonical
|
||||
td= anime.Type
|
||||
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="http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese, target="_blank", rel="noopener") Search
|
@ -6,7 +6,6 @@ const ETAGS = new Map<string, string>()
|
||||
const CACHEREFRESH = new Map<string, Promise<void>>()
|
||||
const EXCLUDECACHE = new Set<string>([
|
||||
"/api/",
|
||||
"/admin/",
|
||||
"/paypal/",
|
||||
"/import/",
|
||||
"chrome-extension"
|
||||
|
Loading…
Reference in New Issue
Block a user