// LinkSpin page renderer (2026-09-29): bridge, review and squeeze pages as standalone HTML. Everything the member // typed is escaped; the only form on a page is either our own capture form or a provider form rebuilt by // formrestyle (parse-or-refuse). No inline script: tracking lives in /assets/pt.js so the page can carry a real CSP. 'use strict'; const formrestyle = require('./formrestyle'); const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); const href = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s"'<>]+$/i.test(s) && s.length <= 700 ? s : ''; }; const PALETTES = { graphite: { bg: '#0F1422', panel: '#161D31', ink: '#EEF2F8', muted: '#A7B4CB', line: '#27314A', accent: '#3B9DFF', accentInk: '#061225', font: "'Segoe UI',system-ui,-apple-system,Roboto,sans-serif", display: "Georgia,'Times New Roman',serif" }, ink: { bg: '#F6F4EE', panel: '#FFFFFF', ink: '#17191C', muted: '#5F6670', line: '#D9D4C7', accent: '#B8410E', accentInk: '#FFFFFF', font: "'Segoe UI',system-ui,-apple-system,Roboto,sans-serif", display: "Georgia,'Times New Roman',serif" }, ember: { bg: '#1A1210', panel: '#241A16', ink: '#F7EFE9', muted: '#C9B8AE', line: '#3A2B25', accent: '#FF8A3D', accentInk: '#1A0E08', font: "'Segoe UI',system-ui,-apple-system,Roboto,sans-serif", display: "Georgia,'Times New Roman',serif" }, }; const PALETTE_NAMES = Object.keys(PALETTES); function css(P) { return '*{box-sizing:border-box}body{margin:0;background:' + P.bg + ';color:' + P.ink + ';font-family:' + P.font + ';font-size:17px;line-height:1.55}a{color:' + P.accent + '}' + '.wrap{max-width:720px;margin:0 auto;padding:28px 18px 60px}.panel{background:' + P.panel + ';border:1px solid ' + P.line + ';border-radius:12px;padding:22px}' + 'h1{font-family:' + P.display + ';font-size:clamp(30px,5.6vw,44px);line-height:1.08;margin:0 0 12px;text-wrap:balance}h2{font-family:' + P.display + ';font-size:24px;margin:26px 0 8px}h3{font-size:18px;margin:18px 0 6px}' + '.sub{font-size:19px;color:' + P.muted + ';margin:0 0 18px}.eyebrow{font-size:12px;letter-spacing:.14em;text-transform:uppercase;font-weight:700;color:' + P.accent + ';margin-bottom:10px}' + 'ul.checks{list-style:none;padding:0;margin:14px 0;display:grid;gap:8px}ul.checks li{padding-left:28px;position:relative}ul.checks li::before{content:"";position:absolute;left:0;top:8px;width:16px;height:16px;border-radius:50%;background:' + P.accent + '}ul.checks li::after{content:"";position:absolute;left:5px;top:11px;width:6px;height:9px;border:solid ' + P.accentInk + ';border-width:0 2px 2px 0;transform:rotate(45deg)}' + '.cta{display:inline-block;background:' + P.accent + ';color:' + P.accentInk + ';font-weight:800;font-size:18px;text-decoration:none;padding:15px 26px;border-radius:10px;border:0;cursor:pointer;font-family:inherit}.cta:hover{filter:brightness(1.08)}.ctawrap{margin:18px 0;text-align:center}' + '.lsform{display:grid;gap:10px}.lsin{width:100%;padding:14px 16px;font:16px/1.4 inherit;border:1.5px solid ' + P.line + ';border-radius:10px;background:' + P.bg + ';color:' + P.ink + '}.lsin:focus{border-color:' + P.accent + ';outline:none}' + '.privacy{font-size:12.5px;color:' + P.muted + ';margin:10px 0 0;text-align:center}.hero img{width:100%;height:auto;border-radius:12px;margin:0 0 18px}' + '.pc{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.pc div{background:' + P.bg + ';border:1px solid ' + P.line + ';border-radius:10px;padding:14px}.pc h3{margin:0 0 8px}.pc ul{margin:0;padding-left:18px}@media(max-width:560px){.pc{grid-template-columns:1fr}}' + '.rating{font-size:22px;letter-spacing:2px;color:' + P.accent + '}.verdict{border-left:4px solid ' + P.accent + ';padding:10px 14px;margin:16px 0;background:' + P.bg + ';border-radius:0 10px 10px 0}' + '.foot{margin-top:34px;font-size:12.5px;color:' + P.muted + ';text-align:center}.foot a{color:' + P.muted + '}p{margin:0 0 14px}'; } const paras = t => String(t || '').split(/\n\s*\n/).map(x => x.trim()).filter(Boolean).map(x => '

