mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-03-22 08:38:11 +05:00
add support for /tags/:tag and other endpoints
This commit is contained in:
@@ -12,7 +12,7 @@ templ Base(title string, content templ.Component, head templ.Component) {
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<link rel="stylesheet" href="/global.css"/>
|
||||
<link rel="stylesheet" href="global.css"/>
|
||||
<link rel="stylesheet" href="/instance.css"/>
|
||||
if title != "" {
|
||||
<title>{ title } ~ soundcloak</title>
|
||||
} else {
|
||||
|
||||
75
templates/tags.templ
Normal file
75
templates/tags.templ
Normal file
@@ -0,0 +1,75 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"github.com/maid-zone/soundcloak/lib/sc"
|
||||
"net/url"
|
||||
"strings"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
templ TagsButtons(current string, tag string) {
|
||||
<div class="btns">
|
||||
for _, b := range [...]btn{{"recent tracks", "", false},{"popular tracks", "/popular-tracks", false},{"playlists", "/playlists",false}} {
|
||||
if b.text == current {
|
||||
<a class="btn active">{ b.text }</a>
|
||||
} else {
|
||||
<a class="btn" href={ templ.URL("/tags/" + tag + b.href) }>{ b.text }</a>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<br/>
|
||||
}
|
||||
|
||||
templ RecentTracks(tag string, p *sc.Paginated[*sc.Track]) {
|
||||
<h1>Recent tracks tagged {url.PathUnescape(tag)}</h1>
|
||||
@TagsButtons("recent tracks", tag)
|
||||
if len(p.Collection) == 0 {
|
||||
<p>no more tracks</p>
|
||||
} else {
|
||||
for _, track := range p.Collection {
|
||||
@TrackItem(track, true, "")
|
||||
}
|
||||
if p.Next != "" {
|
||||
<a class="btn" href={ templ.URL("/tags/" + tag + "?pagination=" + url.QueryEscape(strings.Split(p.Next, "/recent-tracks")[1])) } rel="noreferrer">more tracks</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ PopularTracks(tag string, p *sc.Paginated[*sc.Track]) {
|
||||
<h1>Popular tracks tagged {url.PathUnescape(tag)}</h1>
|
||||
@TagsButtons("popular tracks", tag)
|
||||
<span>Found { strconv.FormatInt(p.Total, 10) } tracks</span>
|
||||
<br/>
|
||||
<br/>
|
||||
if len(p.Collection) == 0 {
|
||||
<p>no more tracks</p>
|
||||
} else {
|
||||
for _, track := range p.Collection {
|
||||
@TrackItem(track, true, "")
|
||||
}
|
||||
if p.Next != "" {
|
||||
<a class="btn" href={ templ.URL("/tags/" + tag + "/popular-tracks?pagination=" + url.QueryEscape(strings.Split(p.Next, "/tracks")[1])) } rel="noreferrer">more tracks</a>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ TaggedPlaylists(tag string, p *sc.Paginated[*sc.Playlist]) {
|
||||
<h1>Playlists tagged {url.PathUnescape(tag)}</h1>
|
||||
@TagsButtons("playlists", tag)
|
||||
<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>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ templ Track(prefs cfg.Preferences, t sc.Track, stream string, displayErr string,
|
||||
<h1>{ t.Title }</h1>
|
||||
@TrackPlayer(prefs, t, stream, displayErr, autoplay, nextTrack, playlist, volume, mode, audio)
|
||||
if t.Genre != "" {
|
||||
<p class="tag">{ t.Genre }</p>
|
||||
<a href={templ.URL("/tags/"+t.Genre)}><p class="tag">{ t.Genre }</p></a>
|
||||
}
|
||||
if playlist != nil {
|
||||
<details open style="margin-bottom: 1rem;">
|
||||
|
||||
Reference in New Issue
Block a user