Added Shoboi to admin view

This commit is contained in:
Eduard Urbach 2017-10-02 15:33:39 +02:00
parent ba445f6d74
commit 1806a623bc
5 changed files with 46 additions and 0 deletions

View File

@ -126,6 +126,7 @@ 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)
// Import

View File

@ -1,6 +1,7 @@
component AdminTabs
.tabs
Tab("Server", "server", "/admin")
Tab("Shoboi", "calendar", "/admin/shoboi")
Tab("AniList", "list", "/admin/anilist")
Tab("WebDev", "html5", "/admin/webdev")

27
pages/admin/shoboi.go Normal file
View 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"
)
// 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 {
return missing[i].StartDate > missing[j].StartDate
})
return ctx.HTML(components.ShoboiMissingMapping(missing))
}

16
pages/admin/shoboi.pixy Normal file
View File

@ -0,0 +1,16 @@
component ShoboiMissingMapping(missing []*arn.Anime)
h1.page-title Anime without Shoboi 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="http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese, target="_blank", rel="noopener") Search

View File

@ -230,6 +230,7 @@ var routeTests = map[string][]string{
"/new/thread": nil,
"/new/soundtrack": nil,
"/admin/anilist": nil,
"/admin/shoboi": nil,
"/user": nil,
"/settings": nil,
"/extension/embed": nil,