source: Klonkt/src/views/pages/admin-stats.ejs@ 69b509d

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

fix(i18n): localize the "Beheer" back-buttons + EPK save message (were hardcoded Dutch)

The "<- Beheer" back-link on the Audio/Playlists/Stats admin pages and the admin quick-links
aria-label were hardcoded Dutch in an otherwise i18n'd UI; now t('nav.admin'). The EPK editor's
save-confirmation + its two plain-text error responses were Dutch too; the save flash now uses
t(lang, 'aepk.saved') and the errors are English.

  • src/views/pages/admin-{audio,playlists,stats}.ejs, admin.ejs — back-link/aria-label -> t('nav.admin')
  • src/routes/admin-epk.js — translate save flash via resolveLang+t; English the error sends
  • src/services/i18n.js — aepk.saved (nl/en/de)

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

  • Property mode set to 100644
File size: 9.4 KB
Line 
1<div class="container stats-page">
2 <p><a href="/admin" class="btn">&larr; <%= t('nav.admin') %></a></p>
3 <h1><%= t('astat.title') %></h1>
4 <p class="stats-note"><%= t('astat.intro') %></p>
5
6 <% var s = stats; var _max = Math.max(1, ...s.series.map(function(d){ return d.pageviews; })); %>
7
8 <div class="stats-cards">
9 <div class="stat-card"><div class="stat-num"><%= s.totals.visitors %></div><div class="stat-label"><%= t('astat.visitor_days', { n: s.days }) %></div></div>
10 <div class="stat-card"><div class="stat-num"><%= s.totals.pageviews %></div><div class="stat-label"><%= t('astat.pageviews_days', { n: s.days }) %></div></div>
11 <div class="stat-card"><div class="stat-num"><%= s.totals.plays %></div><div class="stat-label"><%= t('astat.plays_total') %></div></div>
12 <div class="stat-card"><div class="stat-num"><%= s.totals.postViews %></div><div class="stat-label"><%= t('astat.postviews_total') %></div></div>
13 </div>
14
15 <% if (typeof s.allTime !== 'undefined') { %>
16 <p class="stats-note"><%= t('astat.alltime_pre') %> <strong><%= s.allTime.pageviews %></strong> <%= t('astat.alltime_mid') %> · <strong><%= s.allTime.visitorDays %></strong> <%= t('astat.alltime_post') %></p>
17 <% } %>
18
19 <details class="stats-help">
20 <summary><%= t('astat.help_summary') %></summary>
21 <div class="stats-help-body">
22 <dl class="stats-help-defs">
23 <div><dt><%= t('astat.help_vd_term') %></dt><dd><%= t('astat.help_vd_a') %> <em><%= t('astat.help_vd_em') %></em><%= t('astat.help_vd_b') %></dd></div>
24 <div><dt><%= t('astat.help_pv_term') %></dt><dd><%= t('astat.help_pv') %></dd></div>
25 <div><dt><%= t('astat.help_plays_term') %></dt><dd><%= t('astat.help_plays') %></dd></div>
26 <div><dt><%= t('astat.help_postviews_term') %></dt><dd><%= t('astat.help_postviews') %></dd></div>
27 </dl>
28 <p class="stats-help-note"><%= t('astat.help_footer') %></p>
29 </div>
30 </details>
31
32 <div class="stats-period">
33 <%= t('astat.period') %>
34 <% [7,14,30,90].forEach(function(n){ %>
35 <a href="/admin/stats?days=<%= n %>" class="<%= s.days === n ? 'is-on' : '' %>"><%= n %>d</a>
36 <% }); %>
37 </div>
38
39 <section class="stats-chart-wrap">
40 <div class="stats-chart-head">
41 <h2><%= t('astat.last_n_days', { n: s.days }) %></h2>
42 <div class="stats-legend">
43 <span class="lg lg-vis"><%= t('astat.lg_visitor_days') %></span>
44 <span class="lg lg-pv"><%= t('astat.lg_pageviews') %></span>
45 </div>
46 </div>
47 <div class="stats-chart">
48 <% var _step = s.days <= 14 ? 1 : (s.days <= 31 ? 4 : 10);
49 s.series.forEach(function(d, i){
50 var pvPct = Math.round(d.pageviews / _max * 100);
51 var visPct = Math.round(d.visitors / _max * 100);
52 %>
53 <div class="sc-col" title="<%= t('astat.bar_title', { day: d.day, pv: d.pageviews, vd: d.visitors }) %>">
54 <div class="sc-bar">
55 <span class="sc-pv" style="height: <%= pvPct %>%"></span>
56 <span class="sc-vis" style="height: <%= visPct %>%"></span>
57 </div>
58 <span class="sc-day"><%= (i % _step === 0) ? d.day.slice(8) : '' %></span>
59 </div>
60 <% }); %>
61 </div>
62 </section>
63
64 <div class="stats-tops">
65 <section class="stats-top">
66 <h2><%= t('astat.top_posts') %></h2>
67 <% if (!s.topPosts.length || s.topPosts[0].views === 0) { %>
68 <p class="stats-empty"><%= t('astat.no_views') %></p>
69 <% } else { %>
70 <ol>
71 <% s.topPosts.forEach(function(p){ %>
72 <li><a href="/<%= p.slug %>"><%= p.title %></a><span class="stats-count"><%= p.views %></span></li>
73 <% }); %>
74 </ol>
75 <% } %>
76 </section>
77 <section class="stats-top">
78 <h2><%= t('astat.most_played') %></h2>
79 <% if (!s.topTracks.length || s.topTracks[0].plays === 0) { %>
80 <p class="stats-empty"><%= t('astat.no_plays') %></p>
81 <% } else { %>
82 <ol>
83 <% s.topTracks.forEach(function(t){ %>
84 <li><span><%= t.title %></span><span class="stats-count"><%= t.plays %></span></li>
85 <% }); %>
86 </ol>
87 <% } %>
88 </section>
89 </div>
90
91 <% if (typeof s.referrers !== 'undefined' && s.referrers.length) { %>
92 <section class="stats-top" style="margin-top:1.2rem">
93 <h2>🌐 <%= t('astat.sources') %></h2>
94 <ol>
95 <% s.referrers.forEach(function(r){ %>
96 <li><span><%= r.host %></span><span class="stats-count"><%= r.n %></span></li>
97 <% }); %>
98 </ol>
99 </section>
100 <% } %>
101
102 <% if (typeof linkClicks !== 'undefined' && linkClicks.length) { %>
103 <section class="stats-top" style="margin-top:1.2rem">
104 <h2>🔗 <%= t('astat.linkbio_clicks') %></h2>
105 <ol>
106 <% linkClicks.forEach(function(l){ %>
107 <li><a href="<%= l.url %>" target="_blank" rel="noopener"><%= l.url.replace(/^https?:\/\//,'').slice(0,48) %></a><span class="stats-count"><%= l.clicks %></span></li>
108 <% }); %>
109 </ol>
110 </section>
111 <% } %>
112</div>
113
114<style>
115.stats-page { max-width: 820px; margin: 2.5rem auto; padding: 0 1rem; }
116.stats-page h1 { font-family: var(--font-display, serif); font-size: 2rem; margin: .5rem 0 .25rem; }
117.stats-note { color: var(--ink-muted); font-size: .85rem; margin: 0 0 1.5rem; max-width: 60ch; }
118.stats-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 2rem; }
119.stat-card { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.1rem; }
120.stat-num { font-family: var(--font-display, serif); font-size: 1.9rem; line-height: 1; color: var(--accent); }
121.stat-label { color: var(--ink-muted); font-size: .82rem; margin-top: .35rem; }
122
123.stats-chart-wrap { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 12px; padding: 1.1rem 1.2rem 1rem; margin-bottom: 2rem; }
124.stats-chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
125.stats-chart-head h2 { font-size: 1.05rem; margin: 0; }
126.stats-legend { display: flex; gap: .9rem; font-size: .78rem; color: var(--ink-muted); }
127.lg::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
128.lg-vis::before { background: var(--accent); }
129.lg-pv::before { background: color-mix(in srgb, var(--accent) 28%, transparent); }
130.stats-chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; margin-top: 1rem; overflow: hidden; }
131.sc-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
132.sc-bar { position: relative; width: 70%; max-width: 26px; min-width: 2px; height: 140px; display: flex; align-items: flex-end; }
133.sc-day { white-space: nowrap; }
134.sc-pv, .sc-vis { position: absolute; bottom: 0; left: 0; width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; }
135.sc-pv { background: color-mix(in srgb, var(--accent) 28%, transparent); }
136.sc-vis { background: var(--accent); }
137.sc-day { font-size: .68rem; color: var(--ink-muted); margin-top: .35rem; }
138
139.stats-tops { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
140@media (max-width: 560px) { .stats-tops { grid-template-columns: 1fr; } }
141.stats-top { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 12px; padding: 1rem 1.2rem; }
142.stats-top h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
143.stats-top ol { margin: 0; padding-left: 1.2rem; }
144.stats-top li { padding: .35rem 0; display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
145.stats-top a { color: var(--ink); text-decoration: none; }
146.stats-top a:hover { color: var(--accent); }
147.stats-count { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
148.stats-empty { color: var(--ink-muted); font-size: .88rem; margin: 0; }
149.stats-period { margin: .2rem 0 1.2rem; font-size: .9rem; color: var(--ink-muted); }
150.stats-period a { display: inline-block; margin-left: .4rem; padding: .2rem .6rem; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; color: var(--ink); }
151.stats-period a.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
152.stats-help { border: 1px solid var(--rule); border-radius: 12px; background: var(--paper-2); margin: 0 0 1.25rem; }
153.stats-help summary { cursor: pointer; padding: .7rem 1rem; font-weight: 600; font-size: .9rem; list-style: none; display: flex; align-items: center; gap: .5rem; }
154.stats-help summary::-webkit-details-marker { display: none; }
155.stats-help summary::before { content: '\203A'; font-size: 1.15rem; line-height: 1; color: var(--ink-soft); transition: transform .15s; }
156.stats-help[open] summary::before { transform: rotate(90deg); }
157.stats-help-body { padding: 0 1rem 1rem; }
158.stats-help-defs { margin: 0; }
159.stats-help-defs > div { display: grid; grid-template-columns: 130px 1fr; gap: .2rem 1.1rem; align-items: baseline;
160 padding: .55rem 0; border-top: 1px solid color-mix(in srgb, var(--rule) 55%, transparent); }
161.stats-help-defs dt { font-weight: 700; font-size: .85rem; color: var(--ink); }
162.stats-help-defs dd { margin: 0; font-size: .85rem; line-height: 1.5; color: var(--ink-soft); }
163.stats-help-defs dd em { font-style: italic; color: var(--ink); }
164.stats-help-note { margin: .85rem 0 0; padding-top: .7rem; border-top: 1px solid var(--rule);
165 font-size: .8rem; line-height: 1.55; color: var(--ink-muted); }
166@media (max-width: 480px) { .stats-help-defs > div { grid-template-columns: 1fr; gap: .1rem; } }
167</style>
Note: See TracBrowser for help on using the repository browser.