diff --git a/layout/sidebar/sidebar.pixy b/layout/sidebar/sidebar.pixy index bd2dcd71..eb892f4a 100644 --- a/layout/sidebar/sidebar.pixy +++ b/layout/sidebar/sidebar.pixy @@ -16,10 +16,11 @@ component Sidebar(user *arn.User) SidebarButton("Forum", "/forum", "comment") SidebarButton("Explore", "/explore", "th") SidebarButton("Calendar", "/calendar", "calendar") + SidebarButton("Genres", "/genres", "clone") SidebarButton("Soundtracks", "/soundtracks", "headphones") if user != nil && user.Role == "admin" - SidebarButton("Companies", "/companies", "building") + SidebarButton("Users", "/users", "globe") @@ -34,6 +35,7 @@ component Sidebar(user *arn.User) //- SidebarButton("Games", "/games", "gamepad") //- SidebarButton("Groups", "/groups", "users") //- SidebarButton("Statistics", "/statistics", "pie-chart") + //- SidebarButton("Companies", "/companies", "building") .spacer diff --git a/pages/genres/genres.go b/pages/genres/genres.go index dd482801..05c4e0e2 100644 --- a/pages/genres/genres.go +++ b/pages/genres/genres.go @@ -4,11 +4,14 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" ) // Get ... func Get(ctx *aero.Context) string { - var genres []string + user := utils.GetUser(ctx) + genres := []string{} + genreToAnime := map[string]*arn.Anime{} for _, genre := range arn.Genres { if genre == "Hentai" { @@ -18,5 +21,30 @@ func Get(ctx *aero.Context) string { genres = append(genres, genre) } - return ctx.HTML(components.Genres(genres)) + allAnime := arn.AllAnime() + arn.SortAnimeByQuality(allAnime, "") + + added := 0 + + for _, anime := range allAnime { + for _, genre := range anime.Genres { + // Skip genre that we don't care about + if !arn.Contains(genres, genre) { + continue + } + + _, exists := genreToAnime[genre] + + if !exists { + genreToAnime[genre] = anime + added++ + } + } + + if added >= len(genres) { + break + } + } + + return ctx.HTML(components.Genres(genres, genreToAnime, user)) } diff --git a/pages/genres/genres.pixy b/pages/genres/genres.pixy index ab196db1..49926f4c 100644 --- a/pages/genres/genres.pixy +++ b/pages/genres/genres.pixy @@ -1,13 +1,12 @@ -component Genres(genres []string) +component Genres(genres []string, genreToAnime map[string]*arn.Anime, user *arn.User) h1 Genres .genres each genre in genres - a.genre.ajax(href="/genre/" + strings.ToLower(genre)) + a.genre.mountable.ajax(href="/genre/" + strings.ToLower(genre)) .genre-text.front .genre-icon RawIcon(arn.GetGenreIcon(genre)) span= genre - //- if len(genre.AnimeList) > 0 - //- img.genre-image.back(src=genre.AnimeList[0].Image, alt=genre.AnimeList[0].Title.Romaji, title=genre.AnimeList[0].Title.Romaji + "\n" + genre.Name + " #1") \ No newline at end of file + img.genre-image.back(src=genreToAnime[genre].Image("medium"), alt=genreToAnime[genre].Title.ByUser(user), title=genre) \ No newline at end of file