Changeset d727e92 in Klonkt for src/routes


Ignore:
Timestamp:
06/20/2026 05:37:42 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
a66f691
Parents:
183875b
Message:

feat(audio): tracks without audio (link-only) — list with open-in links, no upload

You can now add a "Track without audio" in Admin → Audio (button) — only
title/artist + the Spotify/YouTube/SoundCloud links, no file. Such tracks
appear in albums & playlists (and standalone track embeds) in the list
with the open-in icons but WITHOUT a play button, and stay outside the
playback queue (which matches on URL). Lookups (posts album/single +
PlaylistService) no longer filter out fileless tracks. New route POST
/admin/audio/create-link. buster audio.css?v=9.

Co-Authored-By: Claude <noreply@…>

Location:
src/routes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/routes/admin-audio.js

    r183875b rd727e92  
    394394
    395395/** GET /admin/audio/api/:id — single track with all metadata */
     396// Maak een track ZONDER audiobestand (alleen titel + open-in links). Verschijnt
     397// in albums/playlists in de lijst, met open-in-iconen maar zonder afspeelknop.
     398router.post('/create-link', requireGod, express.json(), (req, res) => {
     399  const site = res.locals.site;
     400  if (!site) return res.status(404).json({ error: 'Site required' });
     401  const trackId = uuid();
     402  const title = ((req.body && req.body.title) || 'Nieuwe track').toString().trim().slice(0, 200) || 'Nieuwe track';
     403  try {
     404    db.prepare(`
     405      INSERT INTO audio_tracks (id, site_id, title, media_id, position)
     406      VALUES (?, ?, ?, NULL, COALESCE((SELECT MAX(position) + 1 FROM audio_tracks WHERE site_id = ?), 0))
     407    `).run(trackId, site.id, title, site.id);
     408  } catch (e) {
     409    return res.status(500).json({ error: e.message });
     410  }
     411  res.json({ ok: true, id: trackId });
     412});
     413
    396414router.get('/api/:id', requireGod, (req, res) => {
    397415  const site = res.locals.site;
  • src/routes/posts.js

    r183875b rd727e92  
    537537      html = AudioEmbedService.embedTrackShortcodes(html, (id) => {
    538538        const r = byId.get(id);
    539         if (!r || !r.filename) return null;
     539        if (!r) return null;
    540540        return {
    541541          id: r.id,
     
    548548          link_youtube: r.link_youtube || '',
    549549          link_soundcloud: r.link_soundcloud || '',
    550           url: audioUrl(r.filename),
     550          url: r.filename ? audioUrl(r.filename) : '',  // '' = link-only track
    551551        };
    552552      });
     
    566566      const byAlbum = new Map();
    567567      for (const r of albumRows) {
    568         if (!r.filename) continue;
     568        // Link-only tracks (geen bestand) blijven in het album-overzicht (url '').
    569569        if (!byAlbum.has(r.album)) byAlbum.set(r.album, []);
    570570        byAlbum.get(r.album).push({
    571571          id: r.id,
    572           url: audioUrl(r.filename),
     572          url: r.filename ? audioUrl(r.filename) : '',
    573573          title: r.title || 'Untitled',
    574574          artist: r.artist || '',
Note: See TracChangeset for help on using the changeset viewer.