Changeset d727e92 in Klonkt for src/services/AudioEmbedService.js
- Timestamp:
- 06/20/2026 05:37:42 AM (3 months ago)
- Branches:
- main
- Children:
- a66f691
- Parents:
- 183875b
- File:
-
- 1 edited
-
src/services/AudioEmbedService.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/AudioEmbedService.js
r183875b rd727e92 270 270 return html.replace(/\[\[track:([A-Za-z0-9_-]+)\]\]/g, (match, id) => { 271 271 const t = trackLookup(id); 272 if (!t || !t.url) return match; 272 if (!t) return match; 273 const titleH0 = this.escape(t.title || 'Untitled'); 274 const artistH0 = this.escape(t.artist || ''); 275 const creditBits0 = [this.escape(t.credit || ''), this.escape(t.license || '')].filter(Boolean).join(' · '); 276 // Link-only track (geen audiobestand): geen afspeelknop, wel info + open-in. 277 if (!t.url) { 278 return `<div class="post-audio-track post-audio-track--static" id="track-${id}"> 279 <span class="pat-noplay" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg></span> 280 <div class="pat-info"> 281 <div class="pat-title">${titleH0}</div> 282 ${artistH0 ? `<div class="pat-artist">${artistH0}</div>` : ''} 283 ${creditBits0 ? `<div class="pat-credit">${creditBits0}</div>` : ''} 284 </div> 285 ${this.openInLinks(t)} 286 </div>`; 287 } 273 288 const trackJson = JSON.stringify({ 274 289 id, … … 318 333 // Stable DOM id for this rendering — used as data-pcms-album-id on tracks 319 334 const albumDomId = 'album-' + Math.random().toString(36).slice(2, 10); 320 const albumJson = JSON.stringify(album.tracks) 335 // Alleen afspeelbare tracks (met url) in de queue; link-only tracks staan 336 // wel in de lijst maar niet in de afspeel-JSON. 337 const albumJson = JSON.stringify(album.tracks.filter((t) => t.url)) 321 338 .replace(/&/g, '&').replace(/'/g, ''').replace(/</g, '<'); 322 339 const titleH = this.escape(album.title || name); … … 327 344 const tTitle = this.escape(t.title || ('Track ' + (i + 1))); 328 345 const tArtist = this.escape(t.artist || ''); 346 // Link-only track: geen afspeelknop, wel nummer + info + open-in. 347 if (!t.url) { 348 return ` <li class="post-audio-track post-audio-track--static"${t.id ? ` id="track-${t.id}"` : ''}> 349 <span class="pat-track-num">${i + 1}.</span> 350 <div class="pat-info"> 351 <div class="pat-title">${tTitle}</div> 352 ${tArtist && tArtist !== artistH ? `<div class="pat-artist">${tArtist}</div>` : ''} 353 </div> 354 ${this.openInLinks(t)} 355 </li>`; 356 } 329 357 const tUrl = this.escape(t.url); 330 358 return ` <li class="post-audio-track"${t.id ? ` id="track-${t.id}" data-pcms-track-id="${t.id}"` : ''} data-pcms-track-url="${tUrl}" data-pcms-album-id="${albumDomId}"> … … 404 432 // Audio-player.js reads data-pcms-album for queue. Same shape as 405 433 // embedAlbumShortcodes — keep both in sync. 406 const tracksData = pl.tracks.map(t => ({ 434 // Alleen afspeelbare tracks in de queue; link-only tracks staan wel in de 435 // lijst maar niet in de afspeel-JSON. 436 const tracksData = pl.tracks.filter(t => t.url).map(t => ({ 407 437 id: t.id, 408 438 url: t.url, … … 426 456 } 427 457 const metaLine = this.escape(metaParts.join(' · ')); 428 const firstUrl = this.escape( pl.tracks[0].url);458 const firstUrl = this.escape((pl.tracks.find(t => t.url) || {}).url || ''); 429 459 430 460 // Track items — playlist-kind shows per-track cover thumbs, album-kind shows numbers … … 445 475 : `<span class="pat-num">${i + 1}</span>`; 446 476 477 // Link-only track: geen klikbare afspeel-rij (statische div), wel open-in. 478 if (!t.url) { 479 return ` <li class="post-album-track-compact post-album-track-compact--static"${t.id ? ` id="track-${t.id}"` : ''}> 480 <div class="pat-row pat-static"> 481 ${leader} 482 <span class="pat-meta"> 483 <span class="pat-title">${tTitleH}</span> 484 ${showArtist ? `<span class="pat-artist">${tArtistH}</span>` : ''} 485 </span> 486 ${durHtml} 487 </div> 488 ${this.openInLinks(t)} 489 </li>`; 490 } 447 491 const trackBase = String(t.url).split('?')[0]; 448 492 return ` <li class="post-album-track-compact"${t.id ? ` id="track-${t.id}" data-pcms-track-id="${t.id}"` : ''}>
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)