Changeset 834bcc3 in Klonkt for src/routes/download.js


Ignore:
Timestamp:
06/23/2026 06:14:27 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
d774679
Parents:
bb42dfb
Message:

i18n: translate Dutch code comments to English across src/

Comments in routes/services/views/config/middleware/assets translated to
English for the public repo. A few dev-facing throw/console message strings
were Englished too. No user-facing UI strings or i18n dictionary values changed
(src/services/i18n.js untouched). Logic unchanged.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/download.js

    rbb42dfb r834bcc3  
    11/**
    2  * Download-voor-email (premium feature #2).
     2 * Download-for-email (premium feature #2).
    33 *
    4  *   GET  /downloads                 -> lijst van downloadbare tracks (premium; anders 404)
    5  *   GET  /download/:id              -> e-mail-capture-pagina voor één track
    6  *   POST /download/:id              -> e-mail opslaan (-> mailinglijst) + download vrijgeven
    7  *   GET  /download/:id/bestand      -> serveert het bestand (sessie-gated na capture)
     4 *   GET  /downloads                 -> list of downloadable tracks (premium; 404 otherwise)
     5 *   GET  /download/:id              -> email capture page for a single track
     6 *   POST /download/:id              -> save email (-> mailing list) + unlock download
     7 *   GET  /download/:id/bestand      -> serves the file (session-gated after capture)
    88 *
    9  * De fan laat z'n e-mail achter en krijgt het bestand; het adres komt in de
    10  * subscribers-lijst (source 'download', single opt-in — geen confirm-drempel vóór de
     9 * The fan leaves their email and receives the file; the address is added to the
     10 * subscribers list (source 'download', single opt-in — no confirm step before the
    1111 * download). Hub: via /user/:slug/... (resolveSite + siteUrlBase).
    1212 */
     
    2424const router = express.Router();
    2525
    26 // Als er een echte (gepinde) post met slug 'downloads' bestaat, hangt de
    27 // downloads-lijst feitelijk aan die post. Dan tonen we óók de Newer/Older-postnav,
    28 // zodat de bezoeker net als bij een post verder kan bladeren.
     26// If a real (pinned) post with slug 'downloads' exists, the downloads list is
     27// effectively attached to that post. We then also show the Newer/Older post nav
     28// so the visitor can browse just like on a regular post.
    2929function downloadsPostNav(req, res) {
    3030  const site = res.locals.site;
     
    4040
    4141const MIME = { '.mp3': 'audio/mpeg', '.wav': 'audio/wav', '.flac': 'audio/flac', '.m4a': 'audio/mp4', '.ogg': 'audio/ogg' };
    42 const GRACE_MS = 15 * 60 * 1000; // download-venster na capture
     42const GRACE_MS = 15 * 60 * 1000; // download window after capture
    4343
    4444function dlTrack(siteId, id) {
     
    5555}
    5656
    57 // Lijst van downloadbare tracks.
     57// List of downloadable tracks.
    5858router.get('/downloads', (req, res, next) => {
    5959  if (!premiumUnlocked()) return next();
     
    6767  renderPage(req, res, 'pages/downloads', {
    6868    pageTitle: 'Downloads — ' + (site.title || ''),
    69     // on-special = compacte profielkop (zoals op een post); on-downloads = pill grijs
    70     // + feature-route-gedrag. Samen → downloads ziet er net zo uit als een post.
     69    // on-special = compact profile header (like on a post); on-downloads = grey pill
     70    // + feature-route behaviour. Together → downloads looks just like a post.
    7171    bodyClass: 'on-downloads on-special',
    7272    dlTracks: tracks,
     
    7676});
    7777
    78 // Capture-pagina voor één track.
     78// Capture page for a single track.
    7979router.get('/download/:id', (req, res, next) => {
    8080  if (!premiumUnlocked()) return next();
     
    9393});
    9494
    95 // E-mail opslaan + download vrijgeven.
     95// Save email + unlock download.
    9696router.post('/download/:id', (req, res, next) => {
    9797  if (!premiumUnlocked()) return next();
     
    109109    });
    110110  }
    111   // Download vrijgeven in de sessie (kort venster).
     111  // Unlock download in the session (short window).
    112112  if (!req.session.dl) req.session.dl = {};
    113113  req.session.dl[track.id] = Date.now();
     
    118118});
    119119
    120 // Het bestand serveren — alleen als er net een e-mail is achtergelaten (sessie).
     120// Serve the file — only if an email was just submitted (session-gated).
    121121router.get('/download/:id/bestand', (req, res, next) => {
    122122  if (!premiumUnlocked()) return next();
     
    129129    return res.status(403).send('Laat eerst je e-mailadres achter om te downloaden.');
    130130  }
    131   // De speelbare/te-downloaden file = de KALE filename (storage_path is een
    132   // absoluut pad → faalt de slash-guard). Zelfde aanpak als /audio/stream.
     131  // The playable/downloadable file = the BARE filename (storage_path is an
     132  // absolute path → fails the slash-guard). Same approach as /audio/stream.
    133133  const sp = track.filename;
    134134  if (!sp || sp.includes('/') || sp.includes('\\') || sp.includes('..')) return res.status(400).send('Bad path');
Note: See TracChangeset for help on using the changeset viewer.