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
each genre in anime.Genres
if genre != ""
a.light-button.ajax(href="/genres/" + arn.FixGenre(genre))
a.light-button.ajax(href="/genres/" + arn.GetGenreIDByName(genre))
Icon(arn.GetGenreIcon(genre))
span= genre

View File

@ -9,13 +9,11 @@ import (
// Get ...
func Get(ctx *aero.Context) string {
genreName := ctx.Get("name")
genreInfo := new(arn.Genre)
err := arn.GetObject("Genres", genreName, genreInfo)
genre, err := arn.GetGenre(genreName)
if err != nil {
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
import (
"fmt"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// Get ...
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
.grid
each genre in arn.Genres
a.grid-cell.backside-card.ajax(href="/genres/" + arn.FixGenre(genre))
each genre in genres
a.grid-cell.backside-card.ajax(href="/genres/" + genre.ID)
.grid-text.front
GridIcon(arn.GetGenreIcon(genre))
span= genre
img.grid-image.back(src="https://cdn.anilist.co/img/dir/anime/reg/21519-4I676N0vzuek.jpg", alt="")
GridIcon(arn.GetGenreIcon(genre.Name))
span= genre.Name
if len(genre.AnimeList) > 0
img.grid-image.back(src=genre.AnimeList[0].Image, alt=genre.AnimeList[0].Title.Romaji)