Changeset 68b27a4 in Klonkt for src/routes


Ignore:
Timestamp:
06/20/2026 07:28:43 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
0fcc09c
Parents:
d7b5a6c
Message:

feat(agenda): Agenda opt-in — only shown when enabled + active on /shows

  • New setting agenda_enabled (Admin → Agenda: toggle "Show agenda on the site").
  • Agenda button in the pill only appears when premium AND enabled.
  • /shows (+ /shows/notify) gated: disabled = 404 (not reachable).
  • On the agenda page, the Agenda item in the pill is now marked "active" (the pill stays visible there, as requested).

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

Location:
src/routes
Files:
2 edited

Legend:

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

    rd7b5a6c r68b27a4  
    1818import { mailerConfigured, sendMail } from '../config/mailer.js';
    1919import { confirmedFor, counts } from '../services/SubscriberService.js';
     20import { getSetting, setSetting } from '../services/SettingsService.js';
    2021
    2122const router = express.Router();
     
    3637    pageTitle: 'Agenda', bodyClass: 'on-admin',
    3738    shows, smtp: mailerConfigured(), notifyCount: confirmedFor(site.id, 'notify').length,
     39    agendaEnabled: getSetting('agenda_enabled') === '1',
    3840    ...extra,
    3941  });
     
    8385});
    8486
     87router.post('/toggle', requireSiteManager, premiumGate, (req, res) => {
     88  // Agenda tonen op de site (Agenda-knop in de pill + /shows-pagina).
     89  setSetting('agenda_enabled', req.body.enabled ? '1' : '0');
     90  res.redirect((res.locals.siteUrlBase || '') + '/admin/shows');
     91});
     92
    8593router.post('/:id/delete', requireSiteManager, premiumGate, (req, res) => {
    8694  const site = res.locals.site;
  • src/routes/shows.js

    rd7b5a6c r68b27a4  
    1616import { mailerConfigured, sendMail } from '../config/mailer.js';
    1717import { addSubscriber } from '../services/SubscriberService.js';
     18import { getSetting } from '../services/SettingsService.js';
    1819
    1920const router = express.Router();
     21
     22// Agenda is opt-in: pas bereikbaar als de beheerder 'm heeft ingeschakeld.
     23function agendaOn() { return getSetting('agenda_enabled') === '1'; }
    2024
    2125function esc(s) { return String(s || '').replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c])); }
     
    3034
    3135router.get('/shows', (req, res, next) => {
    32   if (!premiumUnlocked()) return next();
     36  if (!premiumUnlocked() || !agendaOn()) return next();
    3337  const site = res.locals.site;
    3438  if (!site) return next();
     
    4246
    4347router.post('/shows/notify', async (req, res, next) => {
    44   if (!premiumUnlocked()) return next();
     48  if (!premiumUnlocked() || !agendaOn()) return next();
    4549  const site = res.locals.site;
    4650  if (!site) return next();
Note: See TracChangeset for help on using the changeset viewer.