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)
|
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 := ctx.(*middleware.OpenGraphContext)
|
||||||
customCtx.OpenGraph = getOpenGraph(track)
|
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)
|
SoundTrackTabs(track, user)
|
||||||
|
|
||||||
.soundtrack-full-page
|
.soundtrack-full-page
|
||||||
@ -37,6 +37,13 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
|
|||||||
li
|
li
|
||||||
a.soundtrack-link(href=link.URL, target="_blank")= link.Title
|
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
|
//- TODO: This is quite ineffective, performance-wise
|
||||||
if len(track.OsuBeatmaps()) > 0 || len(track.EtternaBeatmaps()) > 0
|
if len(track.OsuBeatmaps()) > 0 || len(track.EtternaBeatmaps()) > 0
|
||||||
.widget.mountable
|
.widget.mountable
|
||||||
|
Loading…
Reference in New Issue
Block a user