Home: seedling-in-hand video band under the steps (Marty 2026-11-18: stock clip, muted loop, poster, reduced-motion = poster only); video served with byte ranges; assets ?v=20261118a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,8 @@ const TEST_SWITCH = C.staging && !/(^|\.)yourprogrambuilder\.com$/i.test(C.site)
|
||||
|
||||
// ---- http helpers ----
|
||||
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'text/javascript', '.png': 'image/png', '.jpg': 'image/jpeg', '.webp': 'image/webp',
|
||||
'.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml' };
|
||||
'.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml',
|
||||
'.mp4': 'video/mp4', '.webm': 'video/webm' };
|
||||
const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://linkspin.app https://polhunter.com; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; "
|
||||
+ "img-src 'self' data: blob: https:; connect-src 'self' https://linkspin.app https://polhunter.com https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org "
|
||||
+ "https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com; "
|
||||
@@ -67,6 +68,19 @@ function sendFile(res, file, extra, code) {
|
||||
res.end(data);
|
||||
});
|
||||
}
|
||||
// video needs byte ranges (Safari will not play it without them)
|
||||
function sendMedia(req, res, file) {
|
||||
fs.stat(file, (err, st) => {
|
||||
if (err || !st.isFile()) { res.writeHead(404, headers({ 'Content-Type': 'text/plain' })); return res.end('Not found'); }
|
||||
const base = { 'Content-Type': MIME[path.extname(file).toLowerCase()], 'Accept-Ranges': 'bytes', 'Cache-Control': 'public, max-age=86400' };
|
||||
const m = /^bytes=(\d*)-(\d*)$/.exec(req.headers.range || '');
|
||||
if (!m || (!m[1] && !m[2])) { res.writeHead(200, headers(Object.assign(base, { 'Content-Length': st.size }))); return fs.createReadStream(file).pipe(res); }
|
||||
let a = m[1] ? +m[1] : Math.max(0, st.size - +m[2]), b = m[1] && m[2] ? Math.min(+m[2], st.size - 1) : st.size - 1;
|
||||
if (a > b || a >= st.size) { res.writeHead(416, headers({ 'Content-Range': 'bytes */' + st.size })); return res.end(); }
|
||||
res.writeHead(206, headers(Object.assign(base, { 'Content-Range': 'bytes ' + a + '-' + b + '/' + st.size, 'Content-Length': b - a + 1 })));
|
||||
fs.createReadStream(file, { start: a, end: b }).pipe(res);
|
||||
});
|
||||
}
|
||||
function readRaw(req, max) {
|
||||
return new Promise((resolve, reject) => { const ch = []; let n = 0;
|
||||
req.on('data', c => { n += c.length; if (n > max * 8) { req.destroy(); return; } if (n <= max) ch.push(c); });
|
||||
@@ -268,7 +282,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/robots.txt') { res.writeHead(200, headers({ 'Content-Type': 'text/plain; charset=utf-8' })); return res.end(C.staging ? 'User-agent: *\nDisallow: /\n' : 'User-agent: *\nAllow: /\nDisallow: /my\nDisallow: /admin\nDisallow: /api/\nDisallow: /go/\nDisallow: /sso/\n\nSitemap: https://' + C.site + '/sitemap.xml\n'); }
|
||||
if (p.startsWith('/assets/') || p.startsWith('/art/') || p === '/favicon.ico') {
|
||||
const f = path.normalize(path.join(PUB, p === '/favicon.ico' ? '/art/icon-192.png' : p)); if (!f.startsWith(PUB + path.sep)) { res.writeHead(400); return res.end(); }
|
||||
return sendFile(res, f);
|
||||
return /\.(mp4|webm)$/i.test(f) ? sendMedia(req, res, f) : sendFile(res, f);
|
||||
}
|
||||
// click relay: /go/<packet>?v=<verified token>&p=<placement>&r=<member> -> the sponsor-first referral link (LinkSpin tracked when on)
|
||||
const gm = /^\/go\/(\d{1,9})$/.exec(p);
|
||||
|
||||
Reference in New Issue
Block a user