Improved explore page

This commit is contained in:
Eduard Urbach 2017-11-12 11:18:16 +01:00
parent 54193978fe
commit d17376e5a7
8 changed files with 34 additions and 38 deletions

View File

@ -1,5 +1,6 @@
component AnimeGrid(animeList []*arn.Anime) component AnimeGrid(animeList []*arn.Anime, user *arn.User)
.anime-grid .anime-grid
each anime in animeList each anime in animeList
a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID)) a.anime-grid-cell.ajax(href="/anime/" + toString(anime.ID))
img.anime-grid-image.lazy(data-src=anime.Image("medium"), data-webp="true", alt=anime.Title.Romaji, title=anime.Title.Romaji) img.anime-grid-image.lazy(data-src=anime.Image("medium"), data-webp="true", alt=anime.Title.Romaji)
p.anime-grid-title= anime.Title.ByUser(user)

View File

@ -1,13 +0,0 @@
package best
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
)
const maxEntries = 7
// Get search page.
func Get(ctx *aero.Context) string {
return ctx.HTML(components.BestAnime(nil, nil, nil, nil, nil))
}

View File

@ -1,15 +0,0 @@
component BestAnime(overall []*arn.Anime, story []*arn.Anime, visuals []*arn.Anime, soundtrack []*arn.Anime, airing []*arn.Anime)
h2 Currently Airing
AnimeGrid(airing)
h2 Best Overall
AnimeGrid(overall)
h2 Best Story
AnimeGrid(story)
h2 Best Visuals
AnimeGrid(visuals)
h2 Best Soundtrack
AnimeGrid(soundtrack)

View File

@ -7,6 +7,7 @@ import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
) )
const ( const (
@ -26,8 +27,9 @@ func Get(ctx *aero.Context) string {
status := "current" status := "current"
typ := "tv" typ := "tv"
results := filterAnime(year, status, typ) results := filterAnime(year, status, typ)
user := utils.GetUser(ctx)
return ctx.HTML(components.ExploreAnime(results, year, status, typ)) return ctx.HTML(components.ExploreAnime(results, year, status, typ, user))
} }
// Filter ... // Filter ...
@ -35,10 +37,11 @@ func Filter(ctx *aero.Context) string {
year := ctx.Get("year") year := ctx.Get("year")
status := ctx.Get("status") status := ctx.Get("status")
typ := ctx.Get("type") typ := ctx.Get("type")
user := utils.GetUser(ctx)
results := filterAnime(year, status, typ) results := filterAnime(year, status, typ)
return ctx.HTML(components.ExploreAnime(results, year, status, typ)) return ctx.HTML(components.ExploreAnime(results, year, status, typ, user))
} }
func filterAnime(year, status, typ string) []*arn.Anime { func filterAnime(year, status, typ string) []*arn.Anime {

View File

@ -1,4 +1,4 @@
component ExploreAnime(animeList []*arn.Anime, year string, status string, typ string) component ExploreAnime(animeList []*arn.Anime, year string, status string, typ string, user *arn.User)
ExploreFilters(year, status, typ) ExploreFilters(year, status, typ)
h1.page-title Explore h1.page-title Explore
@ -6,7 +6,7 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s
if len(animeList) == 0 if len(animeList) == 0
p.no-data.mountable No anime found using the above filters. p.no-data.mountable No anime found using the above filters.
else else
AnimeGrid(animeList) AnimeGrid(animeList, user)
component ExploreFilters(year string, status string, typ string) component ExploreFilters(year string, status string, typ string)
.explore-filters .explore-filters

View File

@ -4,10 +4,12 @@ import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
) )
// Get ... // Get ...
func Get(ctx *aero.Context) string { func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
genreName := ctx.Get("name") genreName := ctx.Get("name")
genre, err := arn.GetGenre(genreName) genre, err := arn.GetGenre(genreName)
@ -15,5 +17,5 @@ func Get(ctx *aero.Context) string {
return ctx.Error(404, "Genre not found", err) return ctx.Error(404, "Genre not found", err)
} }
return ctx.HTML(components.Genre(genre)) return ctx.HTML(components.Genre(genre, user))
} }

View File

@ -1,3 +1,3 @@
component Genre(genre *arn.Genre) component Genre(genre *arn.Genre, user *arn.User)
h2(title=toString(len(genre.AnimeList)) + " anime")= arn.Capitalize(genre.ID) h2(title=toString(len(genre.AnimeList)) + " anime")= arn.Capitalize(genre.ID)
AnimeGrid(genre.AnimeList) AnimeGrid(genre.AnimeList, user)

View File

@ -6,5 +6,23 @@
saturate-up saturate-up
shadow-up shadow-up
:hover
.anime-grid-title
opacity 1
.anime-grid-image .anime-grid-image
grid-image grid-image
.anime-grid-title
opacity 0
position absolute
bottom 0
left 0
width 100%
padding 0.5rem
font-size 90%
text-align center
background linear-gradient(to top, hsla(0, 0%, 0%, 0.5), hsla(0, 0%, 0%, 0))
color white
text-shadow 0 0 3px black
transition opacity transition-speed ease