Stack POL Pro pages (Marty 2026-11-09): a Pro member's page shows their own LinkSpin Banner Spins in the ad spots (a spot with no fitting size keeps the network zone), their spin links, a purple Polygon QR to the page (/qr/<username>.svg, qrcode module) and a "Want a personalized page like this?" panel (join under the member, or Unlock Pro in IAP). Every page opened with ?ref=<Pro member> credits them on every call to action (join links, game links, program pages, internal links carry the ref) and shows their banners; no ref or a non-Pro ref = the standard network pages and zones. Blog posts now carry an ad spot after the third paragraph, and personalized posts end with the member's links and the Pro panel. Member pages also get a network spot and the latest blog posts. Indexer reads pro[] from IAP stack-optin.json and adds each Pro member's active spins and spin links (matched by username in LinkSpin).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-09 15:31:39 -06:00
parent e53565051b
commit 05f3514b9e
9 changed files with 431 additions and 21 deletions
+35 -13
View File
@@ -9,7 +9,8 @@ const http = require('http');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const { SITE, esc, head, tail, ZONES, spot } = require('./layout');
const { SITE, esc, head, tail, ZONES, spot, personalize, memberLinks, proCta } = require('./layout');
let QR = null; try { QR = require('qrcode'); } catch (e) { console.error('[stackpol] qrcode module missing: no QR on Pro pages'); }
const { PROGRAMS, BY_KEY, BY_SLUG } = require('./programs');
const blog = require('./blog');
@@ -89,7 +90,7 @@ function programsPage() {
h += '<div class="cards" style="margin-top:22px">' + ps.map(p => card(p, prog(p.k).pol, prog(p.k).payments, OWNER)).join('') + '</div>';
return h + tail();
}
function programPage(p) {
function programPage(p, who) { const ref = who || OWNER; // a Pro member's ref (2026-11-09) or the site owner
const s = prog(p.k), rows = ((IDX && IDX.progRecent && IDX.progRecent[p.k]) || ((IDX && IDX.recent) || []).filter(r => r.k === p.k)).slice(0, 20);
const desc = p.n + ' pays POL on Polygon. ' + fmt(s.pol) + ' POL paid in ' + fmtInt(s.payments) + ' payments to ' + fmtInt(s.wallets) + ' wallets so far. ' + p.d.slice(0, 90);
const ld = [{ '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: [{ '@type': 'ListItem', position: 1, name: 'Stack POL', item: SITE + '/' }, { '@type': 'ListItem', position: 2, name: 'Programs', item: SITE + '/programs' }, { '@type': 'ListItem', position: 3, name: p.n, item: SITE + '/earn/' + p.slug }] },
@@ -100,13 +101,13 @@ function programPage(p) {
h += '<section class="hero" style="padding-top:10px"><div><p class="kick">' + esc(p.kind) + '</p><h1>' + esc(p.n) + '</h1><p class="lead">' + esc(p.d) + '</p>';
h += '<div class="total"><span class="n">' + fmt(s.pol) + '</span><span class="u">POL</span></div><div class="stats"><div><b>' + fmtInt(s.payments) + '</b><span>payments</span></div><div><b>' + fmtInt(s.wallets) + '</b><span>wallets paid</span></div>' + (s.last ? '<div><b>' + ago(s.last) + '</b><span>last payout</span></div>' : '') + '</div>';
if (p.season) h += '<p style="color:#fb923c;font-weight:700">' + esc(p.season.label) + '</p>';
h += '<div class="cta"><a class="btn" href="' + esc(p.join(OWNER)) + '" rel="nofollow noopener" target="_blank">' + (p.k === 'iap' || p.k === 'ls' ? 'Join ' : 'Play ') + esc(p.n) + ' free</a><a class="btn sec" href="/ledger?p=' + p.k + '">Its payouts on the ledger</a></div></div>';
h += '<div class="cta"><a class="btn" href="' + esc(p.join(ref)) + '" rel="nofollow noopener" target="_blank">' + (p.k === 'iap' || p.k === 'ls' ? 'Join ' : 'Play ') + esc(p.n) + ' free</a><a class="btn sec" href="/ledger?p=' + p.k + '">Its payouts on the ledger</a></div></div>';
h += '<aside><img src="/img/' + p.k + '.jpg" alt="' + esc(p.n) + '" width="800" height="420" style="border-radius:18px;border:1px solid var(--line)"></aside></section>';
h += '<div class="sec-head"><h2>How ' + esc(p.n) + ' pays</h2></div><p class="lead" style="max-width:72ch">' + esc(p.how || ('Rewards are sent in POL from ' + p.n + '\'s own payout wallet straight to the wallet on your account, on the Polygon network. Every payment is a public transaction you can open on Polygonscan.')) + '</p>';
h += '<div class="sec-head"><h2>Latest ' + esc(p.n) + ' payouts</h2><p><a href="/ledger?p=' + p.k + '">All of them</a></p></div>' + tableHead(true) + ledgerRows(rows, true) + '</tbody></table></div>';
const posts = blog.listPublished().filter(b => b.tags.includes(p.slug) || b.tags.includes(p.n.toLowerCase())).slice(0, 3);
if (posts.length) h += '<div class="sec-head"><h2>Guides</h2></div><div class="posts">' + posts.map(blog.cardHtml).join('') + '</div>';
h += '<div class="sec-head"><h2>More programs that pay POL</h2></div><div class="cards">' + sortedProgs().filter(x => x.k !== p.k).slice(0, 3).map(x => card(x, prog(x.k).pol, prog(x.k).payments, OWNER)).join('') + '</div>';
h += '<div class="sec-head"><h2>More programs that pay POL</h2></div><div class="cards">' + sortedProgs().filter(x => x.k !== p.k).slice(0, 3).map(x => card(x, prog(x.k).pol, prog(x.k).payments, ref)).join('') + '</div>';
return h + tail();
}
function ledgerPage(k) {
@@ -128,9 +129,23 @@ function stackPage(u, st) {
h += '<div class="cta"><a class="btn" href="https://instantadpay.com/join/' + esc(u) + '?src=stackpol" rel="noopener">Start your own stack, free</a><span class="fine">Free to join. One member\'s results, not a promise. What you stack depends on what you do.</span></div></div>' + heroVideo + '</section>';
const feat = PROGRAMS.filter(p => p.season && seasonOn(p)), rest = PROGRAMS.filter(p => !(p.season && seasonOn(p))).sort((a, b) => ((st.byProg[b.k] || {}).pol || 0) - ((st.byProg[a.k] || {}).pol || 0));
h += '<div class="sec-head"><h2>Where @' + esc(u) + '\'s POL comes from</h2><p>Tap any program to start. Each pays to your own wallet.</p></div>' + feat.map(p => feature(p, u)).join('') + '<div class="cards">' + rest.map(p => card(p, (st.byProg[p.k] || {}).pol || 0, (st.byProg[p.k] || {}).payments || 0, u)).join('') + '</div>';
if (st.pro) { // Stack POL Pro (2026-11-09): the member's own links and a purple Polygon QR that opens this page
h += '<div class="prorow"><div style="min-width:0">' + (memberLinks(u, st) || '<p class="kick">@' + esc(u) + '\'s page</p>') + '<p class="lead" style="margin:6px 0 0">Scan the code to open @' + esc(u) + '\'s stack on your phone, or share it anywhere people can see it.</p></div>'
+ (QR ? '<div class="qr"><img src="/qr/' + esc(u) + '.svg" alt="QR code for stackpol.com/' + esc(u) + '" width="150" height="150"><span>stackpol.com/' + esc(u) + '</span></div>' : '') + '</div>';
}
h += spot(ZONES.banner, ZONES.strip);
h += '<div class="sec-head"><h2>@' + esc(u) + '\'s latest payouts</h2></div>' + tableHead(false) + ledgerRows(st.recent || [], false) + '</tbody></table></div>';
const posts = blog.listPublished().slice(0, 3);
if (posts.length) h += '<div class="sec-head"><h2>From the blog</h2><p><a href="/blog">All posts</a></p></div><div class="posts">' + posts.map(blog.cardHtml).join('') + '</div>';
if (st.pro) h += proCta(u);
return h + tail(videoJs);
}
const QRC = new Map(); // username -> svg (the page URL never changes)
async function qrSvg(un) {
if (QRC.has(un)) return QRC.get(un);
const svg = await QR.toString(SITE + '/' + un, { type: 'svg', margin: 1, width: 300, errorCorrectionLevel: 'M', color: { dark: '#6a2fd6', light: '#ffffff' } }); // Polygon purple, dark enough to scan
QRC.set(un, svg); return svg;
}
function notFound(msg) { return head({ title: 'Not found | Stack POL', desc: 'This page is not on Stack POL.', path: '/404', noindex: true }) + '<section style="padding:60px 0"><h1>Nothing stacked here</h1><p class="lead">' + esc(msg || 'That page does not exist.') + '</p><p><a class="btn" href="/">Go to Stack POL</a></p></section>' + tail(); }
function sitemap() {
const d = new Date().toISOString().slice(0, 10);
@@ -178,22 +193,29 @@ const server = http.createServer((req, res) => {
if (req.method !== 'GET' && req.method !== 'HEAD') { res.writeHead(405); return res.end(); }
if (p === '/api/totals') return send(req, res, 200, 'application/json', JSON.stringify({ at: IDX ? IDX.at : null, network: net(), programs: (IDX && IDX.programs) || {} }), 'public, max-age=120');
if (p === '/health') return send(req, res, 200, 'text/plain', 'ok', 'no-store');
if (p === '/') return html(req, res, 200, home(), 'public, max-age=120');
if (p === '/programs') return html(req, res, 200, programsPage(), 'public, max-age=300');
if (p === '/ledger') return html(req, res, 200, ledgerPage(u.searchParams.get('p')), 'public, max-age=120');
let m = /^\/earn\/([a-z0-9-]+)\/?$/.exec(p); if (m) return BY_SLUG[m[1]] ? html(req, res, 200, programPage(BY_SLUG[m[1]]), 'public, max-age=300') : html(req, res, 404, notFound());
if (p === '/blog' || p === '/blog/') return html(req, res, 200, blog.renderIndex(1));
m = /^\/blog\/page\/(\d+)$/.exec(p); if (m) return html(req, res, 200, blog.renderIndex(Number(m[1])));
m = /^\/blog\/tag\/([^/]+)$/.exec(p); if (m) return html(req, res, 200, blog.renderIndex(1, m[1].toLowerCase()));
// ?ref=<username> of a Pro member (Marty 2026-11-09): every call to action credits them (join links, game links, program
// pages) and their banners fill the ad spots. Anyone else, or no ref: the standard network pages and zones.
const refName = String(u.searchParams.get('ref') || '').toLowerCase(), refSt = /^[a-z0-9_]{3,30}$/.test(refName) && IDX && IDX.stacks && IDX.stacks[refName];
const pc = refSt && refSt.pro ? { who: refName, st: refSt } : null;
const page = body => pc ? personalize(body, pc.who, pc.st) : body;
const q = /^\/qr\/([a-z0-9_]{3,30})\.svg$/.exec(p);
if (q) { const st = IDX && IDX.stacks && IDX.stacks[q[1]]; if (!QR || !st || !st.pro) return html(req, res, 404, notFound()); return qrSvg(q[1]).then(svg => send(req, res, 200, 'image/svg+xml', svg, 'public, max-age=86400')).catch(() => html(req, res, 500, notFound())); }
if (p === '/') return html(req, res, 200, page(home()), 'public, max-age=120');
if (p === '/programs') return html(req, res, 200, page(programsPage()), 'public, max-age=300');
if (p === '/ledger') return html(req, res, 200, page(ledgerPage(u.searchParams.get('p'))), 'public, max-age=120');
let m = /^\/earn\/([a-z0-9-]+)\/?$/.exec(p); if (m) return BY_SLUG[m[1]] ? html(req, res, 200, page(programPage(BY_SLUG[m[1]], pc && pc.who)), 'public, max-age=300') : html(req, res, 404, notFound());
if (p === '/blog' || p === '/blog/') return html(req, res, 200, page(blog.renderIndex(1)));
m = /^\/blog\/page\/(\d+)$/.exec(p); if (m) return html(req, res, 200, page(blog.renderIndex(Number(m[1]))));
m = /^\/blog\/tag\/([^/]+)$/.exec(p); if (m) return html(req, res, 200, page(blog.renderIndex(1, m[1].toLowerCase())));
if (p === '/blog/feed.xml') return send(req, res, 200, 'application/rss+xml; charset=utf-8', blog.rss(), 'public, max-age=600');
m = /^\/blog\/([a-z0-9-]+)\/?$/.exec(p); if (m) { const post = blog.get(m[1]); return post ? html(req, res, 200, blog.renderPost(post), 'public, max-age=600') : html(req, res, 404, notFound('That post is not here.')); }
m = /^\/blog\/([a-z0-9-]+)\/?$/.exec(p); if (m) { const post = blog.get(m[1]); return post ? html(req, res, 200, page(blog.renderPost(post, pc)), 'public, max-age=600') : html(req, res, 404, notFound('That post is not here.')); }
if (p === '/sitemap.xml') return send(req, res, 200, 'application/xml; charset=utf-8', sitemap(), 'public, max-age=3600');
if (p === '/robots.txt') return send(req, res, 200, 'text/plain; charset=utf-8', robots(), 'public, max-age=86400');
if (staticFile(req, res, p)) return;
m = /^\/@?([a-z0-9_]{3,30})\/?$/i.exec(p);
if (m && !RESERVED.has(m[1].toLowerCase())) {
const name = m[1].toLowerCase(), st = IDX && IDX.stacks && IDX.stacks[name];
if (st) return html(req, res, 200, stackPage(name, st), 'public, max-age=120');
if (st) return html(req, res, 200, st.pro ? personalize(stackPage(name, st), name, st) : stackPage(name, st), 'public, max-age=120');
return html(req, res, 404, notFound('@' + name + ' has not switched on a Stack POL page yet. Members turn it on in InstantAdPay Promo tools.'));
}
return html(req, res, 404, notFound());