From c515a01441dfb3be5278fa489457eb47892583b6 Mon Sep 17 00:00:00 2001 From: martbost Date: Thu, 8 Oct 2026 17:40:05 -0500 Subject: [PATCH] Pages domain: member pages publish at the root of site.pagesDomain (lookfirst.page), /p/ kept everywhere; the pages host serves nothing else (/ -> app, unknown paths 404); Pages screen shows the new URLs Co-Authored-By: Claude Fable 5.1 --- public/assets/pages-screen.js | 6 +++--- public/pages.html | 2 +- server.js | 21 ++++++++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/public/assets/pages-screen.js b/public/assets/pages-screen.js index de71e05..30221a4 100644 --- a/public/assets/pages-screen.js +++ b/public/assets/pages-screen.js @@ -1,13 +1,13 @@ // 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 = []; + let PAGES = [], SEL = null, SCAN = null, TYPE = 'bridge', HOSTS = [], BASE = ''; let STYLES = { palettes: [], designs: [], layouts: [], niches: [] }; CR.mount({ active: 'pages', title: 'Pages', sub: 'loading', actions: '' }); - const pageUrl = p => 'https://' + (HOSTS[0] || location.host) + '/p/' + p.slug; + const pageUrl = p => (BASE || ('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 || []; if (r.styles) STYLES = r.styles; + PAGES = r.pages || []; HOSTS = r.hosts || []; BASE = r.pageBase || ''; if (r.styles) STYLES = r.styles; 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); diff --git a/public/pages.html b/public/pages.html index 8f1d57b..d24c2c6 100644 --- a/public/pages.html +++ b/public/pages.html @@ -70,6 +70,6 @@ - + diff --git a/server.js b/server.js index e069a58..0e282b3 100644 --- a/server.js +++ b/server.js @@ -284,7 +284,7 @@ function frameFetch(url, depth) { const mod = u.protocol === 'https:' ? https : http; // Our own hosts (the app and the link domains) answer the curtain's 503 to anonymous fetches while the // app is curtained, which made a test ad aimed at a spin link look dead (2026-10-07). Carry the pass. - const own = [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean)); + const own = [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []); const hdrs = { 'User-Agent': 'Mozilla/5.0 (compatible; LinkSpin-FrameCheck/1.0)', Accept: 'text/html' }; if (CURTAIN && own.includes(u.hostname.toLowerCase())) hdrs.Cookie = 'ls.pass=' + encodeURIComponent(CURTAIN); const rq = mod.get(u.href, { timeout: 8000, headers: hdrs }, r => { @@ -405,7 +405,7 @@ async function boot() { pipeline.init({ dataDir: DATA_DIR, accounts, coach, chain }); registry.init({ dataDir: DATA_DIR }); carry.init({ dataDir: DATA_DIR, accounts, registry, chain, mailer, messages, siteConfig, adminEmail: ADMIN_EMAIL, host: SITE_HOST }); - const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean)); + const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []); rotator.init({ dataDir: DATA_DIR, geo, ownHosts }); setInterval(() => { try { rotator.sweepDemos(); } catch (e) {} }, 60 * 60 * 1000); // unclaimed home-page demo spins expire after 24 h postbacks.init({ dataDir: DATA_DIR, ownHosts, rotator }); @@ -473,6 +473,7 @@ function siteConfig() { carryClaimDays: '3', carryNotices: '1', // 0 = carry-over notices stay on-site (test area), 1 = email too // sponsor with no wallet: days to link one before a downline seat walks up (LinkSpin) linkDomains: '', // comma list of short link domains this server answers for (each gets a real mini-site + /r/ redirects) + pagesDomain: '', // the host member pages are published on at the root (https:///); empty = first link domain under /p/ snapshotEnabled: '1', snapshotHourUtc: '14', snapshotTargets: 'feed,echo', // daily growth snapshot: 14 UTC = 9 AM Central; feed = proof channel, echo = shared payments topic pipelineMode: 'off', // Pipeline board: off = 'coming soon' card, preview = only the admin account sees the live board, on = everyone (Marty, 2026-09-15) pipelineEta: 'Sep 28', // what the coming-soon card and the roadmap promise @@ -831,6 +832,8 @@ function pushFeed(ev) { // ---- short link domains (LinkSpin): each domain in siteConfig().linkDomains is a small real site ---- function reqHost(req) { return String(req.headers['x-forwarded-host'] || req.headers.host || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, ''); } +function pagesHost() { return String(siteConfig().pagesDomain || '').trim().toLowerCase().replace(/^www\./, '') || null; } +function isPagesHost(req) { const h = pagesHost(); return !!h && reqHost(req) === h; } function isLinkHost(req) { const h = reqHost(req); if (!h) return false; return String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean).includes(h); } function linkSitePage(host, page) { const esc = t => String(t).replace(/&/g, '&').replace(/ { res.writeHead(302, { 'Set-Cookie': auth.sessionCookie(token), Location: t.next || '/ads', 'Cache-Control': 'no-store' }); return res.end(); } } // -- member pages: /p/ 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); + // -- the pages domain: only pages live here. / -> the app; / and /p/ -> the page; everything else 404 + if (isPagesHost(req)) { + if (p === '/') { res.writeHead(302, { Location: 'https://' + SITE_HOST + '/', 'Cache-Control': 'no-store' }); return res.end(); } + if (p === '/robots.txt') { res.writeHead(200, { 'Content-Type': 'text/plain' }); return res.end('User-agent: *\nAllow: /\n'); } + if (p === '/assets/pt.js') return sendFile(res, path.join(PUBLIC_DIR, 'assets', 'pt.js')); + if (!/^\/p\/[a-z0-9-]{3,60}(\/lead)?$/i.test(p) && !/^\/api\/p\//.test(p) && !/^\/[a-z0-9-]{3,60}$/i.test(p)) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); } + } + let pm = /^\/p\/([a-z0-9-]{3,60})$/i.exec(p) || (isPagesHost(req) ? /^\/([a-z0-9-]{3,60})$/i.exec(p) : null); if (pm && (req.method === 'GET' || req.method === 'HEAD')) { const pg = pages.bySlug(pm[1]); const preview = u.searchParams.get('preview') === '1'; @@ -1970,7 +1980,8 @@ const server = http.createServer(async (req, res) => { 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, styles: require('./pagestyle').catalog() }, { 'Cache-Control': 'no-store' }); + const ph = pagesHost(); const pageBase = ph ? 'https://' + ph + '/' : 'https://' + (hosts[0] || SITE_HOST) + '/p/'; + return json(res, 200, { pages: await pages.list(s.email), hosts: ph ? [ph] : (hosts.length ? hosts : [SITE_HOST]), pageBase, types: pages.TYPES, styles: require('./pagestyle').catalog() }, { '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.' });