Genre flipcards

This commit is contained in:
Eduard Urbach 2016-11-20 04:53:33 +09:00
parent fbcef9008d
commit 76fee33c7d
4 changed files with 28 additions and 12 deletions

View File

@ -41,7 +41,7 @@ component Anime(anime *arn.Anime)
.light-button-group .light-button-group
each genre in anime.Genres each genre in anime.Genres
if genre != "" if genre != ""
a.light-button.ajax(href="/genres/" + arn.FixGenre(genre)) a.light-button.ajax(href="/genres/" + arn.GetGenreIDByName(genre))
Icon(arn.GetGenreIcon(genre)) Icon(arn.GetGenreIcon(genre))
span= genre span= genre

View File

@ -9,13 +9,11 @@ import (
// Get ... // Get ...
func Get(ctx *aero.Context) string { func Get(ctx *aero.Context) string {
genreName := ctx.Get("name") genreName := ctx.Get("name")
genreInfo := new(arn.Genre) genre, err := arn.GetGenre(genreName)
err := arn.GetObject("Genres", genreName, genreInfo)
if err != nil { if err != nil {
return err.Error() return err.Error()
} }
return ctx.HTML(components.Genre(genreInfo.Genre, genreInfo.AnimeList)) return ctx.HTML(components.Genre(genre.Name, genre.AnimeList))
} }

View File

@ -1,11 +1,27 @@
package genres package genres
import ( import (
"fmt"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
) )
// Get ... // Get ...
func Get(ctx *aero.Context) string { func Get(ctx *aero.Context) string {
return ctx.HTML(components.Genres()) var genres []*arn.Genre
for _, genreName := range arn.Genres {
genre, err := arn.GetGenre(arn.GetGenreIDByName(genreName))
if err == nil {
genre.Name = genreName
genres = append(genres, genre)
} else {
fmt.Println(err)
}
}
return ctx.HTML(components.Genres(genres))
} }

View File

@ -1,10 +1,12 @@
component Genres component Genres(genres []*arn.Genre)
h2 Genres h2 Genres
.grid .grid
each genre in arn.Genres each genre in genres
a.grid-cell.backside-card.ajax(href="/genres/" + arn.FixGenre(genre)) a.grid-cell.backside-card.ajax(href="/genres/" + genre.ID)
.grid-text.front .grid-text.front
GridIcon(arn.GetGenreIcon(genre)) GridIcon(arn.GetGenreIcon(genre.Name))
span= genre span= genre.Name
img.grid-image.back(src="https://cdn.anilist.co/img/dir/anime/reg/21519-4I676N0vzuek.jpg", alt="")
if len(genre.AnimeList) > 0
img.grid-image.back(src=genre.AnimeList[0].Image, alt=genre.AnimeList[0].Title.Romaji)