mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-10 05:39:38 +05:00
56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
package templates
|
|
|
|
import (
|
|
"git.maid.zone/stuff/soundcloak/lib/sc"
|
|
"strconv"
|
|
)
|
|
|
|
templ PlaylistOrUserItem(pl *sc.PlaylistOrUser) {
|
|
<a class="listing" href={ templ.SafeURL(pl.Href()) }>
|
|
{{
|
|
img := pl.Artwork
|
|
if pl.Kind == "user" {
|
|
img = pl.Avatar
|
|
}
|
|
if img == "" {
|
|
img = "/_/static/placeholder.jpg"
|
|
}
|
|
}}
|
|
<img loading="lazy" fetchpriority="low" src={ img }/>
|
|
<div class="meta">
|
|
if pl.Kind == "user" {
|
|
<h3>{ pl.Username }</h3>
|
|
if pl.FullName != "" {
|
|
<span>{ pl.FullName }</span>
|
|
}
|
|
} else {
|
|
<h3>{ pl.Title }</h3>
|
|
<p>{ strconv.FormatInt(pl.TrackCount, 10) } tracks</p>
|
|
}
|
|
</div>
|
|
</a>
|
|
}
|
|
|
|
templ Discover(p *sc.Paginated[*sc.Selection]) {
|
|
<h1>Discover Playlists</h1> // also tracks apparently? haven't seen any
|
|
<span>Got { strconv.FormatInt(int64(len(p.Collection)), 10) } selections</span>
|
|
if len(p.Collection) != 0 {
|
|
for _, selection := range p.Collection {
|
|
// skip so we don't just include the title and zero playlists with it
|
|
if len(selection.Items.Collection) == 0 {
|
|
{{ continue }} // raw go code my beloved
|
|
}
|
|
|
|
<h2>{selection.Title}</h2>
|
|
for _, pl := range selection.Items.Collection {
|
|
@PlaylistOrUserItem(pl)
|
|
}
|
|
}
|
|
|
|
// I don't think they have pagination for this endpoint, just leaving this here, in case they actually do
|
|
// if p.Next != "" {
|
|
// <a class="btn" href={ templ.URL("/discover?pagination=" + url.QueryEscape(strings.Split(p.Next, "/discover")[1])) } rel="noreferrer">more playlists</a>
|
|
// }
|
|
}
|
|
}
|