diff --git a/pages/index.go b/pages/index.go index b03afe35..effb57fe 100644 --- a/pages/index.go +++ b/pages/index.go @@ -169,7 +169,8 @@ func Configure(app *aero.Application) { l.Page("/user/:nick", profile.Get) l.Page("/user/:nick/forum/threads", profile.GetThreadsByUser) l.Page("/user/:nick/forum/posts", profile.GetPostsByUser) - l.Page("/user/:nick/soundtracks", profile.GetSoundTracksByUser) + l.Page("/user/:nick/soundtracks/added", profile.GetSoundTracksByUser) + l.Page("/user/:nick/soundtracks/liked", profile.GetSoundTracksLikedByUser) l.Page("/user/:nick/stats", profile.GetStatsByUser) l.Page("/user/:nick/followers", profile.GetFollowers) l.Page("/user/:nick/animelist", animelist.Get) diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index 27f5ca61..c5765fe7 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -26,12 +26,16 @@ component ProfileTabs(viewUser *arn.User, uri string) Tab("Anime", "th", "/+" + viewUser.Nick) Tab("Collection", "list", "/+" + viewUser.Nick + "/animelist/watching") Tab("Forum", "comment", "/+" + viewUser.Nick + "/forum/threads") - Tab("Tracks", "music", "/+" + viewUser.Nick + "/soundtracks") + Tab("Tracks", "music", "/+" + viewUser.Nick + "/soundtracks/added") Tab("Stats", "area-chart", "/+" + viewUser.Nick + "/stats") Tab("Followers", "users", "/+" + viewUser.Nick + "/followers") if strings.Contains(uri, "/animelist") StatusTabs("/+" + viewUser.Nick + "/animelist") + if strings.Contains(uri, "/soundtracks") + .tabs + Tab("Added", "music", "/+" + viewUser.Nick + "/soundtracks/added") + Tab("Liked", "heart", "/+" + viewUser.Nick + "/soundtracks/liked") component ProfileHeader(viewUser *arn.User, user *arn.User, uri string) ProfileHead(viewUser, user, uri) diff --git a/pages/profile/tracks.go b/pages/profile/tracks.go index 29e270d4..2be2db8d 100644 --- a/pages/profile/tracks.go +++ b/pages/profile/tracks.go @@ -28,3 +28,23 @@ func GetSoundTracksByUser(ctx *aero.Context) string { return ctx.HTML(components.TrackList(tracks, viewUser, user, ctx.URI())) } + +// GetSoundTracksByUser shows all soundtracks of a particular user. +func GetSoundTracksLikedByUser(ctx *aero.Context) string { + nick := ctx.Get("nick") + user := utils.GetUser(ctx) + viewUser, err := arn.GetUserByNick(nick) + + if err != nil { + return ctx.Error(http.StatusNotFound, "User not found", err) + } + + tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool { + return !track.IsDraft && len(track.Media) > 0 && track.LikedBy(viewUser.ID) + }) + + arn.SortSoundTracksLatestFirst(tracks) + + return ctx.HTML(components.TrackList(tracks, viewUser, user, ctx.URI())) + +} diff --git a/tests.go b/tests.go index 3b1e4dde..f5a22f19 100644 --- a/tests.go +++ b/tests.go @@ -14,8 +14,12 @@ var routeTests = map[string][]string{ "/+Akyoto/forum/posts", }, - "/user/:nick/soundtracks": []string{ - "/+Akyoto/soundtracks", + "/user/:nick/soundtracks/added": []string{ + "/+Akyoto/soundtracks/added", + }, + + "/user/:nick/soundtracks/liked": []string{ + "/+Akyoto/soundtracks/liked", }, "/user/:nick/followers": []string{