mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-03-22 08:38:11 +05:00
Get links to other places in user profiles; other small improvements
This commit is contained in:
@@ -28,15 +28,22 @@ templ Base(title string, content templ.Component, head templ.Component) {
|
||||
</html>
|
||||
}
|
||||
|
||||
templ Description(prefs cfg.Preferences, text string) {
|
||||
<details>
|
||||
<summary>Toggle description</summary>
|
||||
<p style="white-space: pre-wrap;">
|
||||
if *prefs.ParseDescriptions {
|
||||
@templ.Raw(textparsing.Format(text))
|
||||
} else {
|
||||
{ text }
|
||||
}
|
||||
</p>
|
||||
</details>
|
||||
templ Description(prefs cfg.Preferences, text string, injected templ.Component) {
|
||||
if text != "" || injected != nil {
|
||||
<details>
|
||||
<summary>Toggle description</summary>
|
||||
<p style="white-space: pre-wrap;">
|
||||
if text != "" {
|
||||
if *prefs.ParseDescriptions {
|
||||
@templ.Raw(textparsing.Format(text))
|
||||
} else {
|
||||
{ text }
|
||||
}
|
||||
}
|
||||
if injected != nil {
|
||||
@injected
|
||||
}
|
||||
</p>
|
||||
</details>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"github.com/maid-zone/soundcloak/lib/cfg"
|
||||
"github.com/maid-zone/soundcloak/lib/sc"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"github.com/maid-zone/soundcloak/lib/cfg"
|
||||
)
|
||||
|
||||
templ PlaylistHeader(p sc.Playlist) {
|
||||
@@ -43,9 +43,7 @@ templ Playlist(prefs cfg.Preferences, p sc.Playlist) {
|
||||
<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)
|
||||
}
|
||||
@Description(prefs, p.Description, nil)
|
||||
<p>{ strconv.FormatInt(p.TrackCount, 10) } tracks</p>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
@@ -23,7 +23,6 @@ templ TrackPlayer(prefs cfg.Preferences, track sc.Track, stream string, displayE
|
||||
if *prefs.Player == cfg.NonePlayer {
|
||||
{{ return }}
|
||||
}
|
||||
|
||||
if displayErr == "" {
|
||||
if cfg.Restream && *prefs.Player == cfg.RestreamPlayer {
|
||||
<audio src={ "/_/restream/" + track.Author.Permalink + "/" + track.Permalink } controls></audio>
|
||||
@@ -38,7 +37,7 @@ templ TrackPlayer(prefs cfg.Preferences, track sc.Track, stream string, displayE
|
||||
<br/>
|
||||
JavaScript is disabled! Audio playback may not work without it enabled.
|
||||
if cfg.Restream {
|
||||
<br>
|
||||
<br/>
|
||||
<a class="link" href="/_/preferences">You can enable Restream player in the preferences. It works without JavaScript.</a>
|
||||
}
|
||||
</noscript>
|
||||
@@ -85,13 +84,11 @@ templ Track(prefs cfg.Preferences, t sc.Track, stream string, displayErr string)
|
||||
<div style="display: flex; gap: 1rem">
|
||||
<a class="btn" href={ templ.URL("https://soundcloud.com/" + t.Author.Permalink + "/" + t.Permalink) }>view on soundcloud</a>
|
||||
if cfg.Restream {
|
||||
<a class="btn" href={ templ.URL("/_/restream/" + t.Author.Permalink + "/" + t.Permalink+"?metadata=true") } download={t.Author.Username + " - " + t.Title + ".mp3"}>download</a>
|
||||
<a class="btn" href={ templ.URL("/_/restream/" + t.Author.Permalink + "/" + t.Permalink + "?metadata=true") } download={ t.Author.Username + " - " + t.Title + ".mp3" }>download</a>
|
||||
}
|
||||
</div>
|
||||
<br/>
|
||||
if t.Description != "" {
|
||||
@Description(prefs, t.Description)
|
||||
}
|
||||
@Description(prefs, t.Description, nil)
|
||||
<p>{ strconv.FormatInt(t.Likes, 10) } likes</p>
|
||||
<p>{ strconv.FormatInt(t.Played, 10) } plays</p>
|
||||
<p>{ strconv.FormatInt(t.Reposted, 10) } reposts</p>
|
||||
|
||||
@@ -32,6 +32,18 @@ templ UserItem(user *sc.User) {
|
||||
</a>
|
||||
}
|
||||
|
||||
templ UserLinks(links []sc.Link) {
|
||||
for _, link := range links {
|
||||
if len(link.URL) > 0 {
|
||||
if link.URL[0] == '/' {
|
||||
<p><a class="link" href={ templ.URL(link.URL) }>- { link.Title }</a></p>
|
||||
} else {
|
||||
<p><a class="link" href={ templ.URL(link.URL) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">- { link.Title }</a></p>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ UserBase(prefs cfg.Preferences, u sc.User) {
|
||||
<div>
|
||||
if u.Avatar != "" {
|
||||
@@ -45,8 +57,10 @@ templ UserBase(prefs cfg.Preferences, u sc.User) {
|
||||
<p style="color: var(--accent)">Verified</p>
|
||||
}
|
||||
</div>
|
||||
if u.Description != "" {
|
||||
@Description(prefs, u.Description)
|
||||
if len(u.WebProfiles) != 0 {
|
||||
@Description(prefs, u.Description, UserLinks(u.WebProfiles))
|
||||
} else {
|
||||
@Description(prefs, u.Description, nil)
|
||||
}
|
||||
<div>
|
||||
<p>{ strconv.FormatInt(u.Followers, 10) } followers</p>
|
||||
@@ -66,10 +80,11 @@ type btn struct {
|
||||
}
|
||||
|
||||
templ UserButtons(current string, user string) {
|
||||
<div class="btns"> // this part is the tedious one now, because formatting breaks if i space the list out with newlines
|
||||
<div class="btns">
|
||||
// this part is the tedious one now, because formatting breaks if i space the list out with newlines
|
||||
for _, b := range [6]btn{{"tracks", "", false},{"playlists", "/sets",false},{"albums", "/albums", false},{"reposts","/reposts", false},{"likes", "/likes", false},{"view on soundcloud", "https://soundcloud.com/"+user, true}} {
|
||||
if b.text == current {
|
||||
<a class="btn active">{b.text}</a>
|
||||
<a class="btn active">{ b.text }</a>
|
||||
} else {
|
||||
if b.external {
|
||||
<a class="btn" href={ templ.URL(b.href) } referrerpolicy="no-referrer" rel="external nofollow noopener noreferrer" target="_blank">{ b.text }</a>
|
||||
|
||||
Reference in New Issue
Block a user