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:
@@ -39,7 +39,8 @@ const toolkit = require('./toolkit');
|
||||
const registry = require('./registry'); // network registry: who is who across properties (LinkSpin, 2026-09-15)
|
||||
const carry = require('./carry'); // sponsor carry-over: engine activation, claim window, notices
|
||||
const rotator = require('./rotator');
|
||||
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29) // the rotator: rotations, weighted destinations, /r/<code>
|
||||
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29)
|
||||
const pages = require('./pages'); // member pages: bridge / review / squeeze, served at /p/<slug> (2026-09-29) // the rotator: rotations, weighted destinations, /r/<code>
|
||||
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
|
||||
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
||||
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
||||
@@ -389,6 +390,7 @@ async function boot() {
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean));
|
||||
rotator.init({ dataDir: DATA_DIR, geo, ownHosts });
|
||||
postbacks.init({ dataDir: DATA_DIR, ownHosts, rotator });
|
||||
pages.init({ dataDir: DATA_DIR, ownHosts, openrouterKey: () => { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; } } });
|
||||
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, send: async (c, t, th) => { await telegramSend(c, t, th); return true; } });
|
||||
setInterval(() => snapshot.tick().catch(e => console.error('snapshot', e.message)), 10 * 60 * 1000);
|
||||
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, site: 'https://linkspin-test.saasy.top' });
|
||||
@@ -873,6 +875,31 @@ const server = http.createServer(async (req, res) => {
|
||||
if (hit && hit.url) { res.writeHead(302, { Location: hit.url, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer-when-downgrade' }); return res.end(); }
|
||||
res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end(linkSitePage(reqHost(req), 'gone'));
|
||||
}
|
||||
// -- member pages: /p/<slug> on the app host and on every link domain; the lead form and the hit beacon live beside it
|
||||
let pm = /^\/p\/([a-z0-9-]{3,60})$/i.exec(p);
|
||||
if (pm && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||
const pg = pages.bySlug(pm[1]);
|
||||
const preview = u.searchParams.get('preview') === '1';
|
||||
if (!pg || (pg.status !== 'published' && !preview)) { res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end(isLinkHost(req) ? linkSitePage(reqHost(req), 'gone') : '<!doctype html><title>Not found</title><p style="font-family:system-ui;padding:40px">That page is not live.</p>'); }
|
||||
if (preview) { const sess = await auth.fromRequest(req); if (!sess || !sess.email || String(sess.email).toLowerCase() !== pg.owner) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); } }
|
||||
else pages.view(pg, req, 'view');
|
||||
const lsid = String(u.searchParams.get('lsid') || '');
|
||||
const hdr = { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin',
|
||||
'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'unsafe-inline'; img-src https: data:; form-action https: http:; base-uri 'none'; frame-ancestors *; connect-src 'self'" };
|
||||
if (/^[a-z0-9]{6,20}$/i.test(lsid)) hdr['Set-Cookie'] = 'ls.click=' + lsid + '; Path=/; SameSite=Lax; Max-Age=2592000' + (IS_PROD ? '; Secure' : '');
|
||||
res.writeHead(200, hdr); return res.end(pages.html(pg, { leadUrl: '/p/' + pg.slug + '/lead', trackSrc: '/assets/pt.js', footerLink: 'https://' + SITE_HOST + '/', footerText: 'Made with LinkSpin' }));
|
||||
}
|
||||
pm = /^\/p\/([a-z0-9-]{3,60})\/lead$/i.exec(p);
|
||||
if (pm && req.method === 'POST') {
|
||||
const raw = await new Promise(r => { let d = ''; req.on('data', c => { d += c; if (d.length > 20000) req.destroy(); }); req.on('end', () => r(d)); });
|
||||
const b = {}; try { const ct = String(req.headers['content-type'] || ''); if (/json/.test(ct)) Object.assign(b, JSON.parse(raw)); else for (const [k, v] of new URLSearchParams(raw)) b[k] = v; } catch (e) {}
|
||||
const r = await pages.lead(pm[1], b, req);
|
||||
if (r.error) { res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end('<!doctype html><title>Try again</title><p style="font-family:system-ui;padding:40px">' + r.error + ' <a href="javascript:history.back()">Go back</a></p>'); }
|
||||
if (r.owner && r.lsid) { try { postbacks.bindClick(String(b.email || '').toLowerCase(), r.lsid); const hit = await rotator.convert(r.lsid, 'lead', {}); if (hit) postbacks.fire(hit.owner, 'lead', Object.assign({ q: hit.q || {}, source: hit.s, country: hit.c, device: hit.dv, lsid: r.lsid, code: hit.code })).catch(() => {}); } catch (e) {} }
|
||||
res.writeHead(302, { Location: r.next || '/', 'Cache-Control': 'no-store' }); return res.end();
|
||||
}
|
||||
if (p.startsWith('/api/p/') && req.method === 'POST' && /\/hit$/.test(p)) { const sl = p.split('/')[3]; const pg = pages.bySlug(sl); if (pg) pages.view(pg, req, 'cta'); res.writeHead(204); return res.end(); }
|
||||
if (p === '/assets/pt.js' && isLinkHost(req)) return sendFile(res, path.join(PUBLIC_DIR, 'assets', 'pt.js'));
|
||||
// -- short link domains: a real small site (home, disclosure, terms, privacy, abuse) so the domain never looks parked
|
||||
if (isLinkHost(req)) {
|
||||
const page = { '/': 'home', '/disclosure': 'disclosure', '/terms': 'terms', '/privacy': 'privacy', '/abuse': 'abuse', '/robots.txt': 'robots' }[p];
|
||||
@@ -1804,6 +1831,33 @@ const server = http.createServer(async (req, res) => {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const r = await rotator.stats(s.email, m[1]); return r ? json(res, 200, r, { 'Cache-Control': 'no-store' }) : json(res, 404, { error: 'No such rotation.' });
|
||||
}
|
||||
if (p === '/api/my/pages' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const hosts = String(siteConfig().linkDomains || '').split(',').map(x => x.trim()).filter(x => x && !x.startsWith('www.'));
|
||||
return json(res, 200, { pages: await pages.list(s.email), hosts: hosts.length ? hosts : [SITE_HOST], types: pages.TYPES }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/pages' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const r = await pages.create(s.email, await readBody(req)); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
if (p === '/api/my/pages/scan' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const b = await readBody(req); const r = await pages.scan(b.url); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
if (p === '/api/my/pages/leads' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
return json(res, 200, { leads: await pages.leads(s.email, u.searchParams.get('page') || null) }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/pages/leads.csv' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const rows = await pages.leads(s.email, u.searchParams.get('page') || null);
|
||||
res.writeHead(200, { 'Content-Type': 'text/csv; charset=utf-8', 'Content-Disposition': 'attachment; filename="linkspin-leads.csv"', 'Cache-Control': 'no-store' }); return res.end(pages.csv(rows));
|
||||
}
|
||||
m = /^\/api\/my\/pages\/([a-f0-9]{10})(\/write)?$/.exec(p);
|
||||
if (m && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const b = await readBody(req); const r = m[2] ? await pages.write(s.email, m[1], b) : await pages.update(s.email, m[1], b); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
if (p === '/api/my/reports' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const days = Math.max(1, Math.min(365, Number(u.searchParams.get('days')) || 30));
|
||||
@@ -2841,6 +2895,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/my') return sendFile(res, path.join(PUBLIC_DIR, 'my.html'));
|
||||
if (p === '/links') return sendFile(res, path.join(PUBLIC_DIR, 'links.html')); // Control Room: the links workspace, first screen of the new front end (2026-09-29)
|
||||
if (p === '/reports') return sendFile(res, path.join(PUBLIC_DIR, 'reports.html'));
|
||||
if (p === '/pages') return sendFile(res, path.join(PUBLIC_DIR, 'pages.html'));
|
||||
if (p === '/team') return sendFile(res, path.join(PUBLIC_DIR, 'team.html'));
|
||||
if (p === '/wallet') return sendFile(res, path.join(PUBLIC_DIR, 'wallet.html'));
|
||||
if (p === '/admin') return sendFile(res, path.join(PUBLIC_DIR, 'admin.html'));
|
||||
|
||||
Reference in New Issue
Block a user