f6621a8e34
B2: the built-in page form posted an empty lsid (pt.js only filled .lsform, the pasted-form class), so page leads never
reached the rotator 'lead' conversion or the postback. The server now fills the hidden lsid at render from ?lsid or the
ls.click cookie, the lead POST falls back to the ls.click cookie when the form sends none, and pt.js fills both .ls-form
and .lsform as a fallback (cache tag pt.js?v=2). Pasted provider forms get no added field: some providers reject unknown
fields, so the lsid only rides along when the member's own form code has an lsid field.
B4: /p.gif now stores the pixel's e= event name (lowercase [a-z0-9_-]{1,32}) in a parallel ev map in audiences.json;
hits stay plain timestamps, so old rows count, match and prune as before. The audiences list shows counts by event
(events for cookie visitors, eventsSoft for 24 h soft keys).
B3: a pixel hit with no ls.vid cookie still offers the cookie but is counted under the 24 h IP + user agent key only,
not a fresh 30-day visitor id, so a cookie-blocking browser counts once.
Test: qa/lsid-pixel.test.mjs (bash qa/run.sh lsid), unit + local end to end on a throwaway data dir.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
12 KiB
JavaScript
95 lines
12 KiB
JavaScript
// LinkSpin page renderer (2026-09-29, restyled 2026-10-07 on the Branded Voice design system: palette x design x
|
|
// layout + niche presets, see pagestyle.js). 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 S = require('./pagestyle');
|
|
const esc = S.esc;
|
|
const href = u => { const s = String(u || '').trim(); if (/^[/]u[/]pages[/][a-z0-9]+[/][a-z0-9]+[.](png|jpe?g|webp|gif)$/i.test(s)) return s; return /^https?:\/\/[^\s"'<>]+$/i.test(s) && s.length <= 700 ? s : ''; };
|
|
const PALETTE_NAMES = Object.keys(S.PALETTES).concat(['ink', 'ember']);
|
|
|
|
// the three knobs a page carries, with safe fallbacks for anything stored by older code
|
|
function knobs(page) { const d = page.design || {}; return { pk: S.paletteKey(d.palette), design: S.designKey(d.design), layout: S.layoutKey(d.layout), niche: S.nicheKey(d.niche), hero: d.hero }; }
|
|
|
|
function baseCss(k) {
|
|
const P = S.PALETTES[k.pk], C = P.c, dkGround = k.design === 'dark' || k.design === 'ignition';
|
|
const ground = k.design === 'editorial' ? C.cream : k.design === 'ignition' ? '#060606' : k.design === 'light' ? '#fff' : C.inkGreen;
|
|
const bodyInk = k.design === 'editorial' ? C.body : k.design === 'ignition' ? S.rgba(C.cream, 0.85) : k.design === 'light' ? C.body : S.rgba(C.cream, 0.82);
|
|
const font = k.design === 'editorial' ? '18px/1.7 ' + S.SERIF : '17px/1.6 ' + S.FONT;
|
|
const heroSkin = k.design === 'light' ? 'background:radial-gradient(ellipse 800px 480px at 85% 0%,' + S.rgba(C.gold, 0.1) + ',transparent 60%),radial-gradient(ellipse 700px 500px at 0% 100%,' + S.rgba(C.green, 0.08) + ',transparent 60%),#fff;color:' + C.ink
|
|
: k.design === 'editorial' ? 'background:' + C.cream + ';color:' + C.ink + ';border-bottom:2px solid ' + C.ink
|
|
: k.design === 'ignition' ? 'background:transparent;color:' + C.cream
|
|
: 'background:radial-gradient(ellipse 900px 500px at 70% -10%,' + S.rgba(C.gold, 0.16) + ',transparent 60%),radial-gradient(ellipse 700px 480px at 12% 8%,' + S.rgba(C.green, 0.35) + ',transparent 65%),' + C.inkGreen + ';color:' + C.cream;
|
|
const heroInk = dkGround ? C.cream : C.ink, heroBody = dkGround ? S.rgba(C.cream, 0.72) : C.body;
|
|
const h1font = k.design === 'ignition' ? 'font-family:' + S.IGNITION_DISPLAY + ';font-weight:400;text-transform:uppercase;letter-spacing:.5px;line-height:.98;font-size:clamp(40px,7vw,72px)' : k.design === 'editorial' ? 'font-family:' + S.SERIF + ';font-weight:700;font-size:clamp(34px,5.6vw,54px);line-height:1.08;letter-spacing:-.01em' : 'font-weight:800;font-size:clamp(32px,5.6vw,52px);line-height:1.08;letter-spacing:-.028em';
|
|
return '*{box-sizing:border-box}body{margin:0;background:' + ground + ';color:' + bodyInk + ';font:' + font + ';-webkit-font-smoothing:antialiased}a{color:' + (dkGround ? C.goldSoft : C.green) + '}p{margin:0 0 16px}'
|
|
+ '.hero,main,.foot,.wrap{position:relative;z-index:1}'
|
|
+ '.hero{' + heroSkin + ';padding:72px 24px 64px;text-align:center;overflow:hidden}.hero>*{position:relative;z-index:1}'
|
|
+ '.hero h1{' + h1font + ';margin:0 auto 18px;max-width:840px;color:' + heroInk + ';text-wrap:balance}.hero .lead{font-size:19px;line-height:1.6;color:' + heroBody + ';max-width:660px;margin:0 auto 8px}.hero .media{max-width:760px;margin:34px auto 0}.hero .ctawrap{margin:28px 0 0}'
|
|
+ '.hs-grid{display:grid;grid-template-columns:1.1fr .9fr;gap:56px;align-items:center;max-width:1080px;margin:0 auto;text-align:left}.hero.split{text-align:left;padding:72px 32px 64px}.hero.split h1{margin:0 0 18px;text-align:left;max-width:none}.hero.split .lead{margin:0 0 8px;max-width:none}.hero.split .media{margin:0}.ctawrap{text-align:center}.hero.split .ctawrap{text-align:left}'
|
|
+ 'main{max-width:680px;margin:0 auto;padding:56px 24px 64px}main h2{font-size:' + (k.design === 'editorial' ? '28px;font-family:' + S.SERIF : '24px') + ';margin:28px 0 10px;color:' + (dkGround ? C.cream : C.ink) + '}main h3{font-size:18px;margin:18px 0 6px;color:' + (dkGround ? C.cream : C.ink) + '}'
|
|
+ (k.design === 'editorial' ? 'main p:first-of-type::first-letter{float:left;font-size:58px;line-height:.9;padding:6px 10px 0 0;color:' + C.gold + ';font-weight:700}' : '')
|
|
// squeeze card
|
|
+ '.wrap{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 20px 0}'
|
|
+ '.card{background:' + (k.design === 'ignition' ? 'rgba(8,8,8,.55)' : '#fff') + ';max-width:560px;width:100%;border-radius:12px;border-top:4px solid ' + C.gold + ';padding:44px 40px 40px;text-align:center;box-shadow:0 24px 80px rgba(0,0,0,' + (dkGround ? '.45' : '.12') + ');color:' + (k.design === 'ignition' ? S.rgba(C.cream, 0.85) : C.body) + (k.design === 'ignition' ? ';border:1px solid ' + S.rgba(S.hotRamp(k.pk).hot1, 0.3) + ';border-top:4px solid ' + S.hotRamp(k.pk).hot1 + ';backdrop-filter:blur(6px)' : '') + '}'
|
|
+ '.card h1{' + h1font.replace(/clamp\([^)]*\)/, 'clamp(28px,5.5vw,38px)') + ';margin:0 0 16px;color:' + (k.design === 'ignition' ? '#fff' : C.ink) + '}.card .sub{font-size:18px;line-height:1.6;margin:0 0 24px}.card ul.checks{margin:0 auto 24px;max-width:26em}.card .hero-img{width:100%;height:auto;border-radius:12px;margin:0 0 20px}'
|
|
+ '.sq-grid{display:grid;grid-template-columns:1fr .85fr;gap:56px;align-items:center;max-width:1060px;width:100%;margin:0 auto}.sq-grid .card{max-width:none;text-align:left}.sq-grid ul.checks{max-width:none;margin:0 0 24px}'
|
|
+ '@media(max-width:820px){.hs-grid,.sq-grid{grid-template-columns:1fr;gap:36px}.hero.split{text-align:center}.hero.split h1{text-align:center}.hero.split .ctawrap{text-align:center}.sq-grid .card{text-align:center}.sq-grid .pv,.hs-grid .media{order:-1}}@media(max-width:480px){.card{padding:32px 20px 28px}.hero{padding:52px 18px 44px}}'
|
|
+ S.kitCss(k.design, k.pk) + S.visualCss(k.pk)
|
|
+ (dkGround ? '.pc div{background:rgba(255,255,255,.04);border-color:' + S.rgba(C.cream, 0.1) + ';color:' + S.rgba(C.cream, 0.85) + '}.verdict{background:rgba(255,255,255,.04);color:' + S.rgba(C.cream, 0.85) + '}.bonus{background:rgba(255,255,255,.04);border-color:' + S.rgba(C.cream, 0.12) + ';box-shadow:none;color:' + S.rgba(C.cream, 0.85) + '}.bonus .tag{background:' + S.rgba(C.gold, 0.16) + ';color:' + C.goldSoft + '}' : '')
|
|
+ (k.design === 'editorial' ? '.foot{color:' + C.muted + '}' : dkGround ? '.foot{color:rgba(245,241,232,.5)}' : '.foot{color:' + C.muted + '}');
|
|
}
|
|
|
|
const paras = t => String(t || '').split(/\n\s*\n/).map(x => x.trim()).filter(Boolean).map(x => '<p>' + esc(x).replace(/\n/g, '<br>') + '</p>').join('');
|
|
const checks = arr => (arr || []).filter(Boolean).length ? '<ul class="checks">' + arr.filter(Boolean).map(b => '<li>' + esc(b) + '</li>').join('') + '</ul>' : '';
|
|
function stars(n) { const k = Math.max(0, Math.min(5, Math.round(Number(n) || 0))); return '<div class="rating" aria-label="' + k + ' out of 5">' + '★'.repeat(k) + '☆'.repeat(5 - k) + '</div>'; }
|
|
const eyebrow = t => t ? '<div class="k-eyebrow"><span class="dot"></span>' + esc(t) + '</div>' : '';
|
|
function ctaBtn(c, extra) { const u = href(c && c.url); const t = esc((c && c.text) || 'Continue'); return u ? '<div class="ctawrap">' + '<a class="cta" href="' + esc(u) + '" data-cta>' + t + '</a>' + (extra || '') + '</div>' : ''; }
|
|
const headline = (k, t) => (k.design === 'ignition' ? S.blazeHeadline(t) : esc(t || ''));
|
|
// the visual on the right of a split: the member's image, else the niche hero, else the procedural card
|
|
function sideVisual(k, c) {
|
|
const img = href(c.image) || S.nicheHero(k.niche, k.hero);
|
|
if (img) return '<div class="media"><div class="k-imgframe"><img src="' + esc(img) + '" alt="' + esc(c.imageAlt || '') + '" loading="eager"></div></div>';
|
|
return '<div class="media">' + S.visualHtml(c.headline, c.bullets && c.bullets.length ? c.bullets : c.pros, c.price) + '</div>';
|
|
}
|
|
function formArea(page, opts) {
|
|
const c = page.content || {};
|
|
if (c.formEmbed) { const parsed = formrestyle.parse(c.formEmbed); if (parsed) return '<div class="formarea">' + formrestyle.html(parsed, (c.cta && c.cta.text) || 'Send me the details') + '</div>'; }
|
|
return '<div class="formarea"><form class="ls-form" method="post" action="' + esc(opts.leadUrl) + '"><input class="ls-in" type="text" name="name" placeholder="Your first name"><input class="ls-in" type="email" name="email" placeholder="Your best email" required><input type="text" name="website" tabindex="-1" autocomplete="off" style="position:absolute;left:-9999px" aria-hidden="true"><input type="hidden" name="lsid" value="' + esc(/^[a-z0-9]{6,20}$/i.test(String(opts.lsid || '')) ? opts.lsid : '') + '">'
|
|
+ '<button class="cta" type="submit">' + esc((c.cta && c.cta.text) || 'Send me the details') + '</button></form></div>';
|
|
}
|
|
|
|
function render(page, opts) {
|
|
opts = opts || {}; const k = knobs(page); const c = page.content || {}; const split = k.layout === 'split';
|
|
const img = href(c.image) || S.nicheHero(k.niche, k.hero);
|
|
const head = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>' + esc(c.headline || page.title || 'Page') + '</title>'
|
|
+ '<meta name="description" content="' + esc((c.sub || '').slice(0, 160)) + '">' + (page.status !== 'published' ? '<meta name="robots" content="noindex,nofollow">' : '')
|
|
+ (img ? '<meta property="og:image" content="' + esc(img) + '">' : '') + '<meta property="og:title" content="' + esc(c.headline || page.title || '') + '"><meta property="og:description" content="' + esc((c.sub || '').slice(0, 200)) + '">'
|
|
+ '<style>' + baseCss(k) + '</style></head><body>';
|
|
let body = '';
|
|
if (page.type === 'squeeze') {
|
|
const card = '<main class="card">' + eyebrow(c.eyebrow || 'Free · Instant access') + '<h1>' + headline(k, c.headline) + '</h1>' + (c.sub ? '<p class="sub">' + esc(c.sub) + '</p>' : '')
|
|
+ (!split && img ? '<img class="hero-img" src="' + esc(img) + '" alt="' + esc(c.imageAlt || '') + '">' : '') + checks(c.bullets) + formArea(page, opts)
|
|
+ (c.privacy ? '<p class="privacy">' + esc(c.privacy) + '</p>' : '<p class="privacy">No spam. Unsubscribe any time.</p>') + '</main>';
|
|
body = '<div class="wrap">' + (split ? '<div class="sq-grid reveal">' + card + sideVisual(k, c) + '</div>' : card.replace('<main class="card">', '<main class="card reveal">')) + '</div>';
|
|
} else {
|
|
const isReview = page.type === 'review';
|
|
const heroCopy = eyebrow(c.eyebrow || (isReview ? 'Review' : '')) + '<h1>' + headline(k, c.headline) + '</h1>' + (isReview && c.rating ? stars(c.rating) : '') + (c.sub ? '<p class="lead">' + esc(c.sub) + '</p>' : '') + ctaBtn(c.cta);
|
|
const media = img ? '<div class="media"><div class="k-imgframe"><img src="' + esc(img) + '" alt="' + esc(c.imageAlt || '') + '"></div></div>' : (split ? sideVisual(k, c) : '');
|
|
const hero = split ? '<header class="hero split reveal"><div class="hs-grid"><div>' + heroCopy + '</div>' + media + '</div></header>' : '<header class="hero reveal">' + heroCopy + media + '</header>';
|
|
let main = paras(c.body);
|
|
if (isReview) {
|
|
main += ((c.pros && c.pros.length) || (c.cons && c.cons.length) ? '<div class="pc"><div><h3>What works</h3><ul>' + (c.pros || []).filter(Boolean).map(x => '<li>' + esc(x) + '</li>').join('') + '</ul></div><div><h3>What to know</h3><ul>' + (c.cons || []).filter(Boolean).map(x => '<li>' + esc(x) + '</li>').join('') + '</ul></div></div>' : '')
|
|
+ (c.verdict ? '<div class="verdict"><b>Verdict.</b> ' + esc(c.verdict) + '</div>' : '');
|
|
} else {
|
|
main += checks(c.bullets) + (c.bonus ? '<div class="bonus"><div class="tag">' + esc(c.bonusTitle || 'Bonus when you join through this page') + '</div><div class="in">' + paras(c.bonus) + '</div></div>' : '');
|
|
}
|
|
main += ctaBtn(c.cta);
|
|
body = hero + '<main>' + main + '</main>';
|
|
}
|
|
const foot = '<div class="foot">' + esc(c.disclaimer || 'Results depend on effort. Nothing here is a promise of income.') + (opts.footerLink ? ' · <a href="' + esc(opts.footerLink) + '">' + esc(opts.footerText || 'Made with LinkSpin') + '</a>' : '') + '</div>';
|
|
return head + body + foot + '<script src="' + esc(opts.trackSrc || '/assets/pt.js') + '" data-page="' + esc(page.slug) + '" defer></script>' + (opts.pixel ? '<img src="' + esc(opts.pixel) + '" alt="" width="1" height="1" style="position:absolute;left:-9999px;top:0" referrerpolicy="strict-origin-when-cross-origin">' : '') + '</body></html>';
|
|
}
|
|
module.exports = { render, PALETTE_NAMES, knobs, catalog: S.catalog };
|