source: Klonkt/src/routes/admin-stats.js@ 3487567

main
Last change on this file since 3487567 was 3487567, checked in by Robin Genis <roboburr@…>, 2 months ago

fix(i18n): translate admin page titles (pageTitleKey instead of hardcoded strings)

Admin page/tab titles were hardcoded (mostly Dutch: Beheer, Instellingen, Nieuwsbrief, …).
renderPage now accepts pageTitleKey (+ pageTitleVars) and translates it with the resolved
language; the 16 admin routes pass keys. Adds admin.t_* keys in nl/en/de.

  • middleware/render.js — pageTitleKey support
  • services/i18n.js — admin.t_* title keys (nl/en/de)
  • routes/admin*.js — pageTitle string -> pageTitleKey
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * Admin: Statistics (premium module, god-only).
3 *
4 * GET /admin/stats -> cookie-free statistics: visitors/views per day,
5 * plays, and the most popular posts/tracks.
6 *
7 * Premium-gated via premiumUnlocked() (premium layer off = freely available;
8 * on = Patreon required). Tracking is in StatsService (no cookies).
9 */
10
11import express from 'express';
12import db from '../config/database.js';
13import { renderPage } from '../middleware/render.js';
14import { requireGod } from '../middleware/auth.js';
15import { premiumUnlocked } from '../services/PatreonService.js';
16import { getStats } from '../services/StatsService.js';
17
18const router = express.Router();
19
20router.get('/', requireGod, (req, res) => {
21 if (!premiumUnlocked()) {
22 return res.status(403).send('Statistieken is een premium-functie — koppel Patreon in Beheer → Instellingen.');
23 }
24 // Link-in-bio clicks (premium #6) for the current site.
25 let linkClicks = [];
26 if (res.locals.site) {
27 try {
28 linkClicks = db.prepare(
29 'SELECT url, clicks FROM link_clicks WHERE site_id = ? AND clicks > 0 ORDER BY clicks DESC LIMIT 50'
30 ).all(res.locals.site.id);
31 } catch { linkClicks = []; }
32 }
33 const days = [7, 14, 30, 90].includes(parseInt(req.query.days, 10)) ? parseInt(req.query.days, 10) : 14;
34 renderPage(req, res, 'pages/admin-stats', {
35 pageTitleKey: 'admin.t_stats',
36 bodyClass: 'on-admin',
37 stats: getStats(days),
38 linkClicks,
39 });
40});
41
42export default router;
Note: See TracBrowser for help on using the repository browser.