mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-01-06 02:49:38 +05:00
88 lines
2.4 KiB
Plaintext
88 lines
2.4 KiB
Plaintext
package templates
|
|
|
|
import (
|
|
"github.com/maid-zone/soundcloak/lib/sc"
|
|
"net/url"
|
|
"strconv"
|
|
"strings"
|
|
"github.com/maid-zone/soundcloak/lib/cfg"
|
|
)
|
|
|
|
templ PlaylistHeader(p sc.Playlist) {
|
|
<meta name="og:site_name" content={ p.Author.Username + " ~ soundcloak" }/>
|
|
<meta name="og:title" content={ p.Title }/>
|
|
<meta name="og:description" content={ p.FormatDescription() }/>
|
|
<meta name="og:image" content={ p.Artwork }/>
|
|
<link rel="icon" type="image/x-icon" href={ p.Artwork }/>
|
|
}
|
|
|
|
templ PlaylistItem(playlist *sc.Playlist, showUsername bool) {
|
|
<a class="listing" href={ templ.URL("/" + playlist.Author.Permalink + "/sets/" + playlist.Permalink) }>
|
|
if playlist.Artwork != "" {
|
|
<img src={ playlist.Artwork }/>
|
|
} else {
|
|
<img src="/placeholder.jpg"/>
|
|
}
|
|
<div class="meta">
|
|
<h3>{ playlist.Title }</h3>
|
|
if showUsername {
|
|
<span>{ playlist.Author.Username }</span>
|
|
}
|
|
<p>{ strconv.FormatInt(playlist.TrackCount, 10) } tracks</p>
|
|
</div>
|
|
</a>
|
|
}
|
|
|
|
templ Playlist(prefs cfg.Preferences, p sc.Playlist) {
|
|
if p.Artwork != "" {
|
|
<img src={ p.Artwork } width="300px"/>
|
|
}
|
|
<h1>{ p.Title }</h1>
|
|
@UserItem(&p.Author)
|
|
<div style="display: flex;">
|
|
<a class="btn" href={ templ.URL("https://soundcloud.com/" + p.Author.Permalink + "/sets/" + p.Permalink) }>view on soundcloud</a>
|
|
</div>
|
|
<br/>
|
|
if p.Description != "" {
|
|
@Description(prefs, p.Description)
|
|
}
|
|
<p>{ strconv.FormatInt(p.TrackCount, 10) } tracks</p>
|
|
<br/>
|
|
<br/>
|
|
<div>
|
|
for _, track := range p.Tracks {
|
|
@TrackItem(track, true)
|
|
}
|
|
</div>
|
|
if len(p.MissingTracks) != 0 {
|
|
<a class="btn" href={ templ.URL("?pagination=" + url.QueryEscape(p.MissingTracks)) } rel="noreferrer">more tracks</a>
|
|
}
|
|
<div>
|
|
if p.TagList != "" {
|
|
<p>Tags: { strings.Join(sc.TagListParser(p.TagList), ", ") }</p>
|
|
}
|
|
<p>{ strconv.FormatInt(p.Likes, 10) } likes</p>
|
|
<br/>
|
|
<p>Created: { p.CreatedAt }</p>
|
|
<p>Last modified: { p.LastModified }</p>
|
|
</div>
|
|
}
|
|
|
|
templ SearchPlaylists(p *sc.Paginated[*sc.Playlist]) {
|
|
<span>Found { strconv.FormatInt(p.Total, 10) } playlists</span>
|
|
<br/>
|
|
<br/>
|
|
if len(p.Collection) == 0 {
|
|
if p.Total != 0 {
|
|
<p>no more results</p>
|
|
}
|
|
} else {
|
|
for _, playlist := range p.Collection {
|
|
@PlaylistItem(playlist, true)
|
|
}
|
|
if p.Next != "" && len(p.Collection) != int(p.Total) {
|
|
<a class="btn" href={ templ.URL("?type=playlists&pagination=" + url.QueryEscape(strings.Split(p.Next, "/playlists")[1])) } rel="noreferrer">more playlists</a>
|
|
}
|
|
}
|
|
}
|