Changeset 183875b in Klonkt for src/services
- Timestamp:
- 06/20/2026 05:23:08 AM (3 months ago)
- Branches:
- main
- Children:
- d727e92
- Parents:
- 459acd9
- Location:
- src/services
- Files:
-
- 2 edited
-
AudioEmbedService.js (modified) (4 diffs)
-
PlaylistService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/AudioEmbedService.js
r459acd9 r183875b 11 11 */ 12 12 13 // "Open in"-iconen (brand-gekleurd via CSS .pat-link--*). 14 const OPEN_IN_SVG = { 15 spotify: '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2a10 10 0 100 20 10 10 0 000-20zm4.6 14.42a.62.62 0 01-.86.21c-2.35-1.44-5.3-1.76-8.79-.96a.62.62 0 11-.28-1.21c3.8-.87 7.07-.5 9.71 1.11.3.18.39.57.22.85zm1.23-2.73a.78.78 0 01-1.07.26c-2.69-1.66-6.79-2.14-9.97-1.17a.78.78 0 11-.45-1.49c3.63-1.1 8.15-.56 11.24 1.33.36.22.48.7.25 1.07zm.1-2.85C14.66 8.95 9.4 8.78 6.3 9.72a.93.93 0 11-.54-1.79c3.56-1.08 9.37-.87 13.07 1.33a.94.94 0 01-.96 1.61z"/></svg>', 16 youtube: '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M23 7.1a3 3 0 00-2.1-2.12C19.04 4.5 12 4.5 12 4.5s-7.04 0-8.9.48A3 3 0 001 7.1 31.2 31.2 0 00.5 12 31.2 31.2 0 001 16.9a3 3 0 002.1 2.12c1.86.48 8.9.48 8.9.48s7.04 0 8.9-.48A3 3 0 0023 16.9 31.2 31.2 0 0023.5 12 31.2 31.2 0 0023 7.1zM9.75 15.5v-7l6 3.5-6 3.5z"/></svg>', 17 soundcloud: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 14v4M7.5 11v7M11 9v9"/><path d="M14.5 9.5V18h4a3 3 0 100-6 4 4 0 00-4-2.5z"/></svg>', 18 }; 19 13 20 class AudioEmbedService { 21 // Kleine "open in"-links voor een track (Spotify/YouTube/SoundCloud). De hrefs 22 // zijn server-side al gevalideerd (alleen https + juiste host). Geeft '' als er 23 // geen links zijn. Wordt naast de play-knop gezet (buiten de knop → geen 24 // conflict met afspelen). 25 static openInLinks(t) { 26 if (!t) return ''; 27 const out = []; 28 const add = (url, key, label) => { 29 if (!url) return; 30 out.push(`<a class="pat-link pat-link--${key}" href="${this.escape(url)}" target="_blank" rel="noopener noreferrer" title="Open in ${label}" aria-label="Open in ${label}">${OPEN_IN_SVG[key]}</a>`); 31 }; 32 add(t.link_spotify, 'spotify', 'Spotify'); 33 add(t.link_youtube, 'youtube', 'YouTube'); 34 add(t.link_soundcloud, 'soundcloud', 'SoundCloud'); 35 return out.length ? `<span class="pat-links">${out.join('')}</span>` : ''; 36 } 37 14 38 static detectProvider(url) { 15 39 if (!url || typeof url !== 'string') return null; … … 273 297 ${creditBits ? `<div class="pat-credit">${creditBits}</div>` : ''} 274 298 </div> 299 ${this.openInLinks(t)} 275 300 </div>`; 276 301 }); … … 312 337 ${tArtist && tArtist !== artistH ? `<div class="pat-artist">${tArtist}</div>` : ''} 313 338 </div> 339 ${this.openInLinks(t)} 314 340 </li>`; 315 341 }).join('\n'); … … 433 459 ${durHtml} 434 460 </button> 461 ${this.openInLinks(t)} 435 462 </li>`; 436 463 }).join('\n'); -
src/services/PlaylistService.js
r459acd9 r183875b 94 94 // filenames (only tracks with a media file are playable). 95 95 const tracks = db.prepare(` 96 SELECT t.id, t.title, t.artist, t.duration, t.cover_url, m.filename 96 SELECT t.id, t.title, t.artist, t.duration, t.cover_url, 97 t.link_spotify, t.link_youtube, t.link_soundcloud, m.filename 97 98 FROM playlist_tracks pt 98 99 JOIN audio_tracks t ON t.id = pt.track_id … … 110 111 cover: t.cover_url || p.cover_url || '', 111 112 duration: t.duration || 0, 113 link_spotify: t.link_spotify || '', 114 link_youtube: t.link_youtube || '', 115 link_soundcloud: t.link_soundcloud || '', 112 116 url: urlFor ? urlFor(t.filename) : null, 113 117 }));
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)