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 .sound-tracks
each track in tracks each track in tracks
.sound-track(id=track.ID) SoundTrack(track)
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") component SoundTrack(track *arn.SoundTrack)
.sound-track-footer .sound-track(id=track.ID)
span posted by a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick 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 maxPosts = 5
const maxTracks = 5
// Get user profile page. // Get user profile page.
func Get(ctx *aero.Context) string { func Get(ctx *aero.Context) string {
@ -27,6 +28,7 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
var user *arn.User var user *arn.User
var threads []*arn.Thread var threads []*arn.Thread
var animeList *arn.AnimeList var animeList *arn.AnimeList
var tracks []*arn.SoundTrack
var posts []*arn.Post var posts []*arn.Post
flow.Parallel(func() { flow.Parallel(func() {
@ -48,7 +50,14 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
if len(posts) > maxPosts { if len(posts) > maxPosts {
posts = 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") Icon("rocket")
span= arn.Capitalize(viewUser.Role) 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) ProfileHeader(viewUser, user)
.profile-category.mountable .profile-category.mountable
@ -68,6 +68,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
else else
each thread in threads each thread in threads
ThreadLink(thread) ThreadLink(thread)
.profile-category.mountable .profile-category.mountable
h3 h3
a.ajax(href="/+" + viewUser.Nick + "/posts", title="View all posts") Posts 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 .spacer
.post-likes= len(post.Likes) .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" //- if user != nil && user.Role == "admin"
//- .footer //- .footer
//- a(href="/api/user/" + viewUser.ID) User API //- a(href="/api/user/" + viewUser.ID) User API