Added soundtracks to user profiles

This commit is contained in:
Eduard Urbach 2017-06-27 17:51:15 +02:00
parent 9463f1c13b
commit 8727ab63eb
3 changed files with 34 additions and 11 deletions

View File

@ -8,11 +8,14 @@ component Music(tracks []*arn.SoundTrack)
.sound-tracks
each track in tracks
.sound-track(id=track.ID)
a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
img.sound-track-anime-image.lazy(data-src=track.MainAnime().Image.Small, alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
iframe.lazy(data-src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/" + track.Media[0].ServiceID + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
.sound-track-footer
span posted by
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick
SoundTrack(track)
component SoundTrack(track *arn.SoundTrack)
.sound-track(id=track.ID)
a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
img.sound-track-anime-image.lazy(data-src=track.MainAnime().Image.Small, alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
iframe.lazy(data-src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/" + track.Media[0].ServiceID + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
.sound-track-footer
span posted by
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick

View File

@ -9,6 +9,7 @@ import (
)
const maxPosts = 5
const maxTracks = 5
// Get user profile page.
func Get(ctx *aero.Context) string {
@ -27,6 +28,7 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
var user *arn.User
var threads []*arn.Thread
var animeList *arn.AnimeList
var tracks []*arn.SoundTrack
var posts []*arn.Post
flow.Parallel(func() {
@ -48,7 +50,14 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
if len(posts) > maxPosts {
posts = posts[:maxPosts]
}
}, func() {
tracks = viewUser.SoundTracks()
arn.SortSoundTracksLatestFirst(tracks)
if len(tracks) > maxTracks {
tracks = tracks[:maxTracks]
}
})
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts))
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts, tracks))
}

View File

@ -44,7 +44,7 @@ component ProfileHeader(viewUser *arn.User, user *arn.User)
Icon("rocket")
span= arn.Capitalize(viewUser.Role)
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post)
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post, tracks []*arn.SoundTrack)
ProfileHeader(viewUser, user)
.profile-category.mountable
@ -58,7 +58,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
each item in animeList.Items
a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.Canonical + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
img.anime-cover-image.profile-watching-list-item-image.lazy(data-src=item.Anime().Image.Tiny, alt=item.Anime().Title.Canonical)
.profile-category.mountable
h3
a.ajax(href="/+" + viewUser.Nick + "/threads", title="View all threads") Threads
@ -68,6 +68,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
else
each thread in threads
ThreadLink(thread)
.profile-category.mountable
h3
a.ajax(href="/+" + viewUser.Nick + "/posts", title="View all posts") Posts
@ -84,6 +85,16 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
.spacer
.post-likes= len(post.Likes)
.profile-category.mountable
h3 Tracks
if len(tracks) == 0
p No soundtracks posted yet.
else
.sound-tracks
each track in tracks
SoundTrack(track)
//- if user != nil && user.Role == "admin"
//- .footer
//- a(href="/api/user/" + viewUser.ID) User API