diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/Dockerfile b/Dockerfile index cbf3a30..8204354 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM node:20-alpine WORKDIR /app -COPY package.json server.js layout.js blog.js programs.js ./ +COPY package.json package-lock.json server.js layout.js blog.js programs.js ./ +RUN npm ci --omit=dev --no-audit --no-fund COPY content/ ./content/ COPY public/ ./public/ ENV NODE_ENV=production PORT=80 diff --git a/blog.js b/blog.js index 8333ede..38b8c58 100644 --- a/blog.js +++ b/blog.js @@ -5,7 +5,7 @@ 'use strict'; const fs = require('fs'); const path = require('path'); -const { SITE, esc, head, tail, ZONES, spot } = require('./layout'); +const { SITE, esc, head, tail, ZONES, spot, memberLinks, proCta } = require('./layout'); const AUTHOR = 'Marty Bostick'; const PER_PAGE = 9; const DIR = path.join(__dirname, 'content', 'blog'); @@ -78,7 +78,7 @@ function renderIndex(page, tag) { function related(p) { return listPublished().filter(x => x.slug !== p.slug).map(x => ({ x, s: x.tags.filter(t => p.tags.includes(t)).length })).sort((a, b) => b.s - a.s || b.x.publishedAt - a.x.publishedAt).slice(0, 3).map(r => r.x); } -function renderPost(p) { +function renderPost(p, pc) { const url = SITE + '/blog/' + p.slug; const ld = [{ '@context': 'https://schema.org', '@type': 'BlogPosting', headline: p.title, description: p.excerpt, image: p.cover ? (p.cover.startsWith('http') ? p.cover : SITE + p.cover) : SITE + '/og-stackpol-1200x630.jpg', datePublished: new Date(p.publishedAt).toISOString(), dateModified: new Date(p.updated).toISOString(), wordCount: words(p.body).split(' ').length, keywords: p.tags.join(', '), @@ -89,9 +89,11 @@ function renderPost(p) { h += '

Stack POL / Blog' + (p.tags[0] ? ' / ' + esc(p.tags[0]) + '' : '') + '

'; h += '

' + esc(p.title) + '

By ' + AUTHOR + ' · ' + fmtDate(p.publishedAt) + (p.updated > p.publishedAt + 864e5 ? ' · updated ' + fmtDate(p.updated) : '') + ' · ' + readMinutes(p.body) + ' min read

'; if (p.cover) h += '' + esc(p.coverAlt) + ''; - h += '
' + p.body; + // an ad spot inside the article (Marty 2026-11-09): after the third paragraph of a long post; a Pro member's banner when personalized + let body = p.body; const paras = body.split('

'); if (paras.length > 6) body = paras.slice(0, 3).join('

') + '

' + spot(ZONES.blogBox, ZONES.strip) + paras.slice(3).join('

'); + h += '
' + body; if (p.faq.length) h += '

Questions people ask

' + p.faq.map(q => '

' + esc(q.q) + '

' + esc(q.a) + '

').join(''); - h += '
' + spot(ZONES.blogBox, ZONES.blogBox); + h += '
' + (pc && pc.st.pro ? memberLinks(pc.who, pc.st) : '') + spot(ZONES.blogBox, ZONES.blogBox) + (pc && pc.st.pro ? proCta(pc.who) : ''); if (p.tags.length) h += '

' + p.tags.map(t => '' + esc(t) + '').join('') + '

'; h += '

Share on XShare on FacebookTelegram

'; h += '
M
' + AUTHOR + 'Founder of InstantAdPay, LinkSpin and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.
'; diff --git a/layout.js b/layout.js index 386b05f..a41d54d 100644 --- a/layout.js +++ b/layout.js @@ -84,6 +84,13 @@ footer.site b{display:block;color:var(--ink);font:700 14px var(--display);margin .crumb{font-size:13px;color:var(--muted);margin-top:26px}.crumb a{color:var(--muted)} /* ad spots (LinkSpin zones): neutral class names, ad blockers hide .adzone-style names (feedback 2026-10-08) */ .spot{display:flex;flex-direction:column;align-items:center;gap:4px;margin:28px auto;max-width:100%;overflow:hidden}.spot .sl{font-size:10.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted)} +/* Stack POL Pro (2026-11-09): the member's own links, the purple QR, the get-a-page-like-this panel */ +.mylinks{margin:26px 0}.mylinks .ml{display:flex;flex-wrap:wrap;gap:10px;margin-top:8px} +.prorow{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:22px;align-items:center;background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:20px;margin:28px 0} +.qr{background:#fff;border-radius:14px;padding:10px;width:170px;text-align:center}.qr img{display:block;width:150px;height:150px}.qr span{font:700 11px var(--body);color:#5b2bb5;letter-spacing:.06em;text-transform:uppercase} +.procta{display:flex;flex-wrap:wrap;gap:12px 16px;align-items:center;border:1px solid var(--violet);border-radius:18px;padding:18px 20px;margin:30px 0;background:linear-gradient(135deg,rgba(130,71,229,.16),transparent)} +.procta div{flex:1 1 280px;min-width:0}.procta b{display:block;font:800 18px var(--display);margin-bottom:4px}.procta span{color:var(--muted)} +@media (max-width:640px){.prorow{grid-template-columns:1fr}.qr{margin:0 auto}} @media (prefers-reduced-motion:reduce){.card,.btn{transition:none}.card:hover{transform:none}} `; @@ -116,7 +123,43 @@ function head(o) { // hidden size never counts a view. Zones are on Marty's LinkSpin account, site stackpol.com (created 2026-11-09). const ZONES = { banner: 'ls-9c2a52', strip: 'ls-dc8bdd', blogBox: 'ls-72413f', ledgerBox: 'ls-1f308f' }; const spot = (wide, narrow) => '
Sponsored
'; -const SPOT_JS = ''; +const MEMBER_HOST = 'rubav.com'; // a LinkSpin link domain: /i/.gif image, /c/ click, /r/ spin link +const SPOT_JS = ''; +// Stack POL Pro (2026-11-09): a page that belongs to a Pro member (their /, or any page opened with ?ref=) shows +// THEIR LinkSpin Banner Spins in the ad spots instead of the network zones (a spot with no spin of a fitting size keeps the network +// zone), and every internal link and join link carries their referral. Free members' pages keep the network zones but still credit +// the member on join links. Not personalized = the standard network ads. +const FIT = { [ZONES.banner]: ['728x90', '468x60'], [ZONES.strip]: ['468x60', '300x250', '125x125'], [ZONES.blogBox]: ['300x250', '125x125', '468x60'], [ZONES.ledgerBox]: ['300x250', '125x125', '468x60'] }; +function pickSpin(spins, zone) { + for (const size of FIT[zone] || []) { const c = spins.filter(x => x.size === size); if (c.length) { const x = c[Math.floor(Math.random() * c.length)]; return x.code + '|' + size.replace('x', '|'); } } + return ''; +} +function personalize(html, who, st) { + if (!who) return html; + const pro = st && st.pro, spins = (pro && pro.spins) || []; + if (spins.length) html = html.replace(/
/g, (m, w, n) => { + const mw = pickSpin(spins, w), mn = pickSpin(spins, n); + return '
'; + }); + return html.replace(/href="([^"]*)"/g, (m, h) => { + if (/^\/(earn|blog|programs|ledger)(\/|\?|$)/.test(h) && !/\/blog\/feed\.xml/.test(h)) return 'href="' + h + (h.includes('?') ? '&' : '?') + 'ref=' + who + '"'; + if (h === '/') return 'href="/' + who + '"'; + if (/^https:\/\/(instantadpay\.com|linkspin\.app)\/?$/.test(h)) return 'href="' + h.replace(/\/?$/, '/join/' + who) + '"'; + if (/^https:\/\/(instantadpay\.com|linkspin\.app)\//.test(h)) return 'href="' + h.replace(/\/join\/martbost\b/, '/join/' + who).replace(/([?&](?:amp;)?ref=)martbost\b/, '$1' + who) + '"'; + return m; + }); +} +// shown on a Pro page and on articles opened from one: the visitor can get a page like this (Marty 2026-11-09). New visitors join +// under the Pro member; members go straight to the Stack POL tab, where Get Pro opens the order a $10+ package fulfils. +function proCta(who) { + return '
Want a personalized page like this?Your own Stack POL page with your banners, your links and your QR code. Unlocked one time with any InstantAdPay ad package of $10 or more.
' + + 'Get your own pageAlready a member? Unlock Pro
'; +} +// the member's spin links, as a block for their page and the end of articles opened from it +function memberLinks(who, st) { + const links = (st && st.pro && st.pro.links) || []; if (!links.length) return ''; + return ''; +} function tail(extra) { const year = new Date().getFullYear(); return '
Stack POLEvery POL payout across the network, stacked in one place and checkable on Polygon.
' @@ -126,4 +169,4 @@ function tail(extra) { + '

© ' + year + ' Stack POL, part of the Crypto Team Build Network. Stack POL shows payouts; it does not hold, invest or pay out anyone\'s money.

' + '
' + (extra || '') + SPOT_JS + ''; } -module.exports = { SITE, esc, head, tail, OG, V, ZONES, spot }; +module.exports = { SITE, esc, head, tail, OG, V, ZONES, spot, personalize, memberLinks, proCta, MEMBER_HOST }; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..5a83777 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,320 @@ +{ + "name": "stackpol", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "stackpol", + "version": "1.0.0", + "dependencies": { + "qrcode": "1.5.4" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dijkstrajs": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", + "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/qrcode": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", + "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", + "license": "MIT", + "dependencies": { + "dijkstrajs": "^1.0.1", + "pngjs": "^5.0.0", + "yargs": "^15.3.1" + }, + "bin": { + "qrcode": "bin/qrcode" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "license": "ISC" + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "license": "ISC" + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "license": "ISC" + }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "license": "ISC" + }, + "node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "license": "MIT", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "license": "ISC", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + } + } +} diff --git a/package.json b/package.json index 7b8a15b..b1cde2a 100644 --- a/package.json +++ b/package.json @@ -1 +1 @@ -{ "name": "stackpol", "version": "1.0.0", "private": true, "main": "server.js", "scripts": { "start": "node server.js" } } +{ "name": "stackpol", "version": "1.0.0", "private": true, "main": "server.js", "scripts": { "start": "node server.js" }, "dependencies": { "qrcode": "1.5.4" } } diff --git a/server.js b/server.js index 03da55b..7ab4c63 100644 --- a/server.js +++ b/server.js @@ -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 += '
' + ps.map(p => card(p, prog(p.k).pol, prog(p.k).payments, OWNER)).join('') + '
'; 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 += '

' + esc(p.kind) + '

' + esc(p.n) + '

' + esc(p.d) + '

'; h += '
' + fmt(s.pol) + 'POL
' + fmtInt(s.payments) + 'payments
' + fmtInt(s.wallets) + 'wallets paid
' + (s.last ? '
' + ago(s.last) + 'last payout
' : '') + '
'; if (p.season) h += '

' + esc(p.season.label) + '

'; - h += '
'; + h += '
'; h += ''; h += '

How ' + esc(p.n) + ' pays

' + 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.')) + '

'; h += '

Latest ' + esc(p.n) + ' payouts

All of them

' + tableHead(true) + ledgerRows(rows, true) + '
'; const posts = blog.listPublished().filter(b => b.tags.includes(p.slug) || b.tags.includes(p.n.toLowerCase())).slice(0, 3); if (posts.length) h += '

Guides

' + posts.map(blog.cardHtml).join('') + '
'; - h += '

More programs that pay POL

' + sortedProgs().filter(x => x.k !== p.k).slice(0, 3).map(x => card(x, prog(x.k).pol, prog(x.k).payments, OWNER)).join('') + '
'; + h += '

More programs that pay POL

' + sortedProgs().filter(x => x.k !== p.k).slice(0, 3).map(x => card(x, prog(x.k).pol, prog(x.k).payments, ref)).join('') + '
'; return h + tail(); } function ledgerPage(k) { @@ -128,9 +129,23 @@ function stackPage(u, st) { h += '
Start your own stack, freeFree to join. One member\'s results, not a promise. What you stack depends on what you do.
' + heroVideo + ''; 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 += '

Where @' + esc(u) + '\'s POL comes from

Tap any program to start. Each pays to your own wallet.

' + feat.map(p => feature(p, u)).join('') + '
' + rest.map(p => card(p, (st.byProg[p.k] || {}).pol || 0, (st.byProg[p.k] || {}).payments || 0, u)).join('') + '
'; + if (st.pro) { // Stack POL Pro (2026-11-09): the member's own links and a purple Polygon QR that opens this page + h += '
' + (memberLinks(u, st) || '

@' + esc(u) + '\'s page

') + '

Scan the code to open @' + esc(u) + '\'s stack on your phone, or share it anywhere people can see it.

' + + (QR ? '
QR code for stackpol.com/' + esc(u) + 'stackpol.com/' + esc(u) + '
' : '') + '
'; + } + h += spot(ZONES.banner, ZONES.strip); h += '

@' + esc(u) + '\'s latest payouts

' + tableHead(false) + ledgerRows(st.recent || [], false) + ''; + const posts = blog.listPublished().slice(0, 3); + if (posts.length) h += '

From the blog

All posts

' + posts.map(blog.cardHtml).join('') + '
'; + 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 }) + '

Nothing stacked here

' + esc(msg || 'That page does not exist.') + '

Go to Stack POL

' + 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= 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()); diff --git a/tools/indexer.py b/tools/indexer.py index bbf2542..50af06e 100644 --- a/tools/indexer.py +++ b/tools/indexer.py @@ -144,6 +144,26 @@ def main(): stacks[un] = {'total': round(sum(r['pol'] for r in mine), 4), 'payments': len(mine), 'since': min(r['ts'] for r in mine), 'byProg': {k: {'pol': round(v['pol'], 4), 'payments': v['payments']} for k, v in by.items()}, 'recent': [{'k': r['k'], 'pol': round(r['pol'], 4), 'tx': r['tx'], 'ts': r['ts']} for r in mine[:25]]} + # Stack POL Pro (2026-11-09): a paid one-time unlock in IAP. Pro pages (and blog/program pages opened from one) show the member's own + # LinkSpin Banner Spins and spin links in place of the network zones. Matched by username (one identity across IAP and LinkSpin). + pro = {str(k).lower() for k, v in ((so.get('pro') or {}) if isinstance(so, dict) else {}).items() if v} + if pro and lsd: + em = {} + for e, a in (load(os.path.join(lsd, 'accounts.json'), {}).get('byEmail', {}) or {}).items(): + un = str(a.get('username') or '').lower() + if un in pro: + em[str(e).lower()] = un + bs = load(os.path.join(lsd, 'bannerspin.json'), {}).get('spins', []) or [] + rt = load(os.path.join(lsd, 'rotator.json'), {}).get('rotations', []) or [] + for un in pro: + if un not in stacks: + continue + mine = [e for e, u in em.items() if u == un] + spins = [{'code': x['code'], 'size': x.get('size', ''), 'name': str(x.get('name') or '')[:60]} for x in bs + if str(x.get('owner', '')).lower() in mine and not x.get('paused') and any(b.get('active', True) for b in x.get('banners') or [])] + links = [{'code': x['code'], 'name': str(x.get('name') or '')[:60]} for x in rt + if str(x.get('owner', '')).lower() in mine and not x.get('paused') and any(d.get('active', True) for d in x.get('destinations') or [])] + stacks[un]['pro'] = {'spins': spins[:40], 'links': links[:20]} snap = {'v': 1, 'at': now, 'network': {'pol': round(sum(r['pol'] for r in rows), 4), 'payments': len(rows), 'wallets': len(wallets - {''})}, 'last7': {'pol': round(sum(r['pol'] for r in l7), 4), 'payments': len(l7)}, 'programs': programs, 'recent': recent, 'progRecent': prog_recent, 'stacks': stacks} print('network %.2f POL, %d payments, %d wallets | last7 %.2f | stacks %s' % (snap['network']['pol'], snap['network']['payments'], snap['network']['wallets'], snap['last7']['pol'], ','.join(stacks) or '-'))