From b49496fe16d20c4bde709b0f787dd55d6a89be2d Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 15 Apr 2018 16:12:24 +0200 Subject: [PATCH] Added 'appears in amv' info on anime pages --- pages/anime/anime.go | 19 +++++++++++++++---- pages/anime/anime.pixy | 18 +++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pages/anime/anime.go b/pages/anime/anime.go index adc1a2e0..0b34a65d 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -75,9 +75,20 @@ func Get(ctx *aero.Context) string { }) // AMVs - amvs := arn.FilterAMVs(func(track *arn.AMV) bool { - return !track.IsDraft && track.MainAnimeID == anime.ID - }) + amvs := []*arn.AMV{} + amvAppearances := []*arn.AMV{} + + for amv := range arn.StreamAMVs() { + if amv.IsDraft { + continue + } + + if amv.MainAnimeID == anime.ID { + amvs = append(amvs, amv) + } else if arn.Contains(amv.ExtraAnimeIDs, anime.ID) { + amvAppearances = append(amvAppearances, amv) + } + } sort.Slice(amvs, func(i, j int) bool { if len(amvs[i].Likes) == len(amvs[j].Likes) { @@ -124,5 +135,5 @@ func Get(ctx *aero.Context) string { ctx.Data = openGraph - return ctx.HTML(components.Anime(anime, animeListItem, tracks, amvs, episodes, friends, friendsAnimeListItems, user)) + return ctx.HTML(components.Anime(anime, animeListItem, tracks, amvs, amvAppearances, episodes, friends, friendsAnimeListItems, user)) } diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 28be5cc6..84c7702e 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -1,11 +1,11 @@ -component Anime(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, amvs []*arn.AMV, episodes []*arn.AnimeEpisode, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) +component Anime(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, amvs []*arn.AMV, amvAppearances []*arn.AMV, episodes []*arn.AnimeEpisode, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) .anime .anime-main-column - AnimeMainColumn(anime, listItem, tracks, amvs, episodes, user) + AnimeMainColumn(anime, listItem, tracks, amvs, amvAppearances, episodes, user) .anime-side-column AnimeSideColumn(anime, friends, listItems, user) -component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, amvs []*arn.AMV, episodes []*arn.AnimeEpisode, user *arn.User) +component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, amvs []*arn.AMV, amvAppearances []*arn.AMV, episodes []*arn.AnimeEpisode, user *arn.User) .anime-header(data-id=anime.ID) a.anime-image-container.mountable(href=anime.ImageLink("original"), target="_blank") img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user)) @@ -28,10 +28,10 @@ component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks AnimeCharacters(anime, user, false) AnimeRelations(anime, user, false) AnimeTracks(anime, tracks, user, false) - AnimeAMVs(anime, amvs, user) + AnimeAMVs(anime, amvs, amvAppearances, user) AnimeEpisodes(anime, episodes, user, false) -component AnimeAMVs(anime *arn.Anime, amvs []*arn.AMV, user *arn.User) +component AnimeAMVs(anime *arn.Anime, amvs []*arn.AMV, amvAppearances []*arn.AMV, user *arn.User) if len(amvs) > 0 section.anime-section.mountable h3.anime-section-name AMVs @@ -39,6 +39,14 @@ component AnimeAMVs(anime *arn.Anime, amvs []*arn.AMV, user *arn.User) .amvs each amv in amvs AMV(amv, user) + + if len(amvAppearances) > 0 + section.anime-section.mountable + h3.anime-section-name Appears in AMVs + + .amvs + each amv in amvAppearances + AMV(amv, user) component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) AnimeTrailer(anime)