From af6bc391afc4eb6b70152a703fe64accdc38e128 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 7 Mar 2018 22:06:02 +0100 Subject: [PATCH] Added filters to editor lists --- mixins/AnimeEditorList.pixy | 8 ++++---- pages/editor/anilist.go | 12 ++++++++++++ pages/editor/genres.go | 12 ++++++++++++ pages/editor/shoboi.go | 12 ++++++++++++ pages/index.go | 6 ++++++ 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/mixins/AnimeEditorList.pixy b/mixins/AnimeEditorList.pixy index 55a9a90d..5ef0a87a 100644 --- a/mixins/AnimeEditorList.pixy +++ b/mixins/AnimeEditorList.pixy @@ -1,10 +1,10 @@ -component AnimeEditorListFull(title string, missing []*arn.Anime, count int, generateSearchLink func(*arn.Anime) string) +component AnimeEditorListFull(title string, missing []*arn.Anime, count int, pageURI string, generateSearchLink func(*arn.Anime) string) EditorTabs h1.editor-list-title.mountable= title .footer.editor-list-entry-count.mountable= strconv.Itoa(count) + " anime" - AnimeEditorList(missing, generateSearchLink) + AnimeEditorList(missing, pageURI, generateSearchLink) -component AnimeEditorList(animes []*arn.Anime, generateSearchLink func(*arn.Anime) string) +component AnimeEditorList(animes []*arn.Anime, pageURI string, generateSearchLink func(*arn.Anime) string) table thead tr.mountable @@ -24,7 +24,7 @@ component AnimeEditorList(animes []*arn.Anime, generateSearchLink func(*arn.Anim td= anime.Type td if len(anime.StartDate) >= 4 - span= anime.StartDate[:4] + a.ajax(href=pageURI + "/" + anime.StartDate[:4])= anime.StartDate[:4] if generateSearchLink != nil td diff --git a/pages/editor/anilist.go b/pages/editor/anilist.go index 5d9b7205..b0641a6f 100644 --- a/pages/editor/anilist.go +++ b/pages/editor/anilist.go @@ -12,7 +12,18 @@ const maxAniListEntries = 70 // AniList ... func AniList(ctx *aero.Context) string { + year, _ := ctx.GetInt("year") + animeType := ctx.Get("type") + missing := arn.FilterAnime(func(anime *arn.Anime) bool { + if year != 0 && year != anime.StartDateTime().Year() { + return false + } + + if animeType != "" && anime.Type != animeType { + return false + } + return anime.GetMapping("anilist/anime") == "" }) @@ -40,6 +51,7 @@ func AniList(ctx *aero.Context) string { "Anime without Anilist links", missing, count, + "/editor/anilist", func(anime *arn.Anime) string { return "https://anilist.co/search?type=anime&q=" + anime.Title.Canonical }, diff --git a/pages/editor/genres.go b/pages/editor/genres.go index 680f2c83..5ac45032 100644 --- a/pages/editor/genres.go +++ b/pages/editor/genres.go @@ -12,7 +12,18 @@ const maxGenreEntries = 70 // Genres ... func Genres(ctx *aero.Context) string { + year, _ := ctx.GetInt("year") + animeType := ctx.Get("type") + missing := arn.FilterAnime(func(anime *arn.Anime) bool { + if year != 0 && year != anime.StartDateTime().Year() { + return false + } + + if animeType != "" && anime.Type != animeType { + return false + } + return len(anime.Genres) == 0 }) @@ -40,6 +51,7 @@ func Genres(ctx *aero.Context) string { "Anime without genres", missing, count, + "/editor/genres", nil, )) } diff --git a/pages/editor/shoboi.go b/pages/editor/shoboi.go index 43abd2c1..f6d37820 100644 --- a/pages/editor/shoboi.go +++ b/pages/editor/shoboi.go @@ -12,7 +12,18 @@ const maxShoboiEntries = 70 // Shoboi ... func Shoboi(ctx *aero.Context) string { + year, _ := ctx.GetInt("year") + animeType := ctx.Get("type") + missing := arn.FilterAnime(func(anime *arn.Anime) bool { + if year != 0 && year != anime.StartDateTime().Year() { + return false + } + + if animeType != "" && anime.Type != animeType { + return false + } + return anime.GetMapping("shoboi/anime") == "" }) @@ -40,6 +51,7 @@ func Shoboi(ctx *aero.Context) string { "Anime without Shoboi links", missing, count, + "/editor/shoboi", func(anime *arn.Anime) string { return "http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese }, diff --git a/pages/index.go b/pages/index.go index f84c8965..6824a456 100644 --- a/pages/index.go +++ b/pages/index.go @@ -200,8 +200,14 @@ func Configure(app *aero.Application) { // Editor l.Page("/editor", editor.Get) l.Page("/editor/anilist", editor.AniList) + l.Page("/editor/anilist/:year", editor.AniList) + l.Page("/editor/anilist/:year/:type", editor.AniList) l.Page("/editor/shoboi", editor.Shoboi) + l.Page("/editor/shoboi/:year", editor.Shoboi) + l.Page("/editor/shoboi/:year/:type", editor.Shoboi) l.Page("/editor/genres", editor.Genres) + l.Page("/editor/genres/:year", editor.Genres) + l.Page("/editor/genres/:year/:type", editor.Genres) // Mixed l.Page("/database", database.Get)