Pages: bridge, review and squeeze pages from a scan plus an angle; parse-or-refuse forms; member-owned leads with CSV; served at /p/<slug> on every domain under a real CSP; lead event on the postback rails

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-29 16:06:11 -05:00
parent 8e1ddb892f
commit 53f5d51821
9 changed files with 459 additions and 3 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ window.CR = (function () {
];
// screens not built yet fall back to the classic dashboard pane so nothing is a dead end
const FALLBACK = { pages: '/my#promo', zones: '/my#campaigns', team: '/my#line', wallet: '/my#wallet' };
const BUILT = new Set(['links', 'reports', 'team', 'wallet']);
const BUILT = new Set(['links', 'pages', 'reports', 'team', 'wallet']);
let ME = null, toastT;
function toast(msg, bad) { let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; t.setAttribute('role', 'status'); document.body.appendChild(t); } t.textContent = msg; t.style.background = bad ? '#FF7A7A' : ''; t.classList.add('on'); clearTimeout(toastT); toastT = setTimeout(() => t.classList.remove('on'), 2000); }
async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; }
+61
View File
@@ -0,0 +1,61 @@
// LinkSpin Pages screen: gallery + wizard (scan -> type -> angle -> write) + editor + leads.
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
let PAGES = [], SEL = null, SCAN = null, TYPE = 'bridge', HOSTS = [];
const PAL = { graphite: '#3B9DFF', ink: '#B8410E', ember: '#FF8A3D' };
CR.mount({ active: 'pages', title: 'Pages', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ New page</button>' });
const pageUrl = p => 'https://' + (HOSTS[0] || location.host) + '/p/' + p.slug;
async function load(keepSel) {
let r; try { r = await CR.get('/api/my/pages'); } catch (e) { CR.sub('could not load'); return; }
PAGES = r.pages || []; HOSTS = r.hosts || [];
const pubd = PAGES.filter(p => p.status === 'published').length;
CR.sub(PAGES.length + ' page' + (PAGES.length === 1 ? '' : 's') + ' · ' + pubd + ' live');
const views = PAGES.reduce((n, p) => n + p.views, 0), leads = PAGES.reduce((n, p) => n + p.leads, 0), clicks = PAGES.reduce((n, p) => n + p.clicks, 0);
$('tiles').innerHTML = [['Pages', fmt(PAGES.length)], ['Live', fmt(pubd)], ['Views', fmt(views)], ['Clicks through', fmt(clicks)], ['Leads on your list', fmt(leads)]].map(([k, v], i) => '<div class="tile' + (i === 4 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
$('gal').innerHTML = PAGES.length ? PAGES.map(p => '<div class="card' + (p.id === SEL ? ' on' : '') + '" data-id="' + p.id + '" role="button" tabindex="0"><div class="thumb"><i class="t"></i><i style="width:55%"></i><i style="width:65%"></i><i class="b"></i></div><div class="cap"><b>' + esc(p.title) + '</b><span class="mono muted" style="font-size:11px">' + p.type + ' · ' + (p.status === 'published' ? '<span class="ok">live</span>' : 'draft') + ' · ' + fmt(p.views) + ' views' + (p.leads ? ' · ' + fmt(p.leads) + ' leads' : '') + '</span></div></div>').join('')
: '<div class="muted">No pages yet. Scan the page you promote and write your first bridge page in a minute.</div>';
$('gal').querySelectorAll('.card').forEach(c => { const go = () => openEditor(c.dataset.id); c.addEventListener('click', go); c.addEventListener('keydown', e => { if (e.key === 'Enter') go(); }); });
try { const L = await CR.get('/api/my/pages/leads'); const rows = L.leads || []; $('leadsBox').hidden = !rows.length; $('leadRows').innerHTML = rows.slice(0, 50).map(l => '<div class="rw"><span><b>' + esc(l.email) + '</b>' + (l.name ? ' <span class="muted">' + esc(l.name) + '</span>' : '') + '</span><span class="muted">' + esc(l.page) + '</span><span class="mono muted" style="font-size:11px">' + new Date(l.ts).toLocaleString() + '</span></div>').join(''); $('leadFoot').textContent = rows.length + ' lead' + (rows.length === 1 ? '' : 's') + ' on your list · yours to export'; } catch (e) {}
if (keepSel && SEL) openEditor(SEL, true);
}
// wizard
$('types').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { TYPE = b.dataset.t; $('types').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); }));
$('scanBtn').addEventListener('click', async () => { const url = $('scanUrl').value.trim(); if (!url) return $('scanUrl').focus(); $('scanBtn').disabled = true; $('scanOut').hidden = false; $('scanOut').innerHTML = '<span class="muted">Scanning…</span>'; try { const r = await api('/api/my/pages/scan', { url }); SCAN = r.scan; $('scanOut').innerHTML = '<span class="mono ok" style="font-size:11px">SCANNED · HTTP ' + SCAN.status + '</span><div><b>' + esc(SCAN.title || SCAN.h1 || '(no title)') + '</b></div><div class="muted">' + esc((SCAN.description || '').slice(0, 160)) + '</div>' + (SCAN.image ? '<div class="muted mono" style="font-size:11px">image found</div>' : '') + (SCAN.bullets.length ? '<div class="muted mono" style="font-size:11px">' + SCAN.bullets.length + ' points found</div>' : ''); } catch (e) { SCAN = null; $('scanOut').innerHTML = '<span class="bad">' + esc(e.message) + '</span>'; } $('scanBtn').disabled = false; });
async function createPage(writeIt) {
const url = $('scanUrl').value.trim(); const angle = $('angle').value.trim();
if (!SCAN && url && writeIt) { $('scanBtn').click(); await new Promise(r => setTimeout(r, 2500)); }
try {
const r = await api('/api/my/pages', { type: TYPE, title: (SCAN && (SCAN.title || SCAN.h1)) || angle || 'New ' + TYPE + ' page', angle, scan: SCAN || (url ? { url } : null), content: { cta: { url: url, text: TYPE === 'squeeze' ? 'Send me the details' : 'Take a look' }, headline: angle || '' } });
SEL = r.page.id;
if (writeIt) { toast('Writing…'); await api('/api/my/pages/' + SEL + '/write', { angle, cta: url }); }
await load(); openEditor(SEL);
} catch (e) { toast(e.message, true); }
}
$('writeBtn').addEventListener('click', () => createPage(true)); $('blankBtn').addEventListener('click', () => createPage(false));
$('newBtn').addEventListener('click', () => { $('editor').hidden = true; $('wizard').hidden = false; $('scanUrl').focus(); });
// editor
const F = { bridge: [['eyebrow', 'Eyebrow'], ['headline', 'Headline'], ['sub', 'Subhead'], ['body', 'Body, blank line between paragraphs', 'ta'], ['bullets', 'Bullets, one per line', 'ta'], ['bonusTitle', 'Bonus title'], ['bonus', 'Bonus text', 'ta'], ['ctaText', 'Button text'], ['ctaUrl', 'Button link'], ['image', 'Hero image URL'], ['disclaimer', 'Footer line']],
review: [['eyebrow', 'Eyebrow'], ['headline', 'Headline'], ['rating', 'Rating 1 to 5'], ['sub', 'Subhead'], ['body', 'Review body, blank line between paragraphs', 'ta'], ['pros', 'What works, one per line', 'ta'], ['cons', 'What to know, one per line', 'ta'], ['verdict', 'Verdict'], ['ctaText', 'Button text'], ['ctaUrl', 'Button link'], ['image', 'Hero image URL'], ['disclaimer', 'Footer line']],
squeeze: [['eyebrow', 'Eyebrow'], ['headline', 'Headline'], ['sub', 'Subhead'], ['bullets', 'What they get, one per line', 'ta'], ['ctaText', 'Button text'], ['ctaUrl', 'Where they go after the form'], ['image', 'Image URL'], ['privacy', 'Privacy line'], ['formEmbed', 'Your autoresponder form (optional, plain HTML form only, no JavaScript). Leave empty to capture leads on your LinkSpin list.', 'ta'], ['disclaimer', 'Footer line']] };
function openEditor(id, quiet) {
const p = PAGES.find(x => x.id === id); if (!p) return; SEL = id;
$('gal').querySelectorAll('.card').forEach(c => c.classList.toggle('on', c.dataset.id === id));
$('wizard').hidden = true; $('editor').hidden = false;
$('edTitle').textContent = p.title; $('edStatus').innerHTML = p.status === 'published' ? '<span class="ok"><span class="dot"></span>LIVE</span>' : '<span class="warn"><span class="dot"></span>DRAFT</span>';
$('edPublish').textContent = p.status === 'published' ? 'Unpublish' : 'Publish'; $('edPreview').href = '/p/' + p.slug + '?preview=1';
$('edUrl').hidden = p.status !== 'published'; $('edUrl').textContent = pageUrl(p);
const c = p.content || {}; const v = k => k === 'ctaText' ? (c.cta && c.cta.text) || '' : k === 'ctaUrl' ? (c.cta && c.cta.url) || '' : Array.isArray(c[k]) ? c[k].join('\n') : (c[k] == null ? '' : c[k]);
$('edFields').innerHTML = F[p.type].map(([k, label, ta]) => '<label class="lbl">' + esc(label) + (ta ? '<textarea class="field" id="f-' + k + '">' + esc(v(k)) + '</textarea>' : '<input class="field' + (/Url|image/i.test(k) ? ' mono' : '') + '" id="f-' + k + '" value="' + esc(v(k)) + '">') + '</label>').join('');
$('pal').innerHTML = Object.entries(PAL).map(([k, col]) => '<button type="button" title="' + k + '" data-p="' + k + '" class="' + ((p.design && p.design.palette) === k ? 'on' : '') + '" style="background:' + col + '"></button>').join('');
$('pal').querySelectorAll('button').forEach(b => b.addEventListener('click', async () => { try { await api('/api/my/pages/' + p.id, { palette: b.dataset.p }); load(true); } catch (e) { toast(e.message, true); } }));
if (!quiet && window.matchMedia('(max-width:900px)').matches) $('side').scrollIntoView({ behavior: 'smooth' });
}
function collect(p) { const g = k => { const el = $('f-' + k); return el ? el.value : undefined; }; const c = {}; for (const [k] of F[p.type]) { if (k === 'ctaText' || k === 'ctaUrl') continue; c[k] = g(k); } c.cta = { text: g('ctaText'), url: g('ctaUrl') }; for (const k of ['bullets', 'pros', 'cons']) if (c[k] != null) c[k] = c[k].split('\n'); return c; }
$('edSave').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; try { await api('/api/my/pages/' + p.id, { content: collect(p), title: ($('f-headline').value || p.title).slice(0, 100) }); toast('Saved'); load(true); } catch (e) { toast(e.message, true); } });
$('edPublish').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; try { await api('/api/my/pages/' + p.id, { content: collect(p) }); const r = await api('/api/my/pages/' + p.id, { status: p.status === 'published' ? 'draft' : 'published' }); toast(r.page.status === 'published' ? 'Live at ' + pageUrl(r.page) : 'Unpublished'); load(true); } catch (e) { toast(e.message, true); } });
$('edRewrite').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; const v = await dialog({ title: 'Write again', text: 'A fresh draft from the scan and your angle. Your current text is replaced.', fields: [{ k: 'angle', label: 'Angle', value: p.angle || '' }], ok: 'Write' }); if (!v) return; try { toast('Writing…'); await api('/api/my/pages/' + p.id + '/write', { angle: v.angle }); load(true); } catch (e) { toast(e.message, true); } });
$('edDelete').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; if (!await dialog({ title: 'Delete ' + p.title + '?', text: 'The page stops answering. Leads already on your list stay.', ok: 'Delete', danger: true })) return; try { await api('/api/my/pages/' + p.id, { remove: true }); SEL = null; $('editor').hidden = true; $('wizard').hidden = false; load(); } catch (e) { toast(e.message, true); } });
$('edClose').addEventListener('click', () => { $('editor').hidden = true; $('wizard').hidden = false; });
$('edSpin').addEventListener('click', async () => { const p = PAGES.find(x => x.id === SEL); if (!p) return; if (p.status !== 'published') return toast('Publish the page first.', true); try { const r = await CR.get('/api/my/rotations'); const rots = r.rotations || []; if (!rots.length) { const c = await api('/api/my/rotations', { name: p.title }); await api('/api/my/rotations/' + c.rotation.id + '/dest', { url: pageUrl(p), label: p.title, weight: 10 }); toast('New spin made with this page'); location.href = '/links#' + c.rotation.id; return; } const v = await dialog({ title: 'Which spin?', html: '<label class="lbl">Spin<select class="field" id="dlg-rot">' + rots.map(x => '<option value="' + x.id + '">' + esc(x.name) + '</option>').join('') + '</select></label>', ok: 'Add page' }); if (!v) return; const id = document.getElementById('dlg-rot') ? document.getElementById('dlg-rot').value : rots[0].id; await api('/api/my/rotations/' + id + '/dest', { url: pageUrl(p), label: p.title, weight: 10 }); toast('Added to the spin'); location.href = '/links#' + id; } catch (e) { toast(e.message, true); } });
CR.requireSession(() => load());
})();
+14
View File
@@ -0,0 +1,14 @@
// LinkSpin page tracking (external so pages carry a real CSP). (1) click-id passthrough: params on the page URL
// (clickid, subids, utm, lsid) ride onto every CTA link; (2) our own capture form gets the lsid; (3) a view /
// click beacon per page (no cookies, no personal data).
(function () {
var s = document.currentScript, slug = s && s.getAttribute('data-page'); if (!slug) return;
var P = {}, n = 0;
try { new URLSearchParams(location.search).forEach(function (v, k) { if (n < 20 && /^[a-zA-Z0-9_-]{1,32}$/.test(k)) { P[k] = String(v).slice(0, 200); n++; } }); } catch (e) {}
var lsid = /^[a-z0-9]{6,20}$/i.test(P.lsid || '') ? P.lsid : '';
document.querySelectorAll('a[data-cta]').forEach(function (a) {
try { var u = new URL(a.href); for (var k in P) if (!u.searchParams.has(k)) u.searchParams.set(k, P[k]); a.href = u.toString(); } catch (e) {}
a.addEventListener('click', function () { try { navigator.sendBeacon('/api/p/' + slug + '/hit', new Blob([JSON.stringify({ k: 'cta' })], { type: 'application/json' })); } catch (e) {} });
});
var f = document.querySelector('.lsform input[name="lsid"]'); if (f && lsid) f.value = lsid;
})();
+61
View File
@@ -0,0 +1,61 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow">
<title>Pages · LinkSpin</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20260929b">
<style>
.ws{display:grid;grid-template-columns:minmax(0,1fr) 440px;min-height:calc(100vh - 53px)}
.body{padding:16px 24px;display:grid;gap:14px;align-content:start}
.gal{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:10px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);overflow:hidden;cursor:pointer;display:grid}
.card.on{border-color:var(--accent)}
.thumb{height:96px;background:var(--panel-2);padding:12px;display:grid;gap:6px;align-content:start} .thumb i{display:block;background:var(--line);height:6px;border-radius:2px} .thumb i.t{background:var(--accent-dim);height:10px;width:70%} .thumb i.b{background:var(--accent);height:14px;width:40%;margin-top:auto}
.card .cap{padding:10px 12px;display:grid;gap:3px} .card .cap b{font-size:13px}
.side{border-left:1px solid var(--line);padding:16px;display:grid;gap:12px;align-content:start;background:var(--rail)}
.side h2{font-family:var(--display);font-size:18px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;margin:0}
.types{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px} .types button{background:transparent;border:1px solid var(--line);border-radius:var(--r);color:var(--ink);padding:8px 6px;cursor:pointer;display:grid;gap:2px;text-align:left} .types button.on{border-color:var(--accent)} .types small{color:var(--muted);font-size:11px}
.ed{display:grid;gap:10px} .ed textarea{min-height:90px;resize:vertical}
.pal{display:flex;gap:6px} .pal button{width:28px;height:28px;border-radius:50%;border:2px solid transparent;cursor:pointer} .pal button.on{border-color:var(--ink)}
.leads .rw{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) 110px}
@media (max-width:900px){.ws{grid-template-columns:1fr}.side{border-left:0;border-top:1px solid var(--line)}.body{padding:12px 16px}.types{grid-template-columns:1fr}}
</style>
</head>
<body>
<div id="page">
<div class="ws">
<div class="body">
<div class="tiles" id="tiles"></div>
<div class="sec">Your pages · click one to edit</div>
<div class="gal" id="gal"></div>
<div class="tbl leads" id="leadsBox" hidden><div class="hd"><span>Lead</span><span>Page</span><span>When</span></div><div id="leadRows"></div><div class="ft" style="display:flex;justify-content:space-between;align-items:center"><span id="leadFoot"></span><a class="btn sm" id="leadCsv" href="/api/my/pages/leads.csv">Download CSV</a></div></div>
</div>
<div class="side" id="side">
<div id="wizard">
<h2>New page</h2>
<label class="lbl">Paste the page you are sending people to<input class="field mono" id="scanUrl" type="url" placeholder="https://"></label>
<button class="btn pri" type="button" id="scanBtn">Scan it</button>
<div id="scanOut" class="panel" hidden></div>
<div class="sec">Page type</div>
<div class="types" id="types"><button type="button" class="on" data-t="bridge"><b>Bridge</b><small>Your story, then the link</small></button><button type="button" data-t="review"><b>Review</b><small>Pros, cons, verdict</small></button><button type="button" data-t="squeeze"><b>Squeeze</b><small>Email first, then the link</small></button></div>
<label class="lbl">Angle, one line<input class="field" id="angle" type="text" maxlength="160" placeholder="I got paid before I finished my coffee"></label>
<div style="display:flex;gap:8px"><button class="btn pri" type="button" id="writeBtn">Write it</button><button class="btn" type="button" id="blankBtn">Start blank</button></div>
<div class="muted">A published page carries tracking and goes straight into any spin. Forms: our own capture (leads stay on your list) or your provider's plain HTML form, checked before it is used.</div>
</div>
<div id="editor" hidden>
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap"><h2 id="edTitle">Page</h2><span class="grow"></span><button class="btn sm" type="button" id="edClose">Close</button></div>
<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:center"><span id="edStatus"></span><a class="btn sm" id="edPreview" href="#" target="_blank" rel="noopener">Preview</a><button class="btn sm pri" type="button" id="edPublish">Publish</button><button class="btn sm" type="button" id="edSpin">Put it in a spin</button><button class="btn sm danger" type="button" id="edDelete">Delete</button></div>
<div class="code" id="edUrl" hidden></div>
<div class="ed" id="edFields"></div>
<div style="display:flex;gap:8px;align-items:center"><span class="sec">Look</span><div class="pal" id="pal"></div><span class="grow"></span><button class="btn sm" type="button" id="edRewrite">Write again</button><button class="btn pri" type="button" id="edSave">Save</button></div>
</div>
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929a"></script>
<script src="/assets/pages-screen.js?v=20260929a"></script>
</body>
</html>