✨ Added the liked soundtracks
This commit is contained in:
parent
b5efaf0bb1
commit
df0b6abd68
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()))
|
||||
|
||||
}
|
||||
|
8
tests.go
8
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{
|
||||
|
Loading…
Reference in New Issue
Block a user