source: Klonkt/src/views/pages/admin-stats.ejs@ 19a72df

main
Last change on this file since 19a72df was bbf9d1a, checked in by roboburr <roboburr@…>, 3 months ago

feat(i18n phase 5): all admin sub-pages translated (NL/EN/DE)

settings, site-edit, seo, google, audio, stats, playlists, users, sites,
comments, circle, shows, newsletter, updates, epk, help. ~520 new keys
per language. Loop-shadowing of t() resolved by fetching before the loop. 709
view-keys cross-checked against the dictionary (0 missing).

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

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