From 1806a623bcaf72507e1eb984749ba465bd6ff7f3 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 2 Oct 2017 15:33:39 +0200 Subject: [PATCH] Added Shoboi to admin view --- main.go | 1 + pages/admin/admin.pixy | 1 + pages/admin/shoboi.go | 27 +++++++++++++++++++++++++++ pages/admin/shoboi.pixy | 16 ++++++++++++++++ tests.go | 1 + 5 files changed, 46 insertions(+) create mode 100644 pages/admin/shoboi.go create mode 100644 pages/admin/shoboi.pixy diff --git a/main.go b/main.go index 8a0224aa..cacc69c1 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/pages/admin/admin.pixy b/pages/admin/admin.pixy index bee55b01..247c6719 100644 --- a/pages/admin/admin.pixy +++ b/pages/admin/admin.pixy @@ -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") diff --git a/pages/admin/shoboi.go b/pages/admin/shoboi.go new file mode 100644 index 00000000..c4cdbd33 --- /dev/null +++ b/pages/admin/shoboi.go @@ -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)) +} diff --git a/pages/admin/shoboi.pixy b/pages/admin/shoboi.pixy new file mode 100644 index 00000000..5224eae7 --- /dev/null +++ b/pages/admin/shoboi.pixy @@ -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 diff --git a/tests.go b/tests.go index 65e568d8..3fe8f199 100644 --- a/tests.go +++ b/tests.go @@ -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,