diff --git a/layout/layout.pixy b/layout/layout.pixy index c4f4b889..445bf3a0 100644 --- a/layout/layout.pixy +++ b/layout/layout.pixy @@ -27,6 +27,7 @@ component Navigation NavigationButton("Anime", "/anime", "television") NavigationButton("Forum", "/forum", "comment") NavigationButton("Genres", "/genres", "tags") + NavigationButton("Airing", "/airing", "rss") component NavigationButton(name string, target string, icon string) a.navigation-link.navigation-link-left.ajax(href=target) diff --git a/main.go b/main.go index 8b2bef4e..f1ec23dc 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/pages/airing" "github.com/animenotifier/notify.moe/pages/anime" "github.com/animenotifier/notify.moe/pages/dashboard" "github.com/animenotifier/notify.moe/pages/forum" @@ -55,6 +56,7 @@ func main() { app.Ajax("/threads/:id", threads.Get) app.Ajax("/posts/:id", posts.Get) app.Ajax("/user/:nick", profile.Get) + app.Ajax("/airing", airing.Get) app.Run() } diff --git a/mixins/AnimeGrid.pixy b/mixins/AnimeGrid.pixy new file mode 100644 index 00000000..8b080e76 --- /dev/null +++ b/mixins/AnimeGrid.pixy @@ -0,0 +1,5 @@ +component AnimeGrid(animeList []*arn.Anime) + .grid + each anime in animeList + a.grid-cell.grid-anime.ajax(href="/anime/" + toString(anime.ID)) + img.anime-image.grid-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching) + ")") \ No newline at end of file diff --git a/pages/airing/airing.go b/pages/airing/airing.go new file mode 100644 index 00000000..fb6bd774 --- /dev/null +++ b/pages/airing/airing.go @@ -0,0 +1,29 @@ +package airing + +import ( + "sort" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" +) + +// Get ... +func Get(ctx *aero.Context) string { + var animeList []*arn.Anime + + scan := make(chan *arn.Anime) + arn.Scan("Anime", scan) + + for anime := range scan { + if anime.AiringStatus != "currently airing" || anime.Adult { + continue + } + + animeList = append(animeList, anime) + } + + sort.Sort(arn.AnimeByPopularity(animeList)) + + return ctx.HTML(components.Airing(animeList)) +} diff --git a/pages/airing/airing.pixy b/pages/airing/airing.pixy new file mode 100644 index 00000000..ba4373e3 --- /dev/null +++ b/pages/airing/airing.pixy @@ -0,0 +1,3 @@ +component Airing(animeList []*arn.Anime) + h2 Airing + AnimeGrid(animeList) \ No newline at end of file diff --git a/pages/genre/genre.pixy b/pages/genre/genre.pixy index f6a8e703..ee8fd3a1 100644 --- a/pages/genre/genre.pixy +++ b/pages/genre/genre.pixy @@ -1,6 +1,3 @@ component Genre(genre *arn.Genre) h2= arn.Capitalize(genre.ID) - .grid - each anime in genre.AnimeList - a.grid-cell.grid-anime.ajax(href="/anime/" + toString(anime.ID)) - img.anime-image.grid-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching) + ")") \ No newline at end of file + AnimeGrid(genre.AnimeList) \ No newline at end of file