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:
parent
5bf4bffaa0
commit
c481ca92cb
57 changed files with 3080 additions and 774 deletions
133
views/alerts_preview.ejs
Normal file
133
views/alerts_preview.ejs
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<!doctype html>
|
||||
<%#
|
||||
Alert preview: the real overlay code on a 1920x1080 stage, with a button for every alert. Served at
|
||||
/actions/alerts/preview (logged in) and exported as a static page by tools/export-preview.js.
|
||||
Locals: base ('/alerts/' or 'alerts/'), themes { key: { label, theme } }, start (theme key), samples (src/alerts.js SAMPLES).
|
||||
%>
|
||||
<html lang="en"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Alert preview</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Caveat:wght@700&family=Nunito:wght@700;800;900&display=block">
|
||||
<% for (const f of ['card', 'polaroid', 'cassette', 'fx']) { %><link rel="stylesheet" href="<%= base %><%= f %>.css"><% } %>
|
||||
<style>
|
||||
* { box-sizing:border-box; }
|
||||
html, body { margin:0; height:100%; background:#101014; color:#f1edf7; font-family:'Nunito', system-ui, sans-serif; }
|
||||
.wrap { display:grid; grid-template-columns:minmax(0, 1fr) 380px; height:100vh; }
|
||||
@media (max-width: 1000px) { .wrap { grid-template-columns:1fr; height:auto; } }
|
||||
.viewport { position:relative; overflow:hidden; display:grid; place-items:center; padding:16px; }
|
||||
.stage-box { position:relative; width:100%; aspect-ratio:16 / 9; max-height:calc(100vh - 32px); }
|
||||
#stage { position:absolute; left:0; top:0; width:1920px; height:1080px; transform-origin:0 0; overflow:hidden; border-radius:10px;
|
||||
background:var(--bg); box-shadow:0 10px 40px rgba(0,0,0,.5); }
|
||||
/* the alert elements are position:fixed in the overlay; inside the scaled stage they must follow the stage */
|
||||
#stage { contain:layout paint; transform-style:flat; }
|
||||
.bg-game { --bg:radial-gradient(1200px 700px at 30% 40%, #3a5f4f, #16261f 70%), #16261f; }
|
||||
.bg-dark { --bg:#1b1b22; }
|
||||
.bg-light { --bg:#e9e6ef; }
|
||||
.bg-check { --bg:repeating-conic-gradient(#2a2a33 0 25%, #22222a 0 50%) 0 0 / 40px 40px; }
|
||||
.scene { position:absolute; inset:0; pointer-events:none; }
|
||||
.scene .cam { position:absolute; right:60px; bottom:60px; width:480px; height:270px; border-radius:18px; background:rgba(255,255,255,.08);
|
||||
border:2px dashed rgba(255,255,255,.18); display:grid; place-items:center; color:rgba(255,255,255,.35); font:800 26px Nunito; }
|
||||
.panel { overflow:auto; background:#191720; border-left:1px solid #2b2836; padding:16px 18px 30px; }
|
||||
.panel h1 { font-size:20px; margin:0 0 4px; }
|
||||
.note { font-size:13px; color:#b9b0cc; margin:0 0 10px; line-height:1.4; }
|
||||
h3 { font-size:12px; letter-spacing:.12em; color:#b9a3ec; margin:16px 0 7px; text-transform:uppercase; }
|
||||
.row { display:flex; flex-wrap:wrap; gap:6px; }
|
||||
button { font:800 13px 'Nunito'; border:0; border-radius:14px; padding:6px 12px; cursor:pointer; background:#2c2838; color:#f1edf7; }
|
||||
button:hover { background:#3b3550; }
|
||||
button.on { background:#9146ff; color:#fff; }
|
||||
button.alt { background:#efe6ff; color:#2a1d40; }
|
||||
.colors { display:flex; gap:12px; flex-wrap:wrap; font-size:13px; align-items:center; }
|
||||
.colors label { display:flex; gap:6px; align-items:center; }
|
||||
.colors input { width:34px; height:26px; border:0; padding:0; background:none; }
|
||||
#log { font:700 12px monospace; color:#c9ffd8; margin-top:14px; min-height:1.2em; }
|
||||
</style></head><body>
|
||||
<div class="wrap">
|
||||
<div class="viewport"><div class="stage-box" id="box"><div id="stage" class="bg-game"><div class="scene"><div class="cam">camera</div></div></div></div></div>
|
||||
<div class="panel">
|
||||
<h1>Alert preview</h1>
|
||||
<p class="note">The real overlay code. Click a button to play an alert; a click replaces the one showing. Click anywhere once first so the browser allows sound.</p>
|
||||
|
||||
<h3>Look</h3>
|
||||
<div class="row" id="themes"><% for (const [k, t] of Object.entries(themes)) { %><button data-theme="<%= k %>"><%= t.label %></button><% } %></div>
|
||||
<div class="row" style="margin-top:6px;" id="styles">
|
||||
<button data-style="card">Alerts: Card</button><button data-style="polaroid">Alerts: Polaroid</button>
|
||||
</div>
|
||||
<div class="colors" style="margin-top:8px;">
|
||||
<label><input type="color" data-c="accent"> accent</label><label><input type="color" data-c="bg"> card</label><label><input type="color" data-c="text"> text</label>
|
||||
</div>
|
||||
|
||||
<h3>Background</h3>
|
||||
<div class="row" id="bgs"><button data-bg="bg-game" class="on">Game</button><button data-bg="bg-dark">Dark</button><button data-bg="bg-light">Light</button><button data-bg="bg-check">Transparent</button></div>
|
||||
|
||||
<h3>Follows and subs</h3>
|
||||
<div class="row"><% for (const [k, l] of [['follow', 'Follow'], ['sub-new', 'New sub'], ['sub-prime', 'Prime'], ['sub-resub', 'Resub 14 months'], ['sub-6', '6 months at once'], ['gift-1', 'Gift 1'], ['gift-10', 'Gift 10'], ['gift-anon', 'Anonymous gift']]) { %><button data-k="<%= k %>"><%= l %></button><% } %></div>
|
||||
<h3>Bits, tips, raids</h3>
|
||||
<div class="row"><% for (const [k, l] of [['bits-20', '20 bits'], ['bits-120', '120 bits'], ['bits-500', '500 bits'], ['tip-5', 'Tip 5'], ['tip-100', 'Tip 100'], ['raid', 'Raid'], ['streak', 'Watch streak']]) { %><button data-k="<%= k %>"><%= l %></button><% } %></div>
|
||||
<h3>Hype Train</h3>
|
||||
<div class="row"><% for (const [k, l] of [['hype-begin', 'Start'], ['hype-level', 'Level up'], ['hype-end', 'End'], ['hype-golden', 'Golden Kappa']]) { %><button data-k="<%= k %>"><%= l %></button><% } %></div>
|
||||
<h3>Redeems</h3>
|
||||
<div class="row">
|
||||
<button data-r="card">Card</button><button data-r="cassette">Cassette</button><button data-r="cassette-rare">Cassette rare</button><button data-r="cassette-ultra">Cassette ultra rare</button>
|
||||
<button data-r="tts">Read aloud</button><button data-r="message">Highlight message</button><button data-r="emote">Gigantify emote</button><button data-r="rain">Celebration</button>
|
||||
</div>
|
||||
<h3>Queue</h3>
|
||||
<div class="row"><button data-queue class="alt">4 alerts at once</button><button data-reset>Stop</button></div>
|
||||
<div id="log">ready</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.ALERTS_BASE = <%- JSON.stringify(base) %>;
|
||||
const THEMES = <%- JSON.stringify(Object.fromEntries(Object.entries(themes).map(([k, t]) => [k, t.theme]))).replace(/</g, '\\u003c') %>;
|
||||
window.S = { alert_theme: JSON.parse(JSON.stringify(THEMES[<%- JSON.stringify(start) %>])) };
|
||||
</script>
|
||||
<% for (const f of ['card', 'cassette', 'fx', 'polaroid']) { %><script src="<%= base %><%= f %>.js"></script><% } %>
|
||||
<script>
|
||||
const SAMPLES = <%- JSON.stringify(samples).replace(/</g, '\\u003c') %>;
|
||||
const REDEEMS = {
|
||||
card: { style: 'card', user: 'LurkingLynx', reward: 'Hydrate!', variation: 'Water break', rarity: 'common', caption: 'redeemed it! ♡' },
|
||||
cassette: { style: 'cassette', user: 'PixelPotato', reward: 'Posture check', variation: 'Sit up straight', rarity: 'common', caption: 'redeemed it! ♡' },
|
||||
'cassette-rare': { style: 'cassette', user: 'ChickenWhisperer', reward: 'Random sound', variation: 'Chicken dance', rarity: 'rare', caption: 'redeemed it! ♡' },
|
||||
'cassette-ultra': { style: 'cassette', user: 'BobTheBuilder99', reward: 'Random sound', variation: 'The legendary one', rarity: 'ultra_rare', caption: 'redeemed it! ♡' },
|
||||
tts: { style: 'tts', user: 'Chatty', reward: 'Read my message', variation: 'Robot voice', caption: 'says:', input: 'hello there streamer, that was a very nice shot and I was totally not camping that corner' },
|
||||
message: { style: 'message', user: 'PixelPotato', reward: 'Highlight my message', caption: 'highlighted:', input: 'this stream is the coziest place on the internet' },
|
||||
emote: { style: 'emote', user: 'LurkingLynx', reward: 'Gigantify an Emote', caption: 'gigantified an emote!', emote: 'https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0' },
|
||||
rain: { style: 'emote_rain', user: 'BobTheBuilder99', reward: 'On-Screen Celebration', caption: 'is celebrating!', emote: 'https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0' },
|
||||
};
|
||||
const log = t => { document.getElementById('log').textContent = t; };
|
||||
|
||||
// scale the 1920x1080 stage to its box; fixed-position alerts are kept inside it by moving them into the stage
|
||||
const stage = document.getElementById('stage'), box = document.getElementById('box');
|
||||
const fit = () => { stage.style.transform = `scale(${box.clientWidth / 1920})`; };
|
||||
new ResizeObserver(fit).observe(box); fit();
|
||||
new MutationObserver(() => {
|
||||
for (const id of ['card-alert', 'polaroid-alert', 'cassette-alert', 'fx-alert']) {
|
||||
const el = document.getElementById(id);
|
||||
if (el && el.parentElement !== stage) stage.appendChild(el);
|
||||
}
|
||||
}).observe(document.body, { childList: true });
|
||||
|
||||
const mark = (sel, attr, v) => document.querySelectorAll(sel).forEach(b => b.classList.toggle('on', b.dataset[attr] === v));
|
||||
function useTheme(k) {
|
||||
window.S.alert_theme = JSON.parse(JSON.stringify(THEMES[k]));
|
||||
mark('#themes button', 'theme', k); mark('#styles button', 'style', window.S.alert_theme.style);
|
||||
document.querySelectorAll('[data-c]').forEach(i => { i.value = window.S.alert_theme.card[i.dataset.c]; });
|
||||
PolaroidAlerts.reset(); log('look: ' + document.querySelector(`[data-theme="${k}"]`).textContent);
|
||||
}
|
||||
document.querySelectorAll('[data-theme]').forEach(b => b.addEventListener('click', () => useTheme(b.dataset.theme)));
|
||||
document.querySelectorAll('[data-style]').forEach(b => b.addEventListener('click', () => { window.S.alert_theme.style = b.dataset.style; mark('#styles button', 'style', b.dataset.style); }));
|
||||
document.querySelectorAll('[data-c]').forEach(i => i.addEventListener('input', () => { window.S.alert_theme.card[i.dataset.c] = i.value; }));
|
||||
document.querySelectorAll('[data-bg]').forEach(b => b.addEventListener('click', () => { stage.className = b.dataset.bg; mark('#bgs button', 'bg', b.dataset.bg); }));
|
||||
document.querySelectorAll('[data-k]').forEach(b => b.addEventListener('click', () => { PolaroidAlerts.playTest({ ...SAMPLES[b.dataset.k], test: true }); log(b.textContent); }));
|
||||
document.querySelectorAll('[data-r]').forEach(b => b.addEventListener('click', () => {
|
||||
const r = REDEEMS[b.dataset.r];
|
||||
PolaroidAlerts.playTest({ type: 'redeem', kind: 'reward', key: 'preview', volume: .8, polaroid: true, test: true, ...r }); log('redeem: ' + b.textContent);
|
||||
}));
|
||||
document.querySelector('[data-queue]').addEventListener('click', () => {
|
||||
PolaroidAlerts.reset(); ['follow', 'bits-120', 'gift-10', 'hype-level'].forEach(k => PolaroidAlerts.play(SAMPLES[k]));
|
||||
log('queued: follow, 120 bits, gift 10, hype level');
|
||||
});
|
||||
document.querySelector('[data-reset]').addEventListener('click', () => { PolaroidAlerts.reset(); log('stopped'); });
|
||||
useTheme(<%- JSON.stringify(start) %>);
|
||||
</script>
|
||||
</body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue