Merge pull request #247 from youssefhabri/add-related-soundtracks
Add related soundtracks to soundtrack page
This commit is contained in:
commit
86d990f761
@ -19,7 +19,21 @@ func Get(ctx aero.Context) error {
|
||||
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
||||
}
|
||||
|
||||
relatedTracks := arn.FilterSoundTracks(func(t *arn.SoundTrack) bool {
|
||||
return !t.IsDraft && len(t.Media) > 0 && t.ID != track.ID && isRelated(track.Anime(), t)
|
||||
})
|
||||
|
||||
customCtx := ctx.(*middleware.OpenGraphContext)
|
||||
customCtx.OpenGraph = getOpenGraph(track)
|
||||
return ctx.HTML(components.SoundTrackPage(track, user))
|
||||
return ctx.HTML(components.SoundTrackPage(track, relatedTracks, user))
|
||||
}
|
||||
|
||||
func isRelated(anime []*arn.Anime, track *arn.SoundTrack) bool {
|
||||
for _, anime := range anime {
|
||||
if arn.Contains(track.Tags, "anime:"+anime.ID) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
|
||||
component SoundTrackPage(track *arn.SoundTrack, relatedTracks []*arn.SoundTrack, user *arn.User)
|
||||
SoundTrackTabs(track, user)
|
||||
|
||||
.soundtrack-full-page
|
||||
@ -37,6 +37,13 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
|
||||
li
|
||||
a.soundtrack-link(href=link.URL, target="_blank")= link.Title
|
||||
|
||||
if len(relatedTracks) > 0
|
||||
.widget.mountable
|
||||
h3.widget-title Related
|
||||
.soundtracks.anime-soundtracks
|
||||
each relatedTrack in relatedTracks
|
||||
SoundTrackMini(relatedTrack, user)
|
||||
|
||||
//- TODO: This is quite ineffective, performance-wise
|
||||
if len(track.OsuBeatmaps()) > 0 || len(track.EtternaBeatmaps()) > 0
|
||||
.widget.mountable
|
||||
|
Loading…
Reference in New Issue
Block a user