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

main
Last change on this file since abbb72a was 92a2c46, checked in by Robin <roboburr@…>, 8 weeks ago

Fix: three UI nits (interact page title i18n, Apple icon, stats columns)

  1. authorize_interaction page title was hardcoded Dutch ('Interacteer via de fediverse'); both renders now use pageTitleKey (fedi.remote_interact / fedi.manage_title) so the tab title follows the interface language. Verified: an English UI now titles 'Interact via the fediverse'.
  2. The Apple Music platform icon was a garbled path that did not read as the Apple logo; replaced with the classic Apple mark. Verified visually at 96px.
  3. Stats chart columns jumped in the 30/90-day views: unlabeled .sc-day spans collapsed to 0 height. Unlabeled columns now hold an NBSP (Bart's suggestion) so every column keeps its label line. Verified: 30-day view has one unique bar baseline and uniform label heights; 90-day has 0 empty spans.

Reported by Bart.

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

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