Improved editor tools

This commit is contained in:
Eduard Urbach 2017-10-06 22:07:12 +02:00
parent b250f2ea7e
commit c9f51037dc
11 changed files with 148 additions and 56 deletions

View File

@ -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)

View File

@ -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

View File

@ -2,44 +2,47 @@ component WebDev
AdminTabs
h1.page-title WebDev
h2 Tests
.buttons
a.button.mountable(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.button.mountable(href="https://observatory.mozilla.org/analyze.html?host=notify.moe", target="_blank", rel="noopener")
Icon("external-link")
span Mozilla Observatory
a.button.mountable(href="https://html5.validator.nu/?doc=https://notify.moe", target="_blank", rel="noopener")
Icon("external-link")
span HTML5 Validator
a.button.mountable(href="https://testmysite.withgoogle.com/", target="_blank", rel="noopener")
Icon("external-link")
span Mobile Speed
a.button.mountable(href="https://www.webpagetest.org/", target="_blank", rel="noopener")
Icon("external-link")
span Web Page Test
h2 Browser Support
.widgets
.widget.mountable
h3.widget-title Tests
.buttons
a.button.mountable(href="http://caniuse.com/#feat=webp", target="_blank", rel="noopener")
Icon("external-link")
span WebP
a.button.mountable(href="http://caniuse.com/#feat=push-api", target="_blank", rel="noopener")
Icon("external-link")
span Push API
a.button.mountable(href="http://caniuse.com/#feat=serviceworkers", target="_blank", rel="noopener")
Icon("external-link")
span Service Worker
a.button.mountable(href="http://caniuse.com/#feat=intersectionobserver", target="_blank", rel="noopener")
Icon("external-link")
span Intersection Observer
a.button.mountable(href="http://caniuse.com/#feat=requestidlecallback", target="_blank", rel="noopener")
Icon("external-link")
span Request Idle Callback
a.button.mountable(href="http://caniuse.com/#feat=css-variables", target="_blank", rel="noopener")
Icon("external-link")
span CSS Variables
.buttons
a.button.mountable(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.button.mountable(href="https://observatory.mozilla.org/analyze.html?host=notify.moe", target="_blank", rel="noopener")
Icon("external-link")
span Mozilla Observatory
a.button.mountable(href="https://html5.validator.nu/?doc=https://notify.moe", target="_blank", rel="noopener")
Icon("external-link")
span HTML5 Validator
a.button.mountable(href="https://testmysite.withgoogle.com/", target="_blank", rel="noopener")
Icon("external-link")
span Mobile Speed
a.button.mountable(href="https://www.webpagetest.org/", target="_blank", rel="noopener")
Icon("external-link")
span Web Page Test
.widget.mountable
h3.widget-title Browser Support
.buttons
a.button.mountable(href="http://caniuse.com/#feat=webp", target="_blank", rel="noopener")
Icon("external-link")
span WebP
a.button.mountable(href="http://caniuse.com/#feat=push-api", target="_blank", rel="noopener")
Icon("external-link")
span Push API
a.button.mountable(href="http://caniuse.com/#feat=serviceworkers", target="_blank", rel="noopener")
Icon("external-link")
span Service Worker
a.button.mountable(href="http://caniuse.com/#feat=intersectionobserver", target="_blank", rel="noopener")
Icon("external-link")
span Intersection Observer
a.button.mountable(href="http://caniuse.com/#feat=requestidlecallback", target="_blank", rel="noopener")
Icon("external-link")
span Request Idle Callback
a.button.mountable(href="http://caniuse.com/#feat=css-variables", target="_blank", rel="noopener")
Icon("external-link")
span CSS Variables

View File

@ -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))
}

View File

@ -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
View 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
View 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

View File

@ -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))
}

View File

@ -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

View File

@ -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"

View File

@ -242,8 +242,8 @@ var routeTests = map[string][]string{
"/anime/:id/edit": nil,
"/new/thread": nil,
"/new/soundtrack": nil,
"/admin/anilist": nil,
"/admin/shoboi": nil,
"/editor/anilist": nil,
"/editor/shoboi": nil,
"/user": nil,
"/settings": nil,
"/shop": nil,