' + esc(x).replace(/\n/g, '
') + '

').join(''); const bullets = arr => (arr || []).filter(Boolean).length ? '' : ''; function stars(n) { const k = Math.max(0, Math.min(5, Math.round(Number(n) || 0))); return '
' + '★'.repeat(k) + '☆'.repeat(5 - k) + '
'; } function ctaBtn(c, cls) { const u = href(c && c.url); const t = esc(c && c.text || 'Continue'); return u ? '
' + t + '
' : ''; } function formArea(page, opts) { const c = page.content || {}; if (c.formEmbed) { const parsed = formrestyle.parse(c.formEmbed); if (parsed) return '
' + formrestyle.html(parsed, c.cta && c.cta.text || 'Send me the details') + '
'; } // our own capture: the lead lands on the member's LinkSpin list, then the visitor continues to the CTA URL return '
'; } function render(page, opts) { opts = opts || {}; const P = PALETTES[page.design && page.design.palette] || PALETTES.graphite; const c = page.content || {}; const head = '' + esc(c.headline || page.title || 'Page') + '' + '' + (page.status !== 'published' ? '' : '') + (c.image ? '' : '') + ''; let body = ''; const hero = c.image && href(c.image) ? '
' + esc(c.imageAlt || '') + '
' : ''; if (page.type === 'squeeze') { body = '
' + (c.eyebrow ? '
' + esc(c.eyebrow) + '
' : '') + '

' + esc(c.headline || '') + '

' + (c.sub ? '

' + esc(c.sub) + '

' : '') + hero + bullets(c.bullets) + formArea(page, opts) + '

' + esc(c.privacy || 'No spam, ever. Unsubscribe with one click.') + '

'; } else if (page.type === 'review') { body = '
' + (c.eyebrow ? '
' + esc(c.eyebrow) + '
' : '
Review
') + '

' + esc(c.headline || '') + '

' + (c.rating ? stars(c.rating) : '') + (c.sub ? '

' + esc(c.sub) + '

' : '') + hero + paras(c.body) + ((c.pros && c.pros.length) || (c.cons && c.cons.length) ? '

What works

    ' + (c.pros || []).filter(Boolean).map(x => '
  • ' + esc(x) + '
  • ').join('') + '

What to know

    ' + (c.cons || []).filter(Boolean).map(x => '
  • ' + esc(x) + '
  • ').join('') + '
' : '') + (c.verdict ? '
Verdict. ' + esc(c.verdict) + '
' : '') + ctaBtn(c.cta) + '
'; } else { // bridge body = '
' + (c.eyebrow ? '
' + esc(c.eyebrow) + '
' : '') + '

' + esc(c.headline || '') + '

' + (c.sub ? '

' + esc(c.sub) + '

' : '') + hero + paras(c.body) + bullets(c.bullets) + ctaBtn(c.cta) + (c.bonus ? '

' + esc(c.bonusTitle || 'Bonus when you join through this page') + '

' + paras(c.bonus) + '
' : '') + ctaBtn(c.cta) + '
'; } const foot = '
' + esc(c.disclaimer || 'Results depend on effort. Nothing here is a promise of income.') + (opts.footerLink ? ' · ' + esc(opts.footerText || 'Made with LinkSpin') + '' : '') + '
'; return head + body + foot + ''; } module.exports = { render, PALETTE_NAMES };