Added new editor lists

This commit is contained in:
Eduard Urbach 2018-03-22 22:26:52 +01:00
parent 95b5224011
commit 6c2e9e2b64
10 changed files with 178 additions and 151 deletions

View File

@ -16,19 +16,30 @@ component Editor(url string, score int, scoreTypes map[string]int, user *arn.Use
component EditorTabs(url string) component EditorTabs(url string)
.tabs .tabs
Tab("Editor", "pencil", "/editor") Tab("Editor", "pencil", "/editor")
Tab("MAL", "exchange", "/editor/anime/maldiff") Tab("MAL", "exchange", "/editor/maldiff/anime")
Tab("Kitsu", "exchange", "/editor/anime/kitsu/new") Tab("Kitsu", "exchange", "/editor/kitsu/new/anime")
Tab("Anime", "tv", "/editor/anime/missing/shoboi") Tab("Anime", "tv", "/editor/anime/synopsis")
Tab("Companies", "building", "/editor/companies/missing/description") Tab("Companies", "building", "/editor/companies/description")
Tab("Search", "search", "/database") Tab("Search", "search", "/database")
if strings.Contains(url, "/editor/anime/missing/") || strings.Contains(url, "/editor/anime/lowresimage") || strings.Contains(url, "/editor/anime/ultralowresimage") if strings.Contains(url, "/editor/anime/")
.tabs .tabs
Tab("Shoboi", "list", "/editor/anime/missing/shoboi") Tab("Synopsis", "align-left", "/editor/anime/synopsis")
Tab("AniList", "list", "/editor/anime/missing/anilist") Tab("Genres", "clone", "/editor/anime/genres")
Tab("Genres", "list", "/editor/anime/missing/genres") Tab("Start date", "calendar", "/editor/anime/startdate")
Tab("Low-Res", "image", "/editor/anime/lowresimage") Tab("Mappings", "arrows-h", "/editor/anime/mapping/mal")
Tab("Ultra Low-Res", "image", "/editor/anime/ultralowresimage") Tab("Images", "image", "/editor/anime/image/lowres")
if strings.Contains(url, "/editor/anime/mapping/")
.tabs
Tab("MAL", "arrows-h", "/editor/anime/mapping/mal")
Tab("Shoboi", "arrows-h", "/editor/anime/mapping/shoboi")
Tab("AniList", "arrows-h", "/editor/anime/mapping/anilist")
if strings.Contains(url, "/editor/anime/image/")
.tabs
Tab("Low-Res", "image", "/editor/anime/image/lowres")
Tab("Ultra Low-Res", "image", "/editor/anime/image/ultralowres")
//- a.tab.ajax(href="/admin", aria-label="Admin") //- a.tab.ajax(href="/admin", aria-label="Admin")
//- Icon("wrench") //- Icon("wrench")

View File

@ -3,43 +3,18 @@ package filteranime
import ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
) )
const maxAniListEntries = 70
// AniList ... // AniList ...
func AniList(ctx *aero.Context) string { func AniList(ctx *aero.Context) string {
year, _ := ctx.GetInt("year") return editorList(
animeType := ctx.Get("type") ctx,
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") == ""
})
arn.SortAnimeByQuality(missing)
count := len(missing)
if count > maxAniListEntries {
missing = missing[:maxAniListEntries]
}
return ctx.HTML(components.AnimeEditorListFull(
"Anime without Anilist mappings", "Anime without Anilist mappings",
missing, func(anime *arn.Anime) bool {
count, return anime.GetMapping("anilist/anime") == ""
ctx.URI(), },
func(anime *arn.Anime) string { func(anime *arn.Anime) string {
return "https://anilist.co/search?type=anime&q=" + anime.Title.Canonical return "https://anilist.co/search?type=anime&q=" + anime.Title.Canonical
}, },
)) )
} }

View File

