Added list of all tracks by one user
This commit is contained in:
parent
9ce39df2eb
commit
c1765a23ea
1
main.go
1
main.go
@ -65,6 +65,7 @@ func configure(app *aero.Application) *aero.Application {
|
|||||||
app.Ajax("/user/:nick", profile.Get)
|
app.Ajax("/user/:nick", profile.Get)
|
||||||
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
|
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
|
||||||
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
|
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
|
||||||
|
app.Ajax("/user/:nick/tracks", profile.GetSoundTracksByUser)
|
||||||
app.Ajax("/user/:nick/animelist", animelist.Get)
|
app.Ajax("/user/:nick/animelist", animelist.Get)
|
||||||
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
|
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
|
||||||
app.Ajax("/new/thread", newthread.Get)
|
app.Ajax("/new/thread", newthread.Get)
|
||||||
|
@ -86,7 +86,8 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
|||||||
.post-likes= len(post.Likes)
|
.post-likes= len(post.Likes)
|
||||||
|
|
||||||
.profile-category.mountable
|
.profile-category.mountable
|
||||||
h3 Tracks
|
h3
|
||||||
|
a.ajax(href="/+" + viewUser.Nick + "/tracks", title="View all tracks") Tracks
|
||||||
|
|
||||||
if len(tracks) == 0
|
if len(tracks) == 0
|
||||||
p No soundtracks posted yet.
|
p No soundtracks posted yet.
|
||||||
|
32
pages/profile/tracks.go
Normal file
32
pages/profile/tracks.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package profile
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetSoundTracksByUser shows all soundtracks of a particular user.
|
||||||
|
func GetSoundTracksByUser(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, err := arn.GetSoundTracksByUser(viewUser)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusInternalServerError, "Error fetching soundtracks", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
arn.SortSoundTracksLatestFirst(tracks)
|
||||||
|
|
||||||
|
return ctx.HTML(components.TrackList(tracks, viewUser, user))
|
||||||
|
|
||||||
|
}
|
6
pages/profile/tracks.pixy
Normal file
6
pages/profile/tracks.pixy
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
component TrackList(tracks []*arn.SoundTrack, viewUser *arn.User, user *arn.User)
|
||||||
|
h2= "Tracks added by " + viewUser.Nick
|
||||||
|
.sound-tracks
|
||||||
|
each track in tracks
|
||||||
|
SoundTrack(track)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user