Changeset 757eea0 in Klonkt
- Timestamp:
- 06/30/2026 03:37:41 AM (2 months ago)
- Branches:
- main
- Children:
- 69b509d
- Parents:
- 432831c
- Location:
- src
- Files:
-
- 2 edited
-
routes/admin-audio.js (modified) (3 diffs)
-
views/pages/admin-audio.ejs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/admin-audio.js
r432831c r757eea0 96 96 const rows = db.prepare(` 97 97 SELECT t.id, t.title, t.artist, t.album, t.duration, t.cover_url, 98 t.position, t.created_at, t.downloadable, t.fedi_open,m.filename, m.size, m.mime_type98 t.position, t.created_at, t.downloadable, m.filename, m.size, m.mime_type 99 99 FROM audio_tracks t 100 100 LEFT JOIN media m ON m.id = t.media_id … … 288 288 }); 289 289 290 // Federate-the-file (fedi_open) per track on/off. When on, this track's audio file is shared291 // as a real AS2 Audio attachment + served ungated → it plays inline in EVERY fediverse client292 // (incl. the Mastodon apps), but the file is downloadable. Off (default) = gated, web-player only.293 router.post('/:id/fedi-open', requireGod, (req, res) => {294 const site = res.locals.site;295 if (!site) return res.status(404).send('Site required');296 const row = db.prepare('SELECT fedi_open FROM audio_tracks WHERE id = ? AND site_id = ?').get(req.params.id, site.id);297 if (row) {298 db.prepare('UPDATE audio_tracks SET fedi_open = ? WHERE id = ? AND site_id = ?')299 .run(row.fedi_open ? 0 : 1, req.params.id, site.id);300 }301 res.redirect('/admin/audio');302 });303 304 290 router.post('/:id/delete', requireGod, (req, res) => { 305 291 const site = res.locals.site; … … 494 480 fields.push('downloadable = ?'); values.push(body.downloadable ? 1 : 0); 495 481 } 496 if (Object.prototype.hasOwnProperty.call(body, 'fedi_open')) {497 fields.push('fedi_open = ?'); values.push(body.fedi_open ? 1 : 0);498 }499 482 if (Object.prototype.hasOwnProperty.call(body, 'credit')) { 500 483 fields.push('credit = ?'); values.push(String(body.credit || '').trim() || null); -
src/views/pages/admin-audio.ejs
r432831c r757eea0 83 83 var _aaudDlOn = t('aaud.dl_on'); 84 84 var _aaudDlOff = t('aaud.dl_off'); 85 var _aaudFediOn = t('aaud.fedi_on');86 var _aaudFediOff = t('aaud.fedi_off');87 85 var _aaudDelete = t('aaud.delete'); 88 86 var _aaudCopy = t('aaud.copy_click'); … … 123 121 style="<%= t.downloadable ? 'color:var(--accent,#6b8f71)' : 'opacity:.5' %>">⬇</button> 124 122 <% } %> 125 <button type="button" class="ax-icon-btn" data-track-fedi data-id="<%= t.id %>" data-on="<%= t.fedi_open ? '1' : '0' %>"126 aria-label="<%= t.fedi_open ? _aaudFediOn : _aaudFediOff %>" title="<%= t.fedi_open ? _aaudFediOn : _aaudFediOff %>"127 style="<%= t.fedi_open ? 'color:var(--accent,#6b8f71)' : 'opacity:.5' %>">🌐</button>128 123 <form action="/admin/audio/<%= t.id %>/delete" method="post" data-confirm="<%= _aaudDelConfirm %>" class="ax-track-delete"> 129 124 <button type="submit" class="ax-icon-btn ax-icon-btn-danger" aria-label="<%= _aaudDelete %>" title="<%= _aaudDelete %>">🗑</button> … … 1009 1004 }); 1010 1005 }); 1011 1012 // Fediverse-share (fedi_open) toggle — AJAX, no page reload (mirrors the download toggle).1013 document.querySelectorAll('[data-track-fedi]').forEach(btn => {1014 btn.addEventListener('click', async () => {1015 if (btn.disabled) return;1016 const want = btn.dataset.on === '1' ? 0 : 1;1017 btn.disabled = true;1018 try {1019 const res = await fetch('/admin/audio/api/' + btn.dataset.id, {1020 method: 'POST',1021 headers: { 'Content-Type': 'application/json' },1022 body: JSON.stringify({ fedi_open: !!want }),1023 });1024 if (!res.ok) throw new Error('HTTP ' + res.status);1025 btn.dataset.on = String(want);1026 btn.style.color = want ? 'var(--accent,#6b8f71)' : '';1027 btn.style.opacity = want ? '1' : '.5';1028 btn.title = want ? '<%= t('aaud.fedi_on') %>' : '<%= t('aaud.fedi_off') %>';1029 } catch (e) {1030 alert('<%= t('aaud.change_failed') %>: ' + (e.message || e));1031 } finally {1032 btn.disabled = false;1033 }1034 });1035 });1036 1006 })(); 1037 1007 </script>
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)