mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-01-01 16:39:37 +05:00
180 lines
6.0 KiB
Plaintext
180 lines
6.0 KiB
Plaintext
package templates
|
|
|
|
import (
|
|
"github.com/maid-zone/soundcloak/lib/sc"
|
|
"net/url"
|
|
"strconv"
|
|
"strings"
|
|
"github.com/maid-zone/soundcloak/lib/cfg"
|
|
)
|
|
|
|
templ UserHeader(u sc.User) {
|
|
<meta name="og:site_name" content="soundcloak"/>
|
|
<meta name="og:title" content={ u.FormatUsername() }/>
|
|
<meta name="og:description" content={ u.FormatDescription() }/>
|
|
<meta name="og:image" content={ u.Avatar }/>
|
|
<link rel="icon" type="image/x-icon" href={ u.Avatar }/>
|
|
}
|
|
|
|
templ UserItem(user *sc.User) {
|
|
<a class="listing" href={ templ.URL("/" + user.Permalink) }>
|
|
if user.Avatar != "" {
|
|
<img src={ user.Avatar }/>
|
|
} else {
|
|
<img src="/placeholder.jpg"/>
|
|
}
|
|
<div class="meta">
|
|
<h3>{ user.Username }</h3>
|
|
if user.FullName != "" {
|
|
<span>{ user.FullName }</span>
|
|
}
|
|
</div>
|
|
</a>
|
|
}
|
|
|
|
templ UserBase(prefs cfg.Preferences, u sc.User) {
|
|
<div>
|
|
if u.Avatar != "" {
|
|
<img src={ u.Avatar } width="300px"/>
|
|
}
|
|
<h1>{ u.Username }</h1>
|
|
if u.FullName != "" {
|
|
<h2>{ u.FullName }</h2>
|
|
}
|
|
if u.Verified {
|
|
<p style="color: var(--accent)">Verified</p>
|
|
}
|
|
</div>
|
|
if u.Description != "" {
|
|
@Description(prefs, u.Description)
|
|
}
|
|
<div>
|
|
<p>{ strconv.FormatInt(u.Followers, 10) } followers</p>
|
|
<p>{ strconv.FormatInt(u.Following, 10) } following</p>
|
|
<p>{ strconv.FormatInt(u.Tracks, 10) } tracks</p>
|
|
<p>{ strconv.FormatInt(u.Playlists, 10) } playlists & albums</p>
|
|
<br/>
|
|
<p>Created: { u.CreatedAt }</p>
|
|
<p>Last modified: { u.LastModified }</p>
|
|
</div>
|
|
}
|
|
|
|
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
|
|
<div class="btns">
|
|
<a class="btn active">tracks</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/sets") }>playlists</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/albums") }>albums</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/reposts") }>reposts</a>
|
|
<a class="btn" href={ templ.URL("https://soundcloud.com/" + u.Permalink) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">view on soundcloud</a>
|
|
</div>
|
|
<br/>
|
|
if len(p.Collection) != 0 {
|
|
<div>
|
|
for _, track := range p.Collection {
|
|
@TrackItem(track, false)
|
|
}
|
|
</div>
|
|
if p.Next != "" && len(p.Collection) != int(u.Tracks) {
|
|
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/tracks")[1])) } rel="noreferrer">more tracks</a>
|
|
}
|
|
} else {
|
|
<span>no more tracks</span>
|
|
}
|
|
}
|
|
|
|
templ UserPlaylists(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Playlist]) {
|
|
@UserBase(prefs, u)
|
|
<div class="btns">
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink) }>tracks</a>
|
|
<a class="btn active">playlists</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/albums") }>albums</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/reposts") }>reposts</a>
|
|
<a class="btn" href={ templ.URL("https://soundcloud.com/" + u.Permalink) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">view on soundcloud</a>
|
|
</div>
|
|
<br/>
|
|
if len(p.Collection) != 0 {
|
|
<div>
|
|
for _, playlist := range p.Collection {
|
|
@PlaylistItem(playlist, false)
|
|
}
|
|
</div>
|
|
if p.Next != "" && len(p.Collection) != int(p.Total) {
|
|
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/playlists_without_albums")[1])) } rel="noreferrer">more playlists</a>
|
|
}
|
|
} else {
|
|
<span>no more playlists</span>
|
|
}
|
|
}
|
|
|
|
templ UserAlbums(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Playlist]) {
|
|
@UserBase(prefs, u)
|
|
<div class="btns">
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink) }>tracks</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/sets") }>playlists</a>
|
|
<a class="btn active">albums</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/reposts") }>reposts</a>
|
|
<a class="btn" href={ templ.URL("https://soundcloud.com/" + u.Permalink) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">view on soundcloud</a>
|
|
</div>
|
|
<br/>
|
|
if len(p.Collection) != 0 {
|
|
<div>
|
|
for _, playlist := range p.Collection {
|
|
@PlaylistItem(playlist, false)
|
|
}
|
|
</div>
|
|
if p.Next != "" && len(p.Collection) != int(p.Total) {
|
|
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/albums")[1])) } rel="noreferrer">more albums</a>
|
|
}
|
|
} else {
|
|
<span>no more albums</span>
|
|
}
|
|
}
|
|
|
|
templ UserReposts(prefs cfg.Preferences, u sc.User, p *sc.Paginated[*sc.Repost]) {
|
|
@UserBase(prefs, u)
|
|
<div class="btns">
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink) }>tracks</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/sets") }>playlists</a>
|
|
<a class="btn" href={ templ.URL("/" + u.Permalink + "/albums") }>albums</a>
|
|
<a class="btn active">reposts</a>
|
|
<a class="btn" href={ templ.URL("https://soundcloud.com/" + u.Permalink) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">view on soundcloud</a>
|
|
</div>
|
|
<br/>
|
|
if len(p.Collection) != 0 {
|
|
<div>
|
|
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)
|
|
}
|
|
}
|
|
</div>
|
|
if p.Next != "" && len(p.Collection) != int(p.Total) {
|
|
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(strings.Split(p.Next, "/reposts")[1])) } rel="noreferrer">more reposts</a>
|
|
}
|
|
} else {
|
|
<span>no more reposts</span>
|
|
}
|
|
}
|
|
|
|
templ SearchUsers(p *sc.Paginated[*sc.User]) {
|
|
<span>Found { strconv.FormatInt(p.Total, 10) } users</span>
|
|
<br/>
|
|
<br/>
|
|
if len(p.Collection) == 0 {
|
|
if p.Total != 0 {
|
|
<p>no more results</p>
|
|
}
|
|
} else {
|
|
for _, user := range p.Collection {
|
|
@UserItem(user)
|
|
}
|
|
if p.Next != "" && len(p.Collection) != int(p.Total) {
|
|
<a class="btn" href={ templ.URL("?type=users&pagination=" + url.QueryEscape(strings.Split(p.Next, "/users")[1])) } rel="noreferrer">more users</a>
|
|
}
|
|
}
|
|
}
|