@ -3,41 +3,18 @@ package filteranime
import ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
) )
const maxGenreEntries = 70 const maxGenreEntries = 70
// Genres ... // Genres ...
func Genres(ctx *aero.Context) string { func Genres(ctx *aero.Context) string {
year, _ := ctx.GetInt("year") return editorList(
animeType := ctx.Get("type") ctx,
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
})
arn.SortAnimeByQuality(missing)
count := len(missing)
if count > maxGenreEntries {
missing = missing[:maxGenreEntries]
}
return ctx.HTML(components.AnimeEditorListFull(
"Anime without genres", "Anime without genres",
missing, func(anime *arn.Anime) bool {
count, return len(anime.Genres) == 0
ctx.URI(), },
nil, nil,
)) )
} }

View File

@ -3,7 +3,6 @@ package filteranime
import ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
) )
const maxImageEntries = 70 const maxImageEntries = 70
@ -19,38 +18,14 @@ func UltraLowResolutionAnimeImages(ctx *aero.Context) string {
} }
func filterAnimeImages(ctx *aero.Context, title string, minExpectedWidth int, minExpectedHeight int) string { func filterAnimeImages(ctx *aero.Context, title string, minExpectedWidth int, minExpectedHeight int) string {
year, _ := ctx.GetInt("year") return editorList(
animeType := ctx.Get("type") ctx,
lowResAnime := 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.Image.Width < minExpectedWidth || anime.Image.Height < minExpectedHeight
})
// Sort
arn.SortAnimeByQuality(lowResAnime)
// Limit
count := len(lowResAnime)
if count > maxImageEntries {
lowResAnime = lowResAnime[:maxImageEntries]
}
return ctx.HTML(components.AnimeEditorListFull(
title, title,
lowResAnime, func(anime *arn.Anime) bool {
count, return anime.Image.Width < minExpectedWidth || anime.Image.Height < minExpectedHeight
ctx.URI(), },
googleImageSearch, googleImageSearch,
)) )
} }
func googleImageSearch(anime *arn.Anime) string { func googleImageSearch(anime *arn.Anime) string {

View File

@ -0,0 +1,20 @@
package filteranime
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// MAL ...
func MAL(ctx *aero.Context) string {
return editorList(
ctx,
"Anime without MAL mappings",
func(anime *arn.Anime) bool {
return anime.GetMapping("myanimelist/anime") == ""
},
func(anime *arn.Anime) string {
return "https://myanimelist.net/anime.php?q=" + anime.Title.Canonical
},
)
}

View File

@ -3,43 +3,20 @@ package filteranime
import ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
) )
const maxShoboiEntries = 70 const maxShoboiEntries = 70
// Shoboi ... // Shoboi ...
func Shoboi(ctx *aero.Context) string { func Shoboi(ctx *aero.Context) string {
year, _ := ctx.GetInt("year") return editorList(
animeType := ctx.Get("type") ctx,
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") == ""
})
arn.SortAnimeByQuality(missing)
count := len(missing)
if count > maxShoboiEntries {
missing = missing[:maxShoboiEntries]
}
return ctx.HTML(components.AnimeEditorListFull(
"Anime without Shoboi mappings", "Anime without Shoboi mappings",
missing, func(anime *arn.Anime) bool {
count, return anime.GetMapping("shoboi/anime") == ""
ctx.URI(), },
func(anime *arn.Anime) string { func(anime *arn.Anime) string {
return "http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese return "http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese
}, },
)) )
} }

View File

@ -0,0 +1,21 @@
package filteranime
import (
"time"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// StartDate ...
func StartDate(ctx *aero.Context) string {
return editorList(
ctx,
"Anime without a valid start date",
func(anime *arn.Anime) bool {
_, err := time.Parse(arn.AnimeDateFormat, anime.StartDate)
return err != nil
},
nil,
)
}

View File

@ -0,0 +1,18 @@
package filteranime
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// Synopsis ...
func Synopsis(ctx *aero.Context) string {
return editorList(
ctx,
"Anime without a long synopsis",
func(anime *arn.Anime) bool {
return len(anime.Summary) < 170
},
nil,
)
}

View File

@ -0,0 +1,54 @@
package filteranime
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
const maxAnimeEntries = 70
// editorList renders the anime list with the given title and filter.
func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) string {
animes, count := filterAnime(ctx, filter)
return ctx.HTML(components.AnimeEditorListFull(
title,
animes,
count,
ctx.URI(),
searchLink,
))
}
// filterAnime filters anime by the given filter function and
// additionally applies year and types filters if specified.
func filterAnime(ctx *aero.Context, filter func(*arn.Anime) bool) ([]*arn.Anime, int) {
year, _ := ctx.GetInt("year")
animeType := ctx.Get("type")
// Filter
animes := arn.FilterAnime(func(anime *arn.Anime) bool {
if year != 0 && year != anime.StartDateTime().Year() {
return false
}
if animeType != "" && anime.Type != animeType {
return false
}
return filter(anime)
})
// Sort
arn.SortAnimeByQuality(animes)
// Limit
count := len(animes)
if count > maxAnimeEntries {
animes = animes[:maxAnimeEntries]
}
return animes, count
}

