Stats per stream and period, public stats page, dashboard settings, Card alert style

Statistics
- Per day and per stream statistics (src/periodstats.js, one generic stat_day table), backfilled
  once from the older tables; Stream / Week / Month / Year / All time views, Community and Streams tabs.
- Viewer count every 5 minutes and title / category history per stream (EventSub channel.update):
  viewer graph, games played (donut), games in the streams list.
- Twitch sync (src/twitchsync.js): followers with follow dates, current subs, mods, VIPs, all-time
  bits, channel emotes, past streams from VODs. Twitch analytics CSV import (src/twitchcsv.js).
- Public stats page on its own host (Settings -> Stats and data): no message text, no bots,
  !hideme / !showme opt-out. Viewer page: roles, follow age, sub status, bits, a menu for rarely used actions.
- StreamElements watch-time importer removed (already imported minutes stay as a baseline).

Dashboard
- Settings and Actions with a left sidebar; each settings page saves only its own fields.
  Connections (Twitch, StreamElements token now set here, HUDFX), OBS links (hidden behind an eye
  toggle) with a link builder, Chat (sound picked from the media library), TTS, Stats and data,
  Backup (export / import the whole setup), Advanced. Time zone setting for the stats pages.
- Actions -> Alerts: alert style, pictures, sounds, bits tiers and card colours, stored in the
  database (src/theme.js); an old file-based theme is imported once. Alert preview page
  (/actions/alerts/preview, tools/preview/export.js for a static copy).
- Old /actions page removed; Actions = Redeems / Alerts / TTS voices / Media.

Alerts
- New plain Card style for everyone (public/alerts/card.js); Polaroid, Cassette and the TTS letter
  stay as optional looks. Redeem variations can be Card, Cassette, Sound only or Video.

Repo
- No channel data in git: the channel's art, stickers and sounds stay on disk (gitignored) and are
  picked in the dashboard; examples for the server config (apache.example.sh, .env.example).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-23 11:22:49 +02:00
parent 5bf4bffaa0
commit c481ca92cb
57 changed files with 3080 additions and 774 deletions

72
views/public_stats.ejs Normal file
View file

@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= displayName %> · Stream stats</title>
<meta name="description" content="Stream statistics for <%= displayName %> on Twitch: streams, chat, emotes, leaderboards.">
<%# viewer names are listed: keep the page out of search engines (remove this line to allow indexing) %>
<meta name="robots" content="noindex">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Caveat:wght@700&family=Nunito:wght@400;600;700;800;900&display=swap">
<style>
/* paper look of the overlay alerts (polaroid / letter): cream paper, ink, red, lilac washi tape */
:root { --bg:#f3ece2; --paper:#fffdf7; --ink:#3a2a20; --muted:#8a7565; --line:#e4d9cb; --accent:#b74347; --accent-hover:#9a3539;
--card:var(--paper); --card-solid:var(--paper); --tape:rgba(201,182,228,.85); --link:#b74347; }
@media (prefers-color-scheme: dark) {
:root { --bg:#1d1916; --paper:#2a2420; --ink:#f1e7da; --muted:#b09d8b; --line:#3d342d; --accent:#d0626a; --accent-hover:#e07a82;
--card:var(--paper); --card-solid:var(--paper); --tape:rgba(155,130,195,.7); --link:#e58b91; }
}
* { box-sizing:border-box; }
html, body { margin:0; background:var(--bg); color:var(--ink); }
body { font:400 15px/1.45 'Nunito', system-ui, sans-serif; }
a { color:var(--link); }
.wrap { max-width:1100px; margin:0 auto; padding:24px 16px 48px; }
header.hero { position:relative; background:var(--paper); padding:22px 24px 18px; margin:14px 0 22px; box-shadow:0 10px 24px rgba(0,0,0,.12);
transform:rotate(-.4deg); display:flex; flex-wrap:wrap; align-items:center; gap:.5rem 1.2rem; }
header.hero:before, header.hero:after { content:''; position:absolute; top:-14px; width:120px; height:32px; background-color:var(--tape);
background-image:repeating-linear-gradient(45deg,#fff6 0 8px,#0000 8px 16px); box-shadow:0 1px 2px rgba(0,0,0,.15); }
header.hero:before { left:-18px; transform:rotate(-8deg); }
header.hero:after { right:-18px; transform:rotate(7deg); }
header.hero h1 { font:700 46px/1 'Caveat', cursive; margin:0; }
header.hero h1 span { color:var(--accent); }
header.hero .sub { color:var(--muted); font-weight:600; }
.live { display:inline-flex; align-items:center; gap:.4rem; background:var(--accent); color:#fff; border-radius:99px; padding:.2rem .8rem;
font-weight:800; font-size:.85rem; text-decoration:none; margin-left:auto; }
.live:before { content:''; width:8px; height:8px; border-radius:50%; background:#fff; animation:blink 1.4s infinite; }
.watch { margin-left:auto; font-weight:700; text-decoration:none; }
@keyframes blink { 50% { opacity:.3; } }
.preview { background:#e6b800; color:#221a00; padding:.4rem .8rem; border-radius:8px; font-weight:700; font-size:.85rem; margin-bottom:.6rem; }
h3.sb-h { font:700 30px/1 'Caveat', cursive; margin:1.8rem 0 .7rem; }
.sb-tile .v { font-weight:900; }
.sb-board h4, .sb-chart h4 { font-weight:800; }
.sb-tabs a.on { color:#fff; }
code { font-family:ui-monospace, monospace; font-size:.9em; }
footer { margin-top:2.4rem; color:var(--muted); font-size:.85rem; border-top:1px dashed var(--line); padding-top:1rem; }
</style>
</head>
<body>
<div class="wrap">
<% if (preview) { %><div class="preview">Preview: the public page is off (Settings → Public stats page). Only you can see this.</div><% } %>
<header class="hero">
<h1><span><%= displayName %></span>'s stream stats</h1>
<span class="sub">the people who make the streams fun ♡</span>
<% if (live) { %>
<a class="live" href="https://twitch.tv/<%= encodeURIComponent(channel) %>" target="_blank" rel="noopener">live now</a>
<% } else if (channel) { %>
<a class="watch" href="https://twitch.tv/<%= encodeURIComponent(channel) %>" target="_blank" rel="noopener">twitch.tv/<%= channel %> ↗</a>
<% } %>
</header>
<%- include('_statsbody', { s, q, base: base || '/', viewerHref: null, mode: 'public', view, ranks, tz }) %>
<footer>
Chat activity and watch time are counted for these statistics; message text is never shown here.
Don't want your name on this page? Type <code>!hideme</code> in chat (you still count in the totals, unnamed);
<code>!showme</code> brings it back. To have your data deleted completely, ask in chat or whisper the streamer.
Days are UTC; numbers update every few minutes.
</footer>
</div>
</body>
</html>