Tutorial video: 2-minute narrated walkthrough on /how (Watch how it works) + 'Watch the 2-minute walkthrough' link under the home hero buttons; server sends .mp4/.webm with byte ranges (sendMedia); chatbot fact; vbb.css?v=9 (Marty 2026-11-18: tutorial explainer videos for each rebuilt site)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-18 08:21:06 -06:00
parent 5d34997287
commit f3aabd75aa
22 changed files with 42 additions and 19 deletions
+15 -1
View File
@@ -46,7 +46,7 @@ const hash = s => crypto.createHmac('sha256', SECRET).update(s).digest('hex').sl
// ---- http helpers ----
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'text/javascript', '.png': 'image/png', '.jpg': 'image/jpeg',
'.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; "
@@ -61,6 +61,19 @@ function sendFile(res, file, extra) {
res.end(data);
});
}
// video needs byte ranges (Safari will not play it without them); tutorial videos 2026-11-18
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); });
@@ -266,6 +279,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('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(); }
if (/\.(mp4|webm)$/i.test(f)) return sendMedia(req, res, f);
return sendFile(res, f);
}
if (p.startsWith('/u/')) {