Improved editor tools
This commit is contained in:
43
pages/editor/anilist.go
Normal file
43
pages/editor/anilist.go
Normal file
@ -0,0 +1,43 @@
|
||||
package editor
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"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 {
|
||||
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 {
|
||||
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))
|
||||
}
|
25
pages/editor/anilist.pixy
Normal file
25
pages/editor/anilist.pixy
Normal file
@ -0,0 +1,25 @@
|
||||
component AniListMissingMapping(missing []*arn.Anime)
|
||||
h1.page-title Anime without Anilist links
|
||||
|
||||
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="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
|
43
pages/editor/shoboi.go
Normal file
43
pages/editor/shoboi.go
Normal file
@ -0,0 +1,43 @@
|
||||
package editor
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"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 {
|
||||
return anime.GetMapping("shoboi/anime") == ""
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "Couldn't filter anime", err)
|
||||
}
|
||||
|
||||
sort.Slice(missing, func(i, j int) bool {
|
||||
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))
|
||||
}
|
25
pages/editor/shoboi.pixy
Normal file
25
pages/editor/shoboi.pixy
Normal file
@ -0,0 +1,25 @@
|
||||
component ShoboiMissingMapping(missing []*arn.Anime)
|
||||
h1.page-title Anime without Shoboi links
|
||||
|
||||
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="http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese, target="_blank", rel="noopener") Search
|
Reference in New Issue
Block a user