Added new editor lists
This commit is contained in:
parent
95b5224011
commit
6c2e9e2b64
@ -16,19 +16,30 @@ component Editor(url string, score int, scoreTypes map[string]int, user *arn.Use
|
||||
component EditorTabs(url string)
|
||||
.tabs
|
||||
Tab("Editor", "pencil", "/editor")
|
||||
Tab("MAL", "exchange", "/editor/anime/maldiff")
|
||||
Tab("Kitsu", "exchange", "/editor/anime/kitsu/new")
|
||||
Tab("Anime", "tv", "/editor/anime/missing/shoboi")
|
||||
Tab("Companies", "building", "/editor/companies/missing/description")
|
||||
Tab("MAL", "exchange", "/editor/maldiff/anime")
|
||||
Tab("Kitsu", "exchange", "/editor/kitsu/new/anime")
|
||||
Tab("Anime", "tv", "/editor/anime/synopsis")
|
||||
Tab("Companies", "building", "/editor/companies/description")
|
||||
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
|
||||
Tab("Shoboi", "list", "/editor/anime/missing/shoboi")
|
||||
Tab("AniList", "list", "/editor/anime/missing/anilist")
|
||||
Tab("Genres", "list", "/editor/anime/missing/genres")
|
||||
Tab("Low-Res", "image", "/editor/anime/lowresimage")
|
||||
Tab("Ultra Low-Res", "image", "/editor/anime/ultralowresimage")
|
||||
Tab("Synopsis", "align-left", "/editor/anime/synopsis")
|
||||
Tab("Genres", "clone", "/editor/anime/genres")
|
||||
Tab("Start date", "calendar", "/editor/anime/startdate")
|
||||
Tab("Mappings", "arrows-h", "/editor/anime/mapping/mal")
|
||||
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")
|
||||
//- Icon("wrench")
|
||||
|
@ -3,43 +3,18 @@ package filteranime
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
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") == ""
|
||||
})
|
||||
|
||||
arn.SortAnimeByQuality(missing)
|
||||
|
||||
count := len(missing)
|
||||
|
||||
if count > maxAniListEntries {
|
||||
missing = missing[:maxAniListEntries]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AnimeEditorListFull(
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without Anilist mappings",
|
||||
missing,
|
||||
count,
|
||||
ctx.URI(),
|
||||
func(anime *arn.Anime) bool {
|
||||
return anime.GetMapping("anilist/anime") == ""
|
||||
},
|
||||
func(anime *arn.Anime) string {
|
||||
return "https://anilist.co/search?type=anime&q=" + anime.Title.Canonical
|
||||
},
|
||||
))
|
||||
)
|
||||
}
|
||||
|
@ -3,41 +3,18 @@ package filteranime
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
arn.SortAnimeByQuality(missing)
|
||||
|
||||
count := len(missing)
|
||||
|
||||
if count > maxGenreEntries {
|
||||
missing = missing[:maxGenreEntries]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AnimeEditorListFull(
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without genres",
|
||||
missing,
|
||||
count,
|
||||
ctx.URI(),
|
||||
func(anime *arn.Anime) bool {
|
||||
return len(anime.Genres) == 0
|
||||
},
|
||||
nil,
|
||||
))
|
||||
)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package filteranime
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
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 {
|
||||
year, _ := ctx.GetInt("year")
|
||||
animeType := ctx.Get("type")
|
||||
|
||||
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(
|
||||
return editorList(
|
||||
ctx,
|
||||
title,
|
||||
lowResAnime,
|
||||
count,
|
||||
ctx.URI(),
|
||||
func(anime *arn.Anime) bool {
|
||||
return anime.Image.Width < minExpectedWidth || anime.Image.Height < minExpectedHeight
|
||||
},
|
||||
googleImageSearch,
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
func googleImageSearch(anime *arn.Anime) string {
|
||||
|
20
pages/editor/filteranime/mal.go
Normal file
20
pages/editor/filteranime/mal.go
Normal 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
|
||||
},
|
||||
)
|
||||
}
|
@ -3,43 +3,20 @@ package filteranime
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
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") == ""
|
||||
})
|
||||
|
||||
arn.SortAnimeByQuality(missing)
|
||||
|
||||
count := len(missing)
|
||||
|
||||
if count > maxShoboiEntries {
|
||||
missing = missing[:maxShoboiEntries]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AnimeEditorListFull(
|
||||
return editorList(
|
||||
ctx,
|
||||
"Anime without Shoboi mappings",
|
||||
missing,
|
||||
count,
|
||||
ctx.URI(),
|
||||
func(anime *arn.Anime) bool {
|
||||
return anime.GetMapping("shoboi/anime") == ""
|
||||
},
|
||||
func(anime *arn.Anime) string {
|
||||
return "http://cal.syoboi.jp/find?type=quick&sd=1&kw=" + anime.Title.Japanese
|
||||
},
|
||||
))
|
||||
)
|
||||
}
|
||||
|
21
pages/editor/filteranime/startdate.go
Normal file
21
pages/editor/filteranime/startdate.go
Normal 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,
|
||||
)
|
||||
}
|
18
pages/editor/filteranime/synopsis.go
Normal file
18
pages/editor/filteranime/synopsis.go
Normal 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,
|
||||
)
|
||||
}
|
54
pages/editor/filteranime/utils.go
Normal file
54
pages/editor/filteranime/utils.go
Normal 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
|
||||
}
|
@ -249,33 +249,32 @@ func Configure(app *aero.Application) {
|
||||
l.Page("/editor", editor.Get)
|
||||
|
||||
// Editor - Anime
|
||||
l.Page("/editor/anime/missing/anilist", filteranime.AniList)
|
||||
l.Page("/editor/anime/missing/anilist/:year", filteranime.AniList)
|
||||
l.Page("/editor/anime/missing/anilist/:year/:type", filteranime.AniList)
|
||||
l.Page("/editor/anime/missing/shoboi", filteranime.Shoboi)
|
||||
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)
|
||||
l.Page("/editor/anime/missing/genres/:year", filteranime.Genres)
|
||||
l.Page("/editor/anime/missing/genres/:year/:type", filteranime.Genres)
|
||||
l.Page("/editor/anime/lowresimage", filteranime.LowResolutionAnimeImages)
|
||||
l.Page("/editor/anime/lowresimage/:year", filteranime.LowResolutionAnimeImages)
|
||||
l.Page("/editor/anime/lowresimage/:year/:type", filteranime.LowResolutionAnimeImages)
|
||||
l.Page("/editor/anime/ultralowresimage", filteranime.UltraLowResolutionAnimeImages)
|
||||
l.Page("/editor/anime/ultralowresimage/:year", filteranime.UltraLowResolutionAnimeImages)
|
||||
l.Page("/editor/anime/ultralowresimage/:year/:type", filteranime.UltraLowResolutionAnimeImages)
|
||||
editorList := func(route string, handler func(ctx *aero.Context) string) {
|
||||
l.Page(route, handler)
|
||||
l.Page(route+"/:year", handler)
|
||||
l.Page(route+"/:year/:type", handler)
|
||||
}
|
||||
|
||||
editorList("/editor/anime/synopsis", filteranime.Synopsis)
|
||||
editorList("/editor/anime/genres", filteranime.Genres)
|
||||
editorList("/editor/anime/startdate", filteranime.StartDate)
|
||||
editorList("/editor/anime/mapping/shoboi", filteranime.Shoboi)
|
||||
editorList("/editor/anime/mapping/anilist", filteranime.AniList)
|
||||
editorList("/editor/anime/mapping/mal", filteranime.MAL)
|
||||
editorList("/editor/anime/image/lowres", filteranime.LowResolutionAnimeImages)
|
||||
editorList("/editor/anime/image/ultralowres", filteranime.UltraLowResolutionAnimeImages)
|
||||
|
||||
// Editor - MALdiff
|
||||
l.Page("/editor/anime/maldiff", editor.CompareMAL)
|
||||
l.Page("/editor/anime/maldiff/:year", editor.CompareMAL)
|
||||
l.Page("/editor/anime/maldiff/:year/:status", editor.CompareMAL)
|
||||
l.Page("/editor/anime/maldiff/:year/:status/:type", editor.CompareMAL)
|
||||
l.Page("/editor/maldiff/anime", editor.CompareMAL)
|
||||
l.Page("/editor/maldiff/anime/:year", editor.CompareMAL)
|
||||
l.Page("/editor/maldiff/anime/:year/:status", editor.CompareMAL)
|
||||
l.Page("/editor/maldiff/anime/:year/:status/:type", editor.CompareMAL)
|
||||
|
||||
// Editor - Kitsu
|
||||
l.Page("/editor/anime/kitsu/new", editor.NewKitsuAnime)
|
||||
l.Page("/editor/kitsu/new/anime", editor.NewKitsuAnime)
|
||||
|
||||
// Editor - Companies
|
||||
l.Page("/editor/companies/missing/description", filtercompanies.NoDescription)
|
||||
l.Page("/editor/companies/description", filtercompanies.NoDescription)
|
||||
|
||||
// Log
|
||||
l.Page("/log", editlog.Get)
|
||||
|
Loading…
Reference in New Issue
Block a user