Added 'appears in amv' info on anime pages

This commit is contained in:
Eduard Urbach 2018-04-15 16:12:24 +02:00
parent 824fe83eb8
commit b49496fe16
2 changed files with 28 additions and 9 deletions

View File

@ -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))
}

View File

@ -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)