Added the liked soundtracks

This commit is contained in:
Scott 2018-03-14 11:57:40 +01:00
parent b5efaf0bb1
commit df0b6abd68
4 changed files with 33 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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()))
}

View File

@ -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{