Questions people ask
' + p.faq.map(q => '' + esc(q.q) + '
' + esc(q.a) + '
').join(''); - h += '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(q.a) + '
').join(''); - h += '.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 '@' + esc(who) + ' recommends
' + links.map(l => '' + esc(l.name || 'Open link') + ' →').join('') + '';
+}
function tail(extra) {
const year = new Date().getFullYear();
return '' + (extra || '') + SPOT_JS + '