Changeset 97bcf7e in Klonkt
- Timestamp:
- 07/30/2026 07:47:53 AM (6 weeks ago)
- Branches:
- main
- Children:
- 7d01696
- Parents:
- 6089c53
- Location:
- src
- Files:
-
- 1 added
- 5 edited
-
assets/css/style.css (modified) (1 diff)
-
routes/admin-media.js (modified) (2 diffs)
-
services/ActivityPubService.js (modified) (1 diff)
-
services/i18n.js (modified) (3 diffs)
-
views/pages/admin-videos.ejs (added)
-
views/partials/media-tabs.ejs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/css/style.css
r6089c53 r97bcf7e 773 773 margin: 1.4em auto; 774 774 } 775 776 /* Video in de post-tekst (C2S-uploads uit Shaer): dezelfde maatvoering als 777 afbeeldingen, plus een plafond. Zonder deze regel rendert een <video> op 778 zijn natuurlijke maat en duwt een portret-video de hele kolom vol; met 779 object-fit blijft het beeld heel binnen het kader. Geldt ook voor de 780 Krant/Berichten (tl-content), waar dezelfde content langskomt. */ 781 .post-content video, .tl-content video { 782 display: block; 783 width: 100%; 784 max-width: 100%; 785 max-height: min(70vh, 540px); 786 height: auto; 787 object-fit: contain; 788 background: #000; 789 border-radius: 6px; 790 margin: 1.4em auto; 791 } 792 .post-content audio, .tl-content audio { width: 100%; display: block; margin: 1em auto; } 775 793 776 794 /* Mini-player + bottom-tab clearance: applied to .pcms-main so the footer -
src/routes/admin-media.js
r6089c53 r97bcf7e 24 24 25 25 const IMG_EXT = /\.(jpe?g|png|webp|gif|avif)$/i; 26 const VIDEO_EXT = /\.(mp4|webm|m4v|mov)$/i; 27 // C2S uploads (Shaer's composer and the help buoy) land here; the videos among 28 // them are what the Video tab shows. 29 const REPLY_MEDIA_DIR = path.resolve( 30 process.env.REPLY_MEDIA_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'reply-media') 31 ); 26 32 const isSibling = (f) => /-v\.(mp4|jpg)$/i.test(f); // an animated cover's video/poster sibling 27 33 … … 90 96 91 97 // Delete one image + its loop-MP4 / poster siblings. Basename-only + within-dir → no traversal. 98 // ── The Video tab (Robins opdracht, 30-7) ───────────────────────────────── 99 // Videos live in reply-media (C2S uploads: Shaer's composer, the help buoy). 100 // Usage is a content/attachment reference from a post, exactly like images. 101 102 function videoEntries(siteId) { 103 const posts = db.prepare('SELECT id, content, c2s_attachments FROM posts WHERE site_id = ?').all(siteId); 104 const used = new Map(); 105 const add = (fn, id) => { if (!fn) return; if (!used.has(fn)) used.set(fn, new Set()); used.get(fn).add(id); }; 106 for (const p of posts) { 107 for (const m of String(p.content || '').matchAll(/\/media\/reply-media\/([^/?#"'\s)]+)/g)) add(m[1], p.id); 108 try { for (const a of JSON.parse(p.c2s_attachments || '[]')) { const m = String(a.url || '').match(/\/media\/reply-media\/([^/?#"'\s)]+)/); if (m) add(m[1], p.id); } } catch { /* malformed never blocks the list */ } 109 } 110 let all = []; 111 try { all = fs.readdirSync(REPLY_MEDIA_DIR).filter(f => !f.startsWith('.')); } catch { /* dir may not exist yet */ } 112 const vstat = (name, key) => { try { const st = fs.statSync(path.join(REPLY_MEDIA_DIR, name)); return key === 'size' ? st.size : st.mtimeMs; } catch { return 0; } }; 113 return all 114 .filter(f => VIDEO_EXT.test(f)) 115 .map(f => ({ 116 file: f, 117 url: `/media/reply-media/${f}`, 118 kb: Math.round(vstat(f, 'size') / 1024), 119 usedCount: (used.get(f) || new Set()).size, 120 _mtime: vstat(f, 'mtime'), 121 })) 122 .sort((a, b) => b._mtime - a._mtime); 123 } 124 125 router.get('/videos', requireGod, (req, res) => { 126 const site = res.locals.site; 127 if (!site) return res.status(404).send('Site required'); 128 renderPage(req, res, 'pages/admin-videos', { 129 pageTitleKey: 'admin.t_media', 130 bodyClass: 'on-admin', 131 items: videoEntries(site.id), 132 audioOn: audioEnabled(), 133 success: req.query.success || null, 134 }); 135 }); 136 137 // Delete one video. Basename-only + within-dir, and only when no post uses it: 138 // the same guardrails the image delete has. 139 router.post('/videos/delete', requireGod, (req, res) => { 140 const site = res.locals.site; 141 if (!site) return res.status(404).json({ error: 'site' }); 142 const file = path.basename(String(req.body?.file || '')); 143 if (!file || !VIDEO_EXT.test(file)) return res.status(400).json({ error: 'bad_file' }); 144 const entry = videoEntries(site.id).find(e => e.file === file); 145 if (!entry) return res.status(404).json({ error: 'not_found' }); 146 if (entry.usedCount) return res.status(409).json({ error: 'in_use' }); 147 try { fs.unlinkSync(path.join(REPLY_MEDIA_DIR, file)); } catch { /* already gone is gone */ } 148 res.json({ ok: true }); 149 }); 150 92 151 router.post('/delete', requireGod, (req, res) => { 93 152 if (!res.locals.site) return res.status(404).json({ ok: false, error: 'Site required' }); -
src/services/ActivityPubService.js
r6089c53 r97bcf7e 2389 2389 if (a.mediaType.startsWith('image/')) return `<p><img src="${a.url}" alt="${esc(a.name)}"></p>`; 2390 2390 if (a.mediaType.startsWith('audio/')) return `<p><audio controls preload="metadata" src="${a.url}"></audio></p>`; 2391 return `<p><video controls playsinline src="${a.url}"></video></p>`;2391 return `<p><video controls playsinline preload="metadata" src="${a.url}"></video></p>`; 2392 2392 }).join(''); 2393 2393 const postId = crypto.randomUUID(); -
src/services/i18n.js
r6089c53 r97bcf7e 74 74 'admin.tagline_hub': 'Hub-modus — bedrijfssite met gebruikers, elk hun eigen Klonkt Hub.', 75 75 'admin.b_sites': '🌐 Sites', 'admin.b_users': '👥 Gebruikers', 'admin.b_audio': '🎵 Audio', 76 'admin.b_media': '🎬 Media', 'admin.t_media': 'Media', 'admin.media_images': 'Afbeeldingen', 'admin.media_ count': 'afbeeldingen', 'admin.media_unused': 'ongebruikt', 'admin.media_cleanup': 'Ongebruikt opruimen', 'admin.media_cleanup_confirm': 'Alle ongebruikte afbeeldingen verwijderen?', 'admin.media_empty': 'Nog geen afbeeldingen geüpload.', 'admin.media_copy': 'Kopieer URL', 'admin.media_del_confirm': 'Deze afbeelding verwijderen?',76 'admin.b_media': '🎬 Media', 'admin.t_media': 'Media', 'admin.media_images': 'Afbeeldingen', 'admin.media_videos': "Video's", 'admin.videos_count': "video's", 'admin.videos_empty': "Nog geen video's geupload.", 'admin.videos_del_confirm': 'Deze video verwijderen?', 'admin.media_count': 'afbeeldingen', 'admin.media_unused': 'ongebruikt', 'admin.media_cleanup': 'Ongebruikt opruimen', 'admin.media_cleanup_confirm': 'Alle ongebruikte afbeeldingen verwijderen?', 'admin.media_empty': 'Nog geen afbeeldingen geüpload.', 'admin.media_copy': 'Kopieer URL', 'admin.media_del_confirm': 'Deze afbeelding verwijderen?', 77 77 'admin.b_playlists': '📃 Playlists', 'admin.b_comments': '💬 Reacties', 'admin.b_seo': '🔎 SEO', 78 78 'admin.b_settings': '⚙️ Instellingen', 'admin.b_newpost': '✍️ Nieuwe post', 'admin.b_look': '🎨 Uiterlijk', … … 1015 1015 'admin.tagline_hub': 'Hub mode — a company site with users, each their own Klonkt Hub.', 1016 1016 'admin.b_sites': '🌐 Sites', 'admin.b_users': '👥 Users', 'admin.b_audio': '🎵 Audio', 1017 'admin.b_media': '🎬 Media', 'admin.t_media': 'Media', 'admin.media_images': 'Images', 'admin.media_ count': 'images', 'admin.media_unused': 'unused', 'admin.media_cleanup': 'Delete unused', 'admin.media_cleanup_confirm': 'Delete all unused images?', 'admin.media_empty': 'No images uploaded yet.', 'admin.media_copy': 'Copy URL', 'admin.media_del_confirm': 'Delete this image?',1017 'admin.b_media': '🎬 Media', 'admin.t_media': 'Media', 'admin.media_images': 'Images', 'admin.media_videos': 'Videos', 'admin.videos_count': 'videos', 'admin.videos_empty': 'No videos uploaded yet.', 'admin.videos_del_confirm': 'Delete this video?', 'admin.media_count': 'images', 'admin.media_unused': 'unused', 'admin.media_cleanup': 'Delete unused', 'admin.media_cleanup_confirm': 'Delete all unused images?', 'admin.media_empty': 'No images uploaded yet.', 'admin.media_copy': 'Copy URL', 'admin.media_del_confirm': 'Delete this image?', 1018 1018 'admin.b_playlists': '📃 Playlists', 'admin.b_comments': '💬 Comments', 'admin.b_seo': '🔎 SEO', 1019 1019 'admin.b_settings': '⚙️ Settings', 'admin.b_newpost': '✍️ New post', 'admin.b_look': '🎨 Appearance', … … 1950 1950 'admin.tagline_hub': 'Hub-Modus — eine Firmenseite mit Nutzern, je ein eigener Klonkt Hub.', 1951 1951 'admin.b_sites': '🌐 Seiten', 'admin.b_users': '👥 Nutzer', 'admin.b_audio': '🎵 Audio', 1952 'admin.b_media': '🎬 Medien', 'admin.t_media': 'Medien', 'admin.media_images': 'Bilder', 'admin.media_ count': 'Bilder', 'admin.media_unused': 'ungenutzt', 'admin.media_cleanup': 'Ungenutzte löschen', 'admin.media_cleanup_confirm': 'Alle ungenutzten Bilder löschen?', 'admin.media_empty': 'Noch keine Bilder hochgeladen.', 'admin.media_copy': 'URL kopieren', 'admin.media_del_confirm': 'Dieses Bild löschen?',1952 'admin.b_media': '🎬 Medien', 'admin.t_media': 'Medien', 'admin.media_images': 'Bilder', 'admin.media_videos': 'Videos', 'admin.videos_count': 'Videos', 'admin.videos_empty': 'Noch keine Videos hochgeladen.', 'admin.videos_del_confirm': 'Dieses Video löschen?', 'admin.media_count': 'Bilder', 'admin.media_unused': 'ungenutzt', 'admin.media_cleanup': 'Ungenutzte löschen', 'admin.media_cleanup_confirm': 'Alle ungenutzten Bilder löschen?', 'admin.media_empty': 'Noch keine Bilder hochgeladen.', 'admin.media_copy': 'URL kopieren', 'admin.media_del_confirm': 'Dieses Bild löschen?', 1953 1953 'admin.b_playlists': '📃 Playlists', 'admin.b_comments': '💬 Kommentare', 'admin.b_seo': '🔎 SEO', 1954 1954 'admin.b_settings': '⚙️ Einstellungen', 'admin.b_newpost': '✍️ Neuer Beitrag', 'admin.b_look': '🎨 Aussehen', -
src/views/partials/media-tabs.ejs
r6089c53 r97bcf7e 1 <%# Shared Media tab bar (Afbeeldingen / Audio / Playlists). Params: active = 'images'|' audio'|'playlists'; audioOn (bool, default true). %>1 <%# Shared Media tab bar (Afbeeldingen / Audio / Playlists). Params: active = 'images'|'videos'|'audio'|'playlists'; audioOn (bool, default true). %> 2 2 <% var _a = (typeof audioOn === 'undefined') ? true : audioOn; %> 3 3 <nav class="media-tabs" aria-label="Media" style="display:flex;gap:.4rem;margin:0 0 1.25rem;border-bottom:1px solid var(--rule,rgba(128,128,128,.3));flex-wrap:wrap;"> 4 4 <a href="/admin/media" class="btn" style="border-radius:8px 8px 0 0;<%= active === 'images' ? 'border-bottom:2px solid var(--accent,#e8b04b);font-weight:600;' : 'opacity:.8;' %>"><%= t('admin.media_images') %></a> 5 <a href="/admin/media/videos" class="btn" style="border-radius:8px 8px 0 0;<%= active === 'videos' ? 'border-bottom:2px solid var(--accent,#e8b04b);font-weight:600;' : 'opacity:.8;' %>"><%= t('admin.media_videos') %></a> 5 6 <% if (_a) { %> 6 7 <a href="/admin/audio" class="btn" style="border-radius:8px 8px 0 0;<%= active === 'audio' ? 'border-bottom:2px solid var(--accent,#e8b04b);font-weight:600;' : 'opacity:.8;' %>"><%= t('admin.b_audio') %></a>
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)