Merge Banner Spin phases 3-4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -581,7 +581,7 @@ async function boot() {
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []);
|
||||
rotator.init({ dataDir: DATA_DIR, geo, ownHosts, sources });
|
||||
// destination health: every 30 min, first pass 2 min after boot; a pause lands in the owner's on-site inbox (same path as the payment notices)
|
||||
health.init({ rotator, dataDir: DATA_DIR, notify: (email, subject, html) => messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [email], subject, html) });
|
||||
health.init({ rotator, bannerspin, dataDir: DATA_DIR, notify: (email, subject, html) => messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [email], subject, html) });
|
||||
setTimeout(() => health.tick().catch(e => console.error('health', e.message)), 2 * 60 * 1000);
|
||||
setInterval(() => health.tick().catch(e => console.error('health', e.message)), 30 * 60 * 1000);
|
||||
setInterval(() => { try { rotator.sweepDemos(); } catch (e) {} }, 60 * 60 * 1000); // unclaimed home-page demo spins expire after 24 h
|
||||
@@ -2299,6 +2299,11 @@ const server = http.createServer(async (req, res) => {
|
||||
if (b.off != null || b.grant) { const r = bannerspin.setGlobal(b); content.invalidate(); return json(res, r.error ? 400 : 200, r); }
|
||||
return json(res, 200, { spins: bannerspin.adminAll(), settings: bannerspin.settings(), totals: bannerspin.totals() }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
// Banner Spin health checks now (phase 3, 2026-10-20): { id } for one Banner Spin, else all; auto-paused banners are re-checked at once
|
||||
if (p === '/api/admin/bannerspins/health' && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
const b = await readBody(req); const r = await health.checkBannerSpins({ id: Number(b.id) || 0 }); content.invalidate(); return json(res, r.error ? 429 : 200, r);
|
||||
}
|
||||
m = /^\/api\/admin\/bannerspins\/(\d+)$/.exec(p);
|
||||
if (m && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
@@ -2421,7 +2426,9 @@ const server = http.createServer(async (req, res) => {
|
||||
const days = Math.max(1, Math.min(365, Number(u.searchParams.get('days')) || 30));
|
||||
// spins (the rotator summary, spread at the top level so older report screens keep working) + pages + zones (2026-10-10)
|
||||
const [spins, pg, zn] = await Promise.all([rotator.summary(s.email, days), pages.summary(s.email, days), zonereport.summary(s.email, days)]);
|
||||
return json(res, 200, Object.assign({}, spins, { spins, pages: pg, zones: zn, days: spins.days, range: days }), { 'Cache-Control': 'no-store' });
|
||||
// Banner Spins beside spin links (phase 3, 2026-10-20)
|
||||
let bsum = null; try { bsum = await bannerspin.summary(s.email, days); } catch (e) { console.error('bannerspin summary', e.message); }
|
||||
return json(res, 200, Object.assign({}, spins, { spins, pages: pg, zones: zn, bannerSpins: bsum, days: spins.days, range: days }), { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
// -- traffic sources (2026-10-12). Every route takes GET and POST: the shell's api() helper always POSTs.
|
||||
if (p === '/api/sources/catalog' && (req.method === 'GET' || req.method === 'POST')) return json(res, 200, { catalog: sources.catalog(), keys: sources.KEYS }, { 'Cache-Control': 'public, max-age=300' });
|
||||
@@ -2772,6 +2779,8 @@ const server = http.createServer(async (req, res) => {
|
||||
let items = [];
|
||||
try { const j = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'training.json'), 'utf8')); if (Array.isArray(j)) items = j; } catch (e) {}
|
||||
// a card with feature:'pipeline' waits for the switch, so the video can be ready before the tab opens (Marty, 2026-09-15)
|
||||
// built-in lessons shipped with the code (catalog/training.json, Banner Spin 2026-10-20): appended unless the volume list already has the same id
|
||||
try { const extra = JSON.parse(fs.readFileSync(path.join(__dirname, 'catalog', 'training.json'), 'utf8')); if (Array.isArray(extra)) for (const it of extra) if (it && it.id && !items.some(x => x && x.id === it.id)) items.push(it); } catch (e) {}
|
||||
const scT = siteConfig(); items = items.filter(it => !it.feature || (it.feature === 'pipeline' && pipeline.visible(scT.pipelineMode, s.email, ADMIN_EMAIL)));
|
||||
if (!items.length) items = [{ title: 'Getting started with LinkSpin',
|
||||
desc: 'How the platform works, how every payout splits on-chain to real wallets, and how to build your line.',
|
||||
|
||||
Reference in New Issue
Block a user