View File

@ -249,33 +249,32 @@ func Configure(app *aero.Application) {
l.Page("/editor", editor.Get) l.Page("/editor", editor.Get)
// Editor - Anime // Editor - Anime
l.Page("/editor/anime/missing/anilist", filteranime.AniList) editorList := func(route string, handler func(ctx *aero.Context) string) {
l.Page("/editor/anime/missing/anilist/:year", filteranime.AniList) l.Page(route, handler)
l.Page("/editor/anime/missing/anilist/:year/:type", filteranime.AniList) l.Page(route+"/:year", handler)
l.Page("/editor/anime/missing/shoboi", filteranime.Shoboi) l.Page(route+"/:year/:type", handler)
l.Page("/editor/anime/missing/shoboi/:year", filteranime.Shoboi) }
l.Page("/editor/anime/missing/shoboi/:year/:type", filteranime.Shoboi)
l.Page("/editor/anime/missing/genres", filteranime.Genres) editorList("/editor/anime/synopsis", filteranime.Synopsis)
l.Page("/editor/anime/missing/genres/:year", filteranime.Genres) editorList("/editor/anime/genres", filteranime.Genres)
l.Page("/editor/anime/missing/genres/:year/:type", filteranime.Genres) editorList("/editor/anime/startdate", filteranime.StartDate)
l.Page("/editor/anime/lowresimage", filteranime.LowResolutionAnimeImages) editorList("/editor/anime/mapping/shoboi", filteranime.Shoboi)
l.Page("/editor/anime/lowresimage/:year", filteranime.LowResolutionAnimeImages) editorList("/editor/anime/mapping/anilist", filteranime.AniList)
l.Page("/editor/anime/lowresimage/:year/:type", filteranime.LowResolutionAnimeImages) editorList("/editor/anime/mapping/mal", filteranime.MAL)
l.Page("/editor/anime/ultralowresimage", filteranime.UltraLowResolutionAnimeImages) editorList("/editor/anime/image/lowres", filteranime.LowResolutionAnimeImages)
l.Page("/editor/anime/ultralowresimage/:year", filteranime.UltraLowResolutionAnimeImages) editorList("/editor/anime/image/ultralowres", filteranime.UltraLowResolutionAnimeImages)
l.Page("/editor/anime/ultralowresimage/:year/:type", filteranime.UltraLowResolutionAnimeImages)
// Editor - MALdiff // Editor - MALdiff
l.Page("/editor/anime/maldiff", editor.CompareMAL) l.Page("/editor/maldiff/anime", editor.CompareMAL)
l.Page("/editor/anime/maldiff/:year", editor.CompareMAL) l.Page("/editor/maldiff/anime/:year", editor.CompareMAL)
l.Page("/editor/anime/maldiff/:year/:status", editor.CompareMAL) l.Page("/editor/maldiff/anime/:year/:status", editor.CompareMAL)
l.Page("/editor/anime/maldiff/:year/:status/:type", editor.CompareMAL) l.Page("/editor/maldiff/anime/:year/:status/:type", editor.CompareMAL)
// Editor - Kitsu // Editor - Kitsu
l.Page("/editor/anime/kitsu/new", editor.NewKitsuAnime) l.Page("/editor/kitsu/new/anime", editor.NewKitsuAnime)
// Editor - Companies // Editor - Companies
l.Page("/editor/companies/missing/description", filtercompanies.NoDescription) l.Page("/editor/companies/description", filtercompanies.NoDescription)
// Log // Log
l.Page("/log", editlog.Get) l.Page("/log", editlog.Get)