mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-03-22 08:38:11 +05:00
Highlight @username, links and emails in descriptions; and some fixes
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"github.com/maid-zone/soundcloak/lib/cfg"
|
||||
"github.com/maid-zone/soundcloak/lib/textparsing"
|
||||
)
|
||||
|
||||
templ Base(title string, content templ.Component, head templ.Component) {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -22,3 +27,16 @@ templ Base(title string, content templ.Component, head templ.Component) {
|
||||
</body>
|
||||
</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>
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"github.com/maid-zone/soundcloak/lib/cfg"
|
||||
)
|
||||
|
||||
templ PlaylistHeader(p sc.Playlist) {
|
||||
@@ -32,7 +33,7 @@ templ PlaylistItem(playlist *sc.Playlist, showUsername bool) {
|
||||
</a>
|
||||
}
|
||||
|
||||
templ Playlist(p sc.Playlist) {
|
||||
templ Playlist(prefs cfg.Preferences, p sc.Playlist) {
|
||||
if p.Artwork != "" {
|
||||
<img src={ p.Artwork } width="300px"/>
|
||||
}
|
||||
@@ -43,10 +44,7 @@ templ Playlist(p sc.Playlist) {
|
||||
</div>
|
||||
<br/>
|
||||
if p.Description != "" {
|
||||
<details>
|
||||
<summary>Toggle description</summary>
|
||||
<p style="white-space: pre-wrap">{ p.Description }</p>
|
||||
</details>
|
||||
@Description(prefs, p.Description)
|
||||
}
|
||||
<p>{ strconv.FormatInt(p.TrackCount, 10) } tracks</p>
|
||||
<br/>
|
||||
|
||||
@@ -11,8 +11,8 @@ templ checkbox(name string, checked bool) {
|
||||
}
|
||||
|
||||
type option struct {
|
||||
value string
|
||||
desc string
|
||||
value string
|
||||
desc string
|
||||
disabled bool
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ templ sel(name string, options []option, selected string) {
|
||||
templ Preferences(prefs cfg.Preferences) {
|
||||
<h1>Preferences</h1>
|
||||
<form method="post">
|
||||
<label>
|
||||
Parse descriptions:
|
||||
@checkbox("ParseDescriptions", *prefs.ParseDescriptions)
|
||||
</label>
|
||||
<br/>
|
||||
if cfg.ProxyImages {
|
||||
<label>
|
||||
Proxy images:
|
||||
@@ -68,9 +73,8 @@ templ Preferences(prefs cfg.Preferences) {
|
||||
<br/>
|
||||
}
|
||||
<input type="submit" value="Update" class="btn" style="margin-top: 1rem;"/>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br/>
|
||||
<br/>
|
||||
<p>These preferences get saved in a cookie.</p>
|
||||
</form>
|
||||
}
|
||||
|
||||
@@ -87,10 +87,7 @@ templ Track(prefs cfg.Preferences, t sc.Track, stream string, displayErr string)
|
||||
</div>
|
||||
<br/>
|
||||
if t.Description != "" {
|
||||
<details>
|
||||
<summary>Toggle description</summary>
|
||||
<p style="white-space: pre-wrap">{ t.Description }</p>
|
||||
</details>
|
||||
@Description(prefs, t.Description)
|
||||
}
|
||||
<p>{ strconv.FormatInt(t.Likes, 10) } likes</p>
|
||||
<p>{ strconv.FormatInt(t.Played, 10) } plays</p>
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"github.com/maid-zone/soundcloak/lib/cfg"
|
||||
)
|
||||
|
||||
templ UserHeader(u sc.User) {
|
||||
@@ -31,7 +32,7 @@ templ UserItem(user *sc.User) {
|
||||
</a>
|
||||
}
|
||||
|
||||
templ UserBase(u sc.User) {
|
||||
templ UserBase(prefs cfg.Preferences, u sc.User) {
|
||||
<div>
|
||||
if u.Avatar != "" {
|
||||
<img src={ u.Avatar } width="300px"/>
|
||||
@@ -45,10 +46,7 @@ templ UserBase(u sc.User) {
|
||||
}
|
||||
</div>
|
||||
if u.Description != "" {
|
||||
<details>
|
||||
<summary>Toggle description</summary>
|
||||
<p style="white-space: pre-wrap">{ u.Description }</p>
|
||||
</details>
|
||||
@Description(prefs, u.Description)
|
||||
}
|
||||
<div>
|
||||
<p>{ strconv.FormatInt(u.Followers, 10) } followers</p>
|
||||
@@ -61,15 +59,15 @@ templ UserBase(u sc.User) {
|
||||
</div>
|
||||
}
|
||||
|
||||
templ User(u sc.User, p *sc.Paginated[*sc.Track]) {
|
||||
@UserBase(u)
|
||||
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) }>view on soundcloud</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 {
|
||||
@@ -86,14 +84,14 @@ templ User(u sc.User, p *sc.Paginated[*sc.Track]) {
|
||||
}
|
||||
}
|
||||
|
||||
templ UserPlaylists(u sc.User, p *sc.Paginated[*sc.Playlist]) {
|
||||
@UserBase(u)
|
||||
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) }>view on soundcloud</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 {
|
||||
@@ -110,14 +108,14 @@ templ UserPlaylists(u sc.User, p *sc.Paginated[*sc.Playlist]) {
|
||||
}
|
||||
}
|
||||
|
||||
templ UserAlbums(u sc.User, p *sc.Paginated[*sc.Playlist]) {
|
||||
@UserBase(u)
|
||||
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) }>view on soundcloud</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 {
|
||||
@@ -134,14 +132,14 @@ templ UserAlbums(u sc.User, p *sc.Paginated[*sc.Playlist]) {
|
||||
}
|
||||
}
|
||||
|
||||
templ UserReposts(u sc.User, p *sc.Paginated[*sc.Repost]) {
|
||||
@UserBase(u)
|
||||
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) }>view on soundcloud</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 {
|
||||
|
||||
Reference in New Issue
Block a user