Pages domain: member pages publish at the root of site.pagesDomain (lookfirst.page), /p/<slug> 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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: '<button class="btn pri" type="button" id="newBtn">+ New page</button>' });
|
||||
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);
|
||||
|
||||
+1
-1
@@ -70,6 +70,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261008c"></script>
|
||||
<script src="/assets/pages-screen.js?v=20261008a"></script>
|
||||
<script src="/assets/pages-screen.js?v=20261008b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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://<pagesDomain>/<slug>); 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(/</g, '<');
|
||||
@@ -866,7 +869,7 @@ const CURTAIN_PAGE = `<!doctype html><html lang="en"><head><meta charset="utf-8"
|
||||
|
||||
function curtained(req, res, u) {
|
||||
if (!CURTAIN) return false;
|
||||
if (isLinkHost(req)) return false; // the short link domains stay public: spin links must redirect and the mini-site must answer while the main site is covered (Marty 2026-10-07: test traffic before launch)
|
||||
if (isLinkHost(req) || isPagesHost(req)) return false; // the short link domains and the pages domain stay public: spin links must redirect and the mini-site must answer while the main site is covered (Marty 2026-10-07: test traffic before launch)
|
||||
if (u.searchParams.get('k') === CURTAIN) {
|
||||
u.searchParams.delete('k');
|
||||
res.writeHead(302, {
|
||||
@@ -941,7 +944,14 @@ const server = http.createServer(async (req, res) => {
|
||||
res.writeHead(302, { 'Set-Cookie': auth.sessionCookie(token), Location: t.next || '/ads', 'Cache-Control': 'no-store' }); return res.end();
|
||||
} }
|
||||
// -- 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);
|
||||
// -- the pages domain: only pages live here. / -> the app; /<slug> and /p/<slug> -> 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.' });
|
||||
|
||||
Reference in New Issue
Block a user