{ strconv.FormatInt(u.Playlists, 10) } playlists & albums
Created: { u.CreatedAt }
Last modified: { u.LastModified }
}
type btn struct {
text string
href string
external bool
}
templ UserButtons(current string, user string) {
// this part is the tedious one now, because formatting breaks if i space the list out with newlines
for _, b := range [...]btn{{"tracks", "", false},{"popular tracks", "/popular-tracks", false},{"playlists", "/sets",false},{"albums", "/albums", false},{"reposts","/reposts", false},{"related", "/_/related", false},{"view on soundcloud", "https://soundcloud.com/"+user, true}} {
if b.text == current {
{ b.text }
} else {
if b.external {
{ b.text }
} else {
{ b.text }
}
}
}
}
templ User(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Track]) {
@UserBase(prefs, u)
// kinda tedious but whatever, might make it more flexible in the future
// ^ outdated, no longer tedious but whatever
@UserButtons("tracks", u.Permalink)
if len(p.Collection) != 0 {
for _, track := range p.Collection {
@TrackItem(track, false, "")
}
if p.Next != "" && len(p.Collection) != int(u.Tracks) {
more tracks
}
} else {
no more tracks
}
}
templ UserPlaylists(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Playlist]) {
@UserBase(prefs, u)
@UserButtons("playlists", u.Permalink)
if len(p.Collection) != 0 {
for _, playlist := range p.Collection {
@PlaylistItem(playlist, false)
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more playlists
}
} else {
no more playlists
}
}
templ UserAlbums(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Playlist]) {
@UserBase(prefs, u)
@UserButtons("albums", u.Permalink)
if len(p.Collection) != 0 {
for _, playlist := range p.Collection {
@PlaylistItem(playlist, false)
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more albums
}
} else {
no more albums
}
}
templ UserReposts(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Repost]) {
@UserBase(prefs, u)
@UserButtons("reposts", u.Permalink)
if len(p.Collection) != 0 {
for _, repost := range p.Collection {
if repost.Type == sc.TrackRepost && repost.Track != nil {
@TrackItem(repost.Track, true, "")
} else if repost.Type == sc.PlaylistRepost && repost.Playlist != nil {
@PlaylistItem(repost.Playlist, true)
}
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more reposts
}
} else {
no more reposts
}
}
templ UserLikes(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Like]) {
@UserBase(prefs, u)
@UserButtons("", u.Permalink)
Likes
if len(p.Collection) != 0 {
for _, like := range p.Collection {
if like.Track != nil {
@TrackItem(like.Track, true, "")
} else if like.Playlist != nil {
@PlaylistItem(like.Playlist, true)
}
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more likes
}
} else {
no more likes
}
}
templ UserRelated(prefs cfg.Preferences, u sc.User, r []*sc.User) {
@UserBase(prefs, u)
@UserButtons("related", u.Permalink)
if len(r) != 0 {
for _, u := range r {
@UserItem(u)
}
} else {
no related users
}
}
templ UserTopTracks(prefs cfg.Preferences, u sc.User, t []*sc.Track) {
@UserBase(prefs, u)
@UserButtons("popular tracks", u.Permalink)
if len(t) != 0 {
for _, track := range t {
@TrackItem(track, false, "")
}
} else {
no popular tracks
}
}
templ UserFollowers(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.User]) {
@UserBase(prefs, u)
@UserButtons("", u.Permalink)
Followers
if len(p.Collection) != 0 {
for _, user := range p.Collection {
@UserItem(user)
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more users
}
} else {
no more users
}
}
templ UserFollowing(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.User]) {
@UserBase(prefs, u)
@UserButtons("", u.Permalink)
Following
if len(p.Collection) != 0 {
for _, user := range p.Collection {
@UserItem(user)
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more users
}
} else {
no more users
}
}
templ SearchUsers(p *sc.Paginated[*sc.User]) {
Found { strconv.FormatInt(p.Total, 10) } users
if len(p.Collection) == 0 {
if p.Total != 0 {
no more results
}
} else {
for _, user := range p.Collection {
@UserItem(user)
}
if p.Next != "" && len(p.Collection) != int(p.Total) {
more users
}
}
}