Changeset e0a1ec1 in Klonkt
- Timestamp:
- 06/30/2026 02:27:57 AM (2 months ago)
- Branches:
- main
- Children:
- d3b9f68
- Parents:
- 084d1c0
- Location:
- src
- Files:
-
- 3 edited
-
routes/posts.js (modified) (4 diffs)
-
services/i18n.js (modified) (3 diffs)
-
views/pages/post-edit.ejs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r084d1c0 re0a1ec1 169 169 170 170 // ==================== CREATE POST ==================== 171 // ── Per-post audio federation ────────────────────────────────────────────── 172 // "Share audio on the fediverse" is a per-post choice in the editor, but the underlying 173 // flag is per track (audio_tracks.fedi_open — it gates the file + drives the AS2 Audio 174 // attachment). NB: the file gate is per file, so opening a track in one post makes its file 175 // fetchable for every post that reuses it. 176 function setAudioFediOpen(siteId, content, open) { 177 const val = open ? 1 : 0; 178 const c = content || ''; 179 try { 180 for (const m of c.matchAll(/\[\[track:([A-Za-z0-9_-]+)\]\]/g)) db.prepare('UPDATE audio_tracks SET fedi_open = ? WHERE id = ? AND site_id = ?').run(val, m[1], siteId); 181 for (const m of c.matchAll(/\[\[album:([^\]]+)\]\]/g)) db.prepare('UPDATE audio_tracks SET fedi_open = ? WHERE site_id = ? AND album = ?').run(val, siteId, m[1].trim()); 182 for (const m of c.matchAll(/\[\[playlist:([A-Za-z0-9_-]+)\]\]/g)) db.prepare('UPDATE audio_tracks SET fedi_open = ? WHERE id IN (SELECT track_id FROM playlist_tracks WHERE playlist_id = ?)').run(val, m[1]); 183 } catch { /* non-fatal */ } 184 } 185 // True when the post references hosted audio AND all of it is currently fedi_open (drives the 186 // editor checkbox's initial state). 187 function postAudioFediOpen(siteId, content) { 188 const c = content || ''; 189 if (!/\[\[(track|album|playlist):/i.test(c)) return false; 190 let total = 0, open = 0; 191 const tally = (r) => { if (r && r.media_id) { total++; if (r.fedi_open) open++; } }; 192 try { 193 for (const m of c.matchAll(/\[\[track:([A-Za-z0-9_-]+)\]\]/g)) tally(db.prepare('SELECT fedi_open, media_id FROM audio_tracks WHERE id = ? AND site_id = ?').get(m[1], siteId)); 194 for (const m of c.matchAll(/\[\[album:([^\]]+)\]\]/g)) for (const r of db.prepare('SELECT fedi_open, media_id FROM audio_tracks WHERE site_id = ? AND album = ? AND media_id IS NOT NULL').all(siteId, m[1].trim())) tally(r); 195 for (const m of c.matchAll(/\[\[playlist:([A-Za-z0-9_-]+)\]\]/g)) for (const r of db.prepare('SELECT t.fedi_open, t.media_id FROM playlist_tracks pt JOIN audio_tracks t ON t.id = pt.track_id WHERE pt.playlist_id = ? AND t.media_id IS NOT NULL').all(m[1])) tally(r); 196 } catch { /* non-fatal */ } 197 return total > 0 && open === total; 198 } 199 171 200 router.post('/posts/create', requireAuth, (req, res) => { 172 201 const site = res.locals.site; … … 228 257 ); 229 258 259 // Per-post "share audio on the fediverse" → set fedi_open on this post's hosted tracks 260 // BEFORE federating, so the Create note carries the right Audio attachments. 261 setAudioFediOpen(site.id, cleanContent, req.body.fedi_open_audio); 262 230 263 if (finalStatus === 'published') { 231 264 try { … … 278 311 post, 279 312 isNew: false, 313 fediOpenAudio: postAudioFediOpen(site.id, post.content), 280 314 pageTitle: 'Edit: ' + (post.title || 'Untitled'), 281 315 bodyClass: 'on-special', … … 349 383 finalSlug, publishedAt, now, post.id 350 384 ); 385 386 // Per-post "share audio on the fediverse" → set fedi_open on this post's hosted tracks 387 // BEFORE federating, so the Update/Create note carries the right Audio attachments. 388 setAudioFediOpen(site.id, cleanContent, req.body.fedi_open_audio); 351 389 352 390 // Update FTS -
src/services/i18n.js
r084d1c0 re0a1ec1 694 694 'pedit.pin_top': 'bovenaan', 695 695 'pedit.pin_nth_suffix': 'e van boven', 696 'pedit.noindex_label': 'noindex (verberg voor zoekmachines)', 'pedit.nsfw_label': 'NSFW / gevoelige inhoud', 'pedit. nsfw_cw_ph': 'Waarschuwingstekst (optioneel, standaard: Gevoelige inhoud)', 'post.nsfw_warning': 'Gevoelige inhoud', 'post.nsfw_show': 'Tonen',696 'pedit.noindex_label': 'noindex (verberg voor zoekmachines)', 'pedit.nsfw_label': 'NSFW / gevoelige inhoud', 'pedit.fedi_audio_label': 'Audio openbaar delen op de fediverse (speelt inline in apps; bestand downloadbaar)', 'pedit.nsfw_cw_ph': 'Waarschuwingstekst (optioneel, standaard: Gevoelige inhoud)', 'post.nsfw_warning': 'Gevoelige inhoud', 'post.nsfw_show': 'Tonen', 697 697 'pedit.fan_only_label': 'Alleen voor ingelogde fans', 698 698 'pedit.schedule_label': 'Publicatie inplannen', … … 1609 1609 'pedit.pin_top': 'at the top', 1610 1610 'pedit.pin_nth_suffix': 'th from top', 1611 'pedit.noindex_label': 'noindex (hide from search engines)', 'pedit.nsfw_label': 'NSFW / sensitive content', 'pedit. nsfw_cw_ph': 'Warning text (optional, default: Sensitive content)', 'post.nsfw_warning': 'Sensitive content', 'post.nsfw_show': 'Show',1611 'pedit.noindex_label': 'noindex (hide from search engines)', 'pedit.nsfw_label': 'NSFW / sensitive content', 'pedit.fedi_audio_label': 'Share audio openly on the fediverse (plays inline in apps; file downloadable)', 'pedit.nsfw_cw_ph': 'Warning text (optional, default: Sensitive content)', 'post.nsfw_warning': 'Sensitive content', 'post.nsfw_show': 'Show', 1612 1612 'pedit.fan_only_label': 'Logged-in fans only', 1613 1613 'pedit.schedule_label': 'Schedule publication', … … 2524 2524 'pedit.pin_top': 'ganz oben', 2525 2525 'pedit.pin_nth_suffix': '. von oben', 2526 'pedit.noindex_label': 'noindex (vor Suchmaschinen verbergen)', 'pedit.nsfw_label': 'NSFW / sensibler Inhalt', 'pedit. nsfw_cw_ph': 'Warntext (optional, Standard: Sensibler Inhalt)', 'post.nsfw_warning': 'Sensibler Inhalt', 'post.nsfw_show': 'Anzeigen',2526 'pedit.noindex_label': 'noindex (vor Suchmaschinen verbergen)', 'pedit.nsfw_label': 'NSFW / sensibler Inhalt', 'pedit.fedi_audio_label': 'Audio offen im Fediverse teilen (spielt inline in Apps; Datei herunterladbar)', 'pedit.nsfw_cw_ph': 'Warntext (optional, Standard: Sensibler Inhalt)', 'post.nsfw_warning': 'Sensibler Inhalt', 'post.nsfw_show': 'Anzeigen', 2527 2527 'pedit.fan_only_label': 'Nur für angemeldete Fans', 2528 2528 'pedit.schedule_label': 'Veröffentlichung planen', -
src/views/pages/post-edit.ejs
r084d1c0 re0a1ec1 245 245 placeholder="<%= t('pedit.nsfw_cw_ph') %>" 246 246 style="width:100%;box-sizing:border-box;margin:6px 0 2px;font-size:13px;padding:7px 9px"> 247 <label class="pe-checkbox"> 248 <input type="checkbox" name="fedi_open_audio" value="1" <%= (typeof fediOpenAudio !== 'undefined' && fediOpenAudio) ? 'checked' : '' %>> 249 <span>🌐 <%= t('pedit.fedi_audio_label') %></span> 250 </label> 247 251 <script> 248 252 (function () {
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)