diff --git a/pages/editor/editor.pixy b/pages/editor/editor.pixy index 6dde5f0a..de5bb054 100644 --- a/pages/editor/editor.pixy +++ b/pages/editor/editor.pixy @@ -12,6 +12,7 @@ component EditorTabs(url string) .tabs Tab("Editor", "pencil", "/editor") Tab("MAL", "exchange", "/editor/anime/maldiff") + Tab("Kitsu", "exchange", "/editor/anime/kitsu/new") Tab("Missing", "list", "/editor/anime/missing/shoboi") Tab("Search", "search", "/database") diff --git a/pages/editor/kitsu.go b/pages/editor/kitsu.go new file mode 100644 index 00000000..b783f11d --- /dev/null +++ b/pages/editor/kitsu.go @@ -0,0 +1,30 @@ +package editor + +import ( + "sort" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/kitsu" + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" +) + +// NewKitsuAnime ... +func NewKitsuAnime(ctx *aero.Context) string { + user := utils.GetUser(ctx) + + animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool { + _, err := arn.GetAnime(anime.ID) + return err != nil + }) + + sort.Slice(animes, func(i, j int) bool { + a := animes[i] + b := animes[j] + + return a.ID > b.ID + }) + + return ctx.HTML(components.NewKitsuAnime(animes, ctx.URI(), user)) +} diff --git a/pages/editor/kitsu.pixy b/pages/editor/kitsu.pixy new file mode 100644 index 00000000..77370727 --- /dev/null +++ b/pages/editor/kitsu.pixy @@ -0,0 +1,28 @@ +component NewKitsuAnime(animes []*kitsu.Anime, url string, user *arn.User) + EditorTabs(url) + h1.mountable New anime on Kitsu + + if len(animes) == 0 + p.text-center.mountable No new anime found. + else + table + thead + tr.mountable + th ID + th Image + th Title + th Type + th Year + tbody + each anime in animes + tr.mountable + td= anime.ID + td + a(href="https://kitsu.io/anime/" + anime.ID, target="_blank") + img.profile-watching-list-item-image(src=anime.Attributes.PosterImage.Tiny, alt=anime.Attributes.CanonicalTitle) + td + a(href="https://kitsu.io/anime/" + anime.ID, target="_blank")= anime.Attributes.CanonicalTitle + td= anime.Attributes.ShowType + td + if len(anime.Attributes.StartDate) >= 4 + span= anime.Attributes.StartDate[:4] \ No newline at end of file diff --git a/pages/index.go b/pages/index.go index 2bc63bf5..57c51a74 100644 --- a/pages/index.go +++ b/pages/index.go @@ -239,6 +239,7 @@ func Configure(app *aero.Application) { 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/anime/kitsu/new", editor.NewKitsuAnime) // Log l.Page("/log", editlog.Get)