openvibers/openvibe.surf Commits
The home on phones: the three scenes are chips, the questions a fold (#17)
Changes
@@@ -258,3 +258,56 @@ html[data-ov-motion=reduced] .sf-desk-page[data-sf-desk-open="1"] .sf-desk-statea.sc-scene-go { position: relative; }a.sc-scene-go::after { content: ''; position: absolute; left: 0; right: 0; top: -2px; bottom: -2px; }}++++/* The phone home (2026-10-30, the owner's short-pages rule): the three doors are one sideways row, the scenes are++ chips, one at a time, and the questions are a fold. Everything stays in the page for the crawlers. */++/* Pick (the owner's short-pages rule, 2026-10-30): on a phone the front page's blocks of the same kind are one at a++ time, picked with a row of chips. Radio inputs and :has(), no script: the chips and the one-pane rule live under++ 640 px and only where :has() is understood, so a wider screen, or an older browser, shows every pane and no chips.++ Every pane stays in the page for crawlers. */++.pick-head { display: none; }++.pick-row { display: none; }++@supports selector(:has(*)) { @media (max-width: 640px) {++ .pick-bar { margin-top: 30px; }++ .pick-head { display: block; }++ .pick-head h2 { margin: 0 0 4px; font: 700 clamp(20px, 2.4vw, 28px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); letter-spacing: -.02em; }++ .pick-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; overscroll-behavior-x: contain; }++ .pick-row::-webkit-scrollbar { display: none; }++ .pick-row input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }++ .pick-row label { display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border, #1f2d47); color: var(--text-secondary, #96a7c2); font-size: .9rem; font-weight: 650; white-space: nowrap; cursor: pointer; }++ .pick-row input:checked + label { color: var(--text-primary, #e6edf7); border-color: var(--accent, #3b82f6); background: color-mix(in srgb, var(--accent, #3b82f6) 12%, transparent); }++ .pick-row input:focus-visible + label { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }++ .pick .pick-pane { display: none; }++ /* A link that points at a pane opens that pane on a phone too. */++ .pick .pick-pane:target { display: block !important; }++ .pick:has(.pick-pane:target) .pick-pane:not(:target) { display: none !important; }++ /* The chip names the pane, so the pane's own heading gives way to it; the link to more stays. */++ .pick .pick-pane > h2, .pick .pick-pane > h3 { display: none; }++} }++++/* The fold (the owner's short-pages rule): closed on a phone, and where there is room it looks like the section it++ replaces: a heading and its content, with no card around it. */++.hm-fold-block { margin-top: 32px; }++.hm-fold-block > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; }++.hm-fold-block > summary::-webkit-details-marker { display: none; }++.hm-fold-block > summary h2 { margin: 0; font: 700 clamp(19px, 2.2vw, 26px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); }++.hm-fold-block > summary span { color: var(--text-muted, #7386a3); font-weight: 600; font-size: .86rem; white-space: nowrap; }++.hm-fold-block > summary:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }++@media (min-width: 641px) {++ .hm-fold-block { border: 0; background: none; border-radius: 0; margin: 56px auto 0; padding: 0; }++ .hm-fold-block > summary { display: block; min-height: 0; }++ .hm-fold-block > summary h2 { margin: 0 0 6px; font: 700 clamp(22px, 2.6vw, 30px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); }++ .hm-fold-block > summary span { display: none; }++ .hm-fold-block .hm-sec, .hm-fold-block .sc-sec { margin: 0; max-width: none; padding: 0; }++}++@media (max-width: 640px) { .hm-fold-block { margin-top: 24px; } .hm-fold-block > summary h2 { font-size: 1.05rem; } }++/* A fold that sits inside the section it replaces adds no space of its own. */++:where(.sc-sec, .cm-sec, .hm-sec, .section) > .hm-fold-block { margin: 0; }++/* The fold holds the questions, so their list gets the room the section gave it. */++.hm-fold-block .sc-faq { margin: 0; padding: 0 16px 16px; }++/* The three doors on a phone: one sideways row, every door still in the page. */++@media (max-width: 599px) {++ .sf-tiles { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; gap: 10px; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; scrollbar-width: none; }++ .sf-tiles::-webkit-scrollbar { display: none; }++ .sf-tiles > li { flex: 0 0 72%; min-width: 0; scroll-snap-align: start; }++}@@@ -38,7 +38,7 @@ const baseUrl = () => BASE;const canonical = (p) => `${BASE}${p || '/'}`;/** The page around a body: the shared shell with the room's stylesheets and behaviour. */--function layout({ title, description, canonical, path, robots = 'index, follow', body, active = '/', scripts = ['js/surf.js'], jsonLd = [] } = {}) {++function layout({ title, description, canonical, path, robots = 'index, follow', body, active = '/', scripts = ['js/surf.js'], jsonLd = [], inlineStyles = [] } = {}) {const pathNow = path || active || '/';canonical = canonical || (path ? `${BASE}${path}` : undefined);const navbar = {@@@ -76,6 +76,7 @@ function layout({ title, description, canonical, path, robots = 'index, follow',<script src="${esc(ovServe.url('kit-web.js'))}" defer></script><script src="${esc(ovServe.url('motion.js'))}" defer></script>${(scripts || []).map((rel) => `<script src="${esc(asset(rel))}" defer></script>`).join('\n')}++${(inlineStyles || []).map((css) => `<style>${css}</style>`).join('\n')}<meta name="ov-boost" content="surf@${esc(RELEASE)}">`,body: `<a class="skip" href="#main">Skip to content</a><div id="navbar-mount"></div>@@@ -14,6 +14,7 @@*/const layoutLib = require('../render/layout');const kit = require('openvibe-shared/kit');++const S = require('./short');const sc = require('openvibe-shared/showcase');const rooms = require('openvibe-shared/rooms');@@@ -83,8 +84,14 @@ function home() {] },});const at = room.indexOf('<section class="sc-room-scenes"');-- const body = at < 0 ? room.replace(/<\/div>$/, `${tiles}</div>`) : room.slice(0, at) + tiles + room.slice(at);-- return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/' });++ let body = at < 0 ? room.replace(/<\/div>$/, `${tiles}</div>`) : room.slice(0, at) + tiles + room.slice(at);++ // The home on a phone (the owner's short-pages rule, 2026-10-30): the three scenes are chips, one at a time, and++ // the questions are a fold. Both stay in the page for the crawlers.++ body = S.pickScenes(body, { key: 'scenes', label: 'What you can do', head: 'What you can do', labels: ['Ride maps', 'Surf the web', 'Watch'] });++ body = S.foldSection(body, 'id="sc-questions"', 'questions-fold');++ // The rule that shows the picked scene: one per scene, so the CSS is written for this page.++ const rules = `@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('scenes', ['scene-0', 'scene-1', 'scene-2'])}}}`;++ return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/', inlineStyles: [rules] });}function mapCard(m) {nnew file mode 100644@@@ -0,0 +1,104 @@++'use strict';++/**++ * The home on a phone (the owner's short-pages rule, 2026-10-30): one or two screens, app-like.++ *++ * pickBlock() several blocks of the same kind, one at a time on a phone, picked with a row of chips. Radio++ * inputs and :has(), no script: every block stays in the page for crawlers, and a wider screen (or a++ * browser without :has()) shows them all and no chips.++ * foldBlock() a part a reader rarely needs, closed on a phone and open where there is room. The page's own markup++ * keeps it open, so a browser without the script shows it as before; the script closes it on a narrow++ * screen and remembers the reader's choice.++ *++ * The CSS for both lives in the site's own stylesheet; the rule that shows the picked block is written for the++ * page, because there is one per block.++ */++const esc = (s) => String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');++++/**++ * A pick block. The panes are the page's own blocks; each one keeps its heading on a wide screen, and on a phone the++ * heading gives way to the chip that names it.++ *++ * pickBlock({ key, label, head, panes }) head: the heading of the block, or '' when the block already has one.++ * panes: [{ id, label, html }]++ */++function pickBlock({ key, label, head = '', panes, bodyClass = '' }) {++ // A pane with nothing to show is left out, so the chips and the rules that show them match the page.++ panes = (panes || []).filter((p) => p.html);++ if (!panes.length) return '';++ const chips = panes.map((p, i) => `<input type="radio" name="pick-${esc(key)}" id="pk-${esc(key)}-${esc(p.id)}" value="${esc(p.id)}"${i === 0 ? ' checked' : ''}><label for="pk-${esc(key)}-${esc(p.id)}">${esc(p.label)}</label>`).join('');++ // The pane carries the id the page already links to (an anchor in the hero, for instance), so a link to it still++ // opens that pane on a phone (the CSS shows the pane a link points at).++ const body = panes.map((p) => `<div class="pick-pane" id="${esc(p.id)}">${p.html}</div>`).join('');++ const bar = `${head ? `<div class="pick-head"><h2>${esc(head)}</h2></div>` : ''}<div class="pick-row" role="radiogroup" aria-label="${esc(label)}">${chips}</div>`;++ return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar">${bar}</div><div class="pick-body${bodyClass ? ' ' + esc(bodyClass) : ''}">${body}</div></div>`;++}++++/** The rule that shows the picked block of a pick block: one per block, so the CSS is written for the page. */++function pickRule(key, id) {++ return `.pick:has(#pk-${key}-${id}:checked) #${id}{display:block}`;++}++++/** The rules for every block of a pick block, in the order they appear. */++function pickRules(key, ids) {++ return ids.map((id) => pickRule(key, id)).join('');++}++++/**++ * A fold. The head is the heading the block had; the html is what it holds.++ *++ * foldBlock({ id, head, html })++ */++function foldBlock({ id, head, html }) {++ return `<details class="hm-fold hm-fold-block" id="${esc(id)}" open><summary>${head}<span>tap to open</span></summary>${html}</details>${foldScript(id)}`;++}++++/** The script a fold carries: closed on a phone unless the reader opened it before, and it remembers that. */++function foldScript(id) {++ return `<script>(function(){var d=document.getElementById(${JSON.stringify(id)});if(!d)return;var k='ov_fold_'+${JSON.stringify(id)};var s=null;try{s=localStorage.getItem(k)}catch(e){}if(s==='open'){d.open=true;return}if(s==='closed'){d.open=false;return}var t=0;if(window.matchMedia&&window.matchMedia('(max-width:640px)').matches){t=Date.now();d.open=false}d.addEventListener('toggle',function(){if(Date.now()-t<300)return;try{localStorage.setItem(k,d.open?'open':'closed')}catch(e){}})})();</script>`;++}++++/**++ * A section of the page's own markup as a fold. The section stays where it was; its own heading becomes the fold's++ * heading, and the fold is closed on a phone (the script) and open where there is room.++ *++ * foldSection(html, needle, id) needle: a mark of the part to fold (a class, for instance)++ */++function foldSection(html, needle, id) {++ const at = html.indexOf(needle);++ if (at < 0) return html;++ const start = html.lastIndexOf('<section', at);++ const close = html.indexOf('</section>', at);++ if (start < 0 || close < 0) return html;++ const openEnd = html.indexOf('>', start) + 1;++ const openTag = html.slice(start, openEnd);++ let inner = html.slice(openEnd, close);++ const h2 = /<h2[^>]*>[\s\S]*?<\/h2>/.exec(inner);++ if (!h2) return html;++ const head = h2[0];++ inner = inner.slice(h2.index + head.length);++ // The lede under the heading goes with it: the fold's heading says enough on a phone.++ const lede = /<p class="sc-lede"[^>]*>[\s\S]*?<\/p>/.exec(inner);++ if (lede) inner = inner.slice(0, lede.index) + inner.slice(lede.index + lede[0].length);++ const fold = `<details class="hm-fold hm-fold-block" id="${esc(id)}" open><summary>${head}<span>tap to open</span></summary>${inner.trim()}</details>${foldScript(id)}`;++ return html.slice(0, start) + openTag + fold + html.slice(close);++}++++/**++ * The room's scenes as a pick block: the scenes become the panes and the chips pick one of them on a phone. On a wide++ * screen they stay where they were, one under the other.++ *++ * pickScenes(html, { key, label, head, labels })++ */++function pickScenes(html, { key, label, head = '', labels = [] }) {++ const start = html.indexOf('<section class="sc-room-scenes"');++ if (start < 0) return html;++ const close = html.indexOf('</section>', start);++ if (close < 0) return html;++ const articles = html.slice(start, close).match(/<article class="sc-scene[\s\S]*?<\/article>/g) || [];++ if (articles.length < 2) return html;++ const panes = articles.map((a, i) => ({ id: `scene-${i}`, label: labels[i] || `Scene ${i + 1}`, html: a }));++ const block = pickBlock({ key, label, head, panes, bodyClass: 'sc-room-scenes' });++ return html.slice(0, start) + block + html.slice(close + '</section>'.length);++}++++module.exports = { pickBlock, pickRule, pickRules, foldBlock, foldScript, foldSection, pickScenes };nnew file mode 100644@@@ -0,0 +1,53 @@++'use strict';++/**++ * The home on a phone (the owner's short-pages rule, 2026-10-30): the three scenes are a pick block, a row of chips++ * picks one of them, and the questions are a fold. Radio inputs and :has(), no script for the chips; every scene stays++ * in the page for crawlers; a wider screen shows them all and no chips.++ */++const assert = require('assert');++const fs = require('fs');++const path = require('path');++const { boot, check, done } = require('./helpers/boot');++++(async () => {++ const t = await boot();++ try {++ await check('the scenes are chips: one per scene, the first picked, every scene in the page', async () => {++ const r = await t.get('/');++ assert.strictEqual(r.status, 200, r.text);++ const page = r.text;++ assert.ok(page.includes('<div class="pick" id="pick-scenes">'), 'the pick block is on the home');++ const block = page.slice(page.indexOf('<div class="pick" id="pick-scenes">'));++ const chips = [...block.matchAll(/<input type="radio" name="pick-scenes" id="pk-scenes-(scene-\d+)" value="\1"( checked)?><label for="pk-scenes-\1">([^<]+)<\/label>/g)];++ assert.deepStrictEqual(chips.map((m) => m[1]), ['scene-0', 'scene-1', 'scene-2'], 'a chip per scene');++ assert.deepStrictEqual(chips.filter((m) => m[2]).map((m) => m[1]), ['scene-0'], 'the first scene is picked');++ const panes = [...block.matchAll(/<div class="pick-pane" id="scene-(\d+)">/g)].map((m) => m[1]);++ assert.deepStrictEqual(panes, ['0', '1', '2'], 'every scene is in the page, one per chip');++ // Nothing was removed: the scenes and the doors are still there.++ for (const title of ['Press play, you are on the ramp', 'Surf the web with Vibe', 'Lean back and surf what is on', 'Ride', 'Web', 'Watch']) {++ assert.ok(page.includes(title), `${title} is on the page`);++ }++ });++++ await check('the CSS guard: the chips are hidden and every scene shows until 640 px and where :has() is understood', async () => {++ const r = await t.get('/');++ assert.match(r.text, /<style>@supports selector\(:has\(\*\)\)\{@media \(max-width:640px\)\{\.pick:has\(#pk-scenes-scene-0:checked\) #scene-0\{display:block\}/, 'the rule that shows the picked scene');++ const css = fs.readFileSync(path.join(__dirname, '..', 'public', 'css', 'surf.css'), 'utf8');++ assert.match(css, /\.pick-row \{ display: none; \}/, 'the chips are hidden by default');++ assert.match(css, /@supports selector\(:has\(\*\)\) \{ @media \(max-width: 640px\) \{/, 'the phone rules are under :has() and 640 px');++ assert.match(css, /\.pick-row label \{[^}]*min-height: 44px/, 'a chip is a 44 px target');++ assert.match(css, /\.pick \.pick-pane \{ display: none; \}/, 'the scenes are hidden on a phone');++ assert.match(css, /\.sf-tiles \{ display: flex; overflow-x: auto;/, 'the three doors are one sideways row');++ });++++ await check('the questions are a fold, open in the page and closed on a phone', async () => {++ const r = await t.get('/');++ assert.ok(r.text.includes('<details class="hm-fold hm-fold-block" id="questions-fold" open>'), 'the questions are a fold, open in the page');++ assert.ok(r.text.includes('document.getElementById("questions-fold")'), 'the fold has the script that closes it on a phone');++ assert.match(r.text, /Do I need to install anything to ride\?/);++ });++ } finally {++ await t.close();++ }++ done();++})().catch((e) => { console.error(e); process.exit(1); });
@@ -258,3 +258,56 @@ html[data-ov-motion=reduced] .sf-desk-page[data-sf-desk-open="1"] .sf-desk-state
@@ -258,3 +258,56 @@ html[data-ov-motion=reduced] .sf-desk-page[data-sf-desk-open="1"] .sf-desk-state
a.sc-scene-go { position: relative; }
a.sc-scene-go { position: relative; }
a.sc-scene-go::after { content: ''; position: absolute; left: 0; right: 0; top: -2px; bottom: -2px; }
a.sc-scene-go::after { content: ''; position: absolute; left: 0; right: 0; top: -2px; bottom: -2px; }
}
}
+
+/* The phone home (2026-10-30, the owner's short-pages rule): the three doors are one sideways row, the scenes are
+ chips, one at a time, and the questions are a fold. Everything stays in the page for the crawlers. */
+/* Pick (the owner's short-pages rule, 2026-10-30): on a phone the front page's blocks of the same kind are one at a
+ time, picked with a row of chips. Radio inputs and :has(), no script: the chips and the one-pane rule live under
+ 640 px and only where :has() is understood, so a wider screen, or an older browser, shows every pane and no chips.
+ Every pane stays in the page for crawlers. */
+.pick-head { display: none; }
+.pick-row { display: none; }
+@supports selector(:has(*)) { @media (max-width: 640px) {
+ .pick-bar { margin-top: 30px; }
+ .pick-head { display: block; }
+ .pick-head h2 { margin: 0 0 4px; font: 700 clamp(20px, 2.4vw, 28px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); letter-spacing: -.02em; }
+ .pick-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; overscroll-behavior-x: contain; }
+ .pick-row::-webkit-scrollbar { display: none; }
+ .pick-row input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
+ .pick-row label { display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border, #1f2d47); color: var(--text-secondary, #96a7c2); font-size: .9rem; font-weight: 650; white-space: nowrap; cursor: pointer; }
+ .pick-row input:checked + label { color: var(--text-primary, #e6edf7); border-color: var(--accent, #3b82f6); background: color-mix(in srgb, var(--accent, #3b82f6) 12%, transparent); }
+ .pick-row input:focus-visible + label { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
+ .pick .pick-pane { display: none; }
+ /* A link that points at a pane opens that pane on a phone too. */
+ .pick .pick-pane:target { display: block !important; }
+ .pick:has(.pick-pane:target) .pick-pane:not(:target) { display: none !important; }
+ /* The chip names the pane, so the pane's own heading gives way to it; the link to more stays. */
+ .pick .pick-pane > h2, .pick .pick-pane > h3 { display: none; }
+} }
+
+/* The fold (the owner's short-pages rule): closed on a phone, and where there is room it looks like the section it
+ replaces: a heading and its content, with no card around it. */
+.hm-fold-block { margin-top: 32px; }
+.hm-fold-block > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; }
+.hm-fold-block > summary::-webkit-details-marker { display: none; }
+.hm-fold-block > summary h2 { margin: 0; font: 700 clamp(19px, 2.2vw, 26px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); }
+.hm-fold-block > summary span { color: var(--text-muted, #7386a3); font-weight: 600; font-size: .86rem; white-space: nowrap; }
+.hm-fold-block > summary:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
+@media (min-width: 641px) {
+ .hm-fold-block { border: 0; background: none; border-radius: 0; margin: 56px auto 0; padding: 0; }
+ .hm-fold-block > summary { display: block; min-height: 0; }
+ .hm-fold-block > summary h2 { margin: 0 0 6px; font: 700 clamp(22px, 2.6vw, 30px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); }
+ .hm-fold-block > summary span { display: none; }
+ .hm-fold-block .hm-sec, .hm-fold-block .sc-sec { margin: 0; max-width: none; padding: 0; }
+}
+@media (max-width: 640px) { .hm-fold-block { margin-top: 24px; } .hm-fold-block > summary h2 { font-size: 1.05rem; } }
+/* A fold that sits inside the section it replaces adds no space of its own. */
+:where(.sc-sec, .cm-sec, .hm-sec, .section) > .hm-fold-block { margin: 0; }
+/* The fold holds the questions, so their list gets the room the section gave it. */
+.hm-fold-block .sc-faq { margin: 0; padding: 0 16px 16px; }
+/* The three doors on a phone: one sideways row, every door still in the page. */
+@media (max-width: 599px) {
+ .sf-tiles { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; gap: 10px; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; scrollbar-width: none; }
+ .sf-tiles::-webkit-scrollbar { display: none; }
+ .sf-tiles > li { flex: 0 0 72%; min-width: 0; scroll-snap-align: start; }
+}
@@ -38,7 +38,7 @@ const baseUrl = () => BASE;
@@ -38,7 +38,7 @@ const baseUrl = () => BASE;
const canonical = (p) => `${BASE}${p || '/'}`;
const canonical = (p) => `${BASE}${p || '/'}`;
/** The page around a body: the shared shell with the room's stylesheets and behaviour. */
/** The page around a body: the shared shell with the room's stylesheets and behaviour. */
-function layout({ title, description, canonical, path, robots = 'index, follow', body, active = '/', scripts = ['js/surf.js'], jsonLd = [] } = {}) {
+function layout({ title, description, canonical, path, robots = 'index, follow', body, active = '/', scripts = ['js/surf.js'], jsonLd = [], inlineStyles = [] } = {}) {
const pathNow = path || active || '/';
const pathNow = path || active || '/';
canonical = canonical || (path ? `${BASE}${path}` : undefined);
canonical = canonical || (path ? `${BASE}${path}` : undefined);
const navbar = {
const navbar = {
@@ -76,6 +76,7 @@ function layout({ title, description, canonical, path, robots = 'index, follow',
@@ -76,6 +76,7 @@ function layout({ title, description, canonical, path, robots = 'index, follow',
<script src="${esc(ovServe.url('kit-web.js'))}" defer></script>
<script src="${esc(ovServe.url('kit-web.js'))}" defer></script>
<script src="${esc(ovServe.url('motion.js'))}" defer></script>
<script src="${esc(ovServe.url('motion.js'))}" defer></script>
${(scripts || []).map((rel) => `<script src="${esc(asset(rel))}" defer></script>`).join('\n')}
${(scripts || []).map((rel) => `<script src="${esc(asset(rel))}" defer></script>`).join('\n')}
+${(inlineStyles || []).map((css) => `<style>${css}</style>`).join('\n')}
<meta name="ov-boost" content="surf@${esc(RELEASE)}">`,
<meta name="ov-boost" content="surf@${esc(RELEASE)}">`,
body: `<a class="skip" href="#main">Skip to content</a>
body: `<a class="skip" href="#main">Skip to content</a>
<div id="navbar-mount"></div>
<div id="navbar-mount"></div>
@@ -14,6 +14,7 @@
@@ -14,6 +14,7 @@
*/
*/
const layoutLib = require('../render/layout');
const layoutLib = require('../render/layout');
const kit = require('openvibe-shared/kit');
const kit = require('openvibe-shared/kit');
+const S = require('./short');
const sc = require('openvibe-shared/showcase');
const sc = require('openvibe-shared/showcase');
const rooms = require('openvibe-shared/rooms');
const rooms = require('openvibe-shared/rooms');
@@ -83,8 +84,14 @@ function home() {
@@ -83,8 +84,14 @@ function home() {
] },
] },
});
});
const at = room.indexOf('<section class="sc-room-scenes"');
const at = room.indexOf('<section class="sc-room-scenes"');
- const body = at < 0 ? room.replace(/<\/div>$/, `${tiles}</div>`) : room.slice(0, at) + tiles + room.slice(at);
- return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/' });
+ let body = at < 0 ? room.replace(/<\/div>$/, `${tiles}</div>`) : room.slice(0, at) + tiles + room.slice(at);
+ // The home on a phone (the owner's short-pages rule, 2026-10-30): the three scenes are chips, one at a time, and
+ // the questions are a fold. Both stay in the page for the crawlers.
+ body = S.pickScenes(body, { key: 'scenes', label: 'What you can do', head: 'What you can do', labels: ['Ride maps', 'Surf the web', 'Watch'] });
+ body = S.foldSection(body, 'id="sc-questions"', 'questions-fold');
+ // The rule that shows the picked scene: one per scene, so the CSS is written for this page.
+ const rules = `@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('scenes', ['scene-0', 'scene-1', 'scene-2'])}}}`;
+ return layout({ title: null, path: '/', body: `<div class="sf-wrap">${body}</div>`, active: '/', inlineStyles: [rules] });
}
}
function mapCard(m) {
function mapCard(m) {
new file mode 100644
new file mode 100644
@@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
+'use strict';
+/**
+ * The home on a phone (the owner's short-pages rule, 2026-10-30): one or two screens, app-like.
+ *
+ * pickBlock() several blocks of the same kind, one at a time on a phone, picked with a row of chips. Radio
+ * inputs and :has(), no script: every block stays in the page for crawlers, and a wider screen (or a
+ * browser without :has()) shows them all and no chips.
+ * foldBlock() a part a reader rarely needs, closed on a phone and open where there is room. The page's own markup
+ * keeps it open, so a browser without the script shows it as before; the script closes it on a narrow
+ * screen and remembers the reader's choice.
+ *
+ * The CSS for both lives in the site's own stylesheet; the rule that shows the picked block is written for the
+ * page, because there is one per block.
+ */
+const esc = (s) => String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
+
+/**
+ * A pick block. The panes are the page's own blocks; each one keeps its heading on a wide screen, and on a phone the
+ * heading gives way to the chip that names it.
+ *
+ * pickBlock({ key, label, head, panes }) head: the heading of the block, or '' when the block already has one.
+ * panes: [{ id, label, html }]
+ */
+function pickBlock({ key, label, head = '', panes, bodyClass = '' }) {
+ // A pane with nothing to show is left out, so the chips and the rules that show them match the page.
+ panes = (panes || []).filter((p) => p.html);
+ if (!panes.length) return '';
+ const chips = panes.map((p, i) => `<input type="radio" name="pick-${esc(key)}" id="pk-${esc(key)}-${esc(p.id)}" value="${esc(p.id)}"${i === 0 ? ' checked' : ''}><label for="pk-${esc(key)}-${esc(p.id)}">${esc(p.label)}</label>`).join('');
+ // The pane carries the id the page already links to (an anchor in the hero, for instance), so a link to it still
+ // opens that pane on a phone (the CSS shows the pane a link points at).
+ const body = panes.map((p) => `<div class="pick-pane" id="${esc(p.id)}">${p.html}</div>`).join('');
+ const bar = `${head ? `<div class="pick-head"><h2>${esc(head)}</h2></div>` : ''}<div class="pick-row" role="radiogroup" aria-label="${esc(label)}">${chips}</div>`;
+ return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar">${bar}</div><div class="pick-body${bodyClass ? ' ' + esc(bodyClass) : ''}">${body}</div></div>`;
+}
+
+/** The rule that shows the picked block of a pick block: one per block, so the CSS is written for the page. */
+function pickRule(key, id) {
+ return `.pick:has(#pk-${key}-${id}:checked) #${id}{display:block}`;
+}
+
+/** The rules for every block of a pick block, in the order they appear. */
+function pickRules(key, ids) {
+ return ids.map((id) => pickRule(key, id)).join('');
+}
+
+/**
+ * A fold. The head is the heading the block had; the html is what it holds.
+ *
+ * foldBlock({ id, head, html })
+ */
+function foldBlock({ id, head, html }) {
+ return `<details class="hm-fold hm-fold-block" id="${esc(id)}" open><summary>${head}<span>tap to open</span></summary>${html}</details>${foldScript(id)}`;
+}
+
+/** The script a fold carries: closed on a phone unless the reader opened it before, and it remembers that. */
+function foldScript(id) {
+ return `<script>(function(){var d=document.getElementById(${JSON.stringify(id)});if(!d)return;var k='ov_fold_'+${JSON.stringify(id)};var s=null;try{s=localStorage.getItem(k)}catch(e){}if(s==='open'){d.open=true;return}if(s==='closed'){d.open=false;return}var t=0;if(window.matchMedia&&window.matchMedia('(max-width:640px)').matches){t=Date.now();d.open=false}d.addEventListener('toggle',function(){if(Date.now()-t<300)return;try{localStorage.setItem(k,d.open?'open':'closed')}catch(e){}})})();</script>`;
+}
+
+/**
+ * A section of the page's own markup as a fold. The section stays where it was; its own heading becomes the fold's
+ * heading, and the fold is closed on a phone (the script) and open where there is room.
+ *
+ * foldSection(html, needle, id) needle: a mark of the part to fold (a class, for instance)
+ */
+function foldSection(html, needle, id) {
+ const at = html.indexOf(needle);
+ if (at < 0) return html;
+ const start = html.lastIndexOf('<section', at);
+ const close = html.indexOf('</section>', at);
+ if (start < 0 || close < 0) return html;
+ const openEnd = html.indexOf('>', start) + 1;
+ const openTag = html.slice(start, openEnd);
+ let inner = html.slice(openEnd, close);
+ const h2 = /<h2[^>]*>[\s\S]*?<\/h2>/.exec(inner);
+ if (!h2) return html;
+ const head = h2[0];
+ inner = inner.slice(h2.index + head.length);
+ // The lede under the heading goes with it: the fold's heading says enough on a phone.
+ const lede = /<p class="sc-lede"[^>]*>[\s\S]*?<\/p>/.exec(inner);
+ if (lede) inner = inner.slice(0, lede.index) + inner.slice(lede.index + lede[0].length);
+ const fold = `<details class="hm-fold hm-fold-block" id="${esc(id)}" open><summary>${head}<span>tap to open</span></summary>${inner.trim()}</details>${foldScript(id)}`;
+ return html.slice(0, start) + openTag + fold + html.slice(close);
+}
+
+/**
+ * The room's scenes as a pick block: the scenes become the panes and the chips pick one of them on a phone. On a wide
+ * screen they stay where they were, one under the other.
+ *
+ * pickScenes(html, { key, label, head, labels })
+ */
+function pickScenes(html, { key, label, head = '', labels = [] }) {
+ const start = html.indexOf('<section class="sc-room-scenes"');
+ if (start < 0) return html;
+ const close = html.indexOf('</section>', start);
+ if (close < 0) return html;
+ const articles = html.slice(start, close).match(/<article class="sc-scene[\s\S]*?<\/article>/g) || [];
+ if (articles.length < 2) return html;
+ const panes = articles.map((a, i) => ({ id: `scene-${i}`, label: labels[i] || `Scene ${i + 1}`, html: a }));
+ const block = pickBlock({ key, label, head, panes, bodyClass: 'sc-room-scenes' });
+ return html.slice(0, start) + block + html.slice(close + '</section>'.length);
+}
+
+module.exports = { pickBlock, pickRule, pickRules, foldBlock, foldScript, foldSection, pickScenes };
new file mode 100644
new file mode 100644
@@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
+'use strict';
+/**
+ * The home on a phone (the owner's short-pages rule, 2026-10-30): the three scenes are a pick block, a row of chips
+ * picks one of them, and the questions are a fold. Radio inputs and :has(), no script for the chips; every scene stays
+ * in the page for crawlers; a wider screen shows them all and no chips.
+ */
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+const { boot, check, done } = require('./helpers/boot');
+
+(async () => {
+ const t = await boot();
+ try {
+ await check('the scenes are chips: one per scene, the first picked, every scene in the page', async () => {
+ const r = await t.get('/');
+ assert.strictEqual(r.status, 200, r.text);
+ const page = r.text;
+ assert.ok(page.includes('<div class="pick" id="pick-scenes">'), 'the pick block is on the home');
+ const block = page.slice(page.indexOf('<div class="pick" id="pick-scenes">'));
+ const chips = [...block.matchAll(/<input type="radio" name="pick-scenes" id="pk-scenes-(scene-\d+)" value="\1"( checked)?><label for="pk-scenes-\1">([^<]+)<\/label>/g)];
+ assert.deepStrictEqual(chips.map((m) => m[1]), ['scene-0', 'scene-1', 'scene-2'], 'a chip per scene');
+ assert.deepStrictEqual(chips.filter((m) => m[2]).map((m) => m[1]), ['scene-0'], 'the first scene is picked');
+ const panes = [...block.matchAll(/<div class="pick-pane" id="scene-(\d+)">/g)].map((m) => m[1]);
+ assert.deepStrictEqual(panes, ['0', '1', '2'], 'every scene is in the page, one per chip');
+ // Nothing was removed: the scenes and the doors are still there.
+ for (const title of ['Press play, you are on the ramp', 'Surf the web with Vibe', 'Lean back and surf what is on', 'Ride', 'Web', 'Watch']) {
+ assert.ok(page.includes(title), `${title} is on the page`);
+ }
+ });
+
+ await check('the CSS guard: the chips are hidden and every scene shows until 640 px and where :has() is understood', async () => {
+ const r = await t.get('/');
+ assert.match(r.text, /<style>@supports selector\(:has\(\*\)\)\{@media \(max-width:640px\)\{\.pick:has\(#pk-scenes-scene-0:checked\) #scene-0\{display:block\}/, 'the rule that shows the picked scene');
+ const css = fs.readFileSync(path.join(__dirname, '..', 'public', 'css', 'surf.css'), 'utf8');
+ assert.match(css, /\.pick-row \{ display: none; \}/, 'the chips are hidden by default');
+ assert.match(css, /@supports selector\(:has\(\*\)\) \{ @media \(max-width: 640px\) \{/, 'the phone rules are under :has() and 640 px');
+ assert.match(css, /\.pick-row label \{[^}]*min-height: 44px/, 'a chip is a 44 px target');
+ assert.match(css, /\.pick \.pick-pane \{ display: none; \}/, 'the scenes are hidden on a phone');
+ assert.match(css, /\.sf-tiles \{ display: flex; overflow-x: auto;/, 'the three doors are one sideways row');
+ });
+
+ await check('the questions are a fold, open in the page and closed on a phone', async () => {
+ const r = await t.get('/');
+ assert.ok(r.text.includes('<details class="hm-fold hm-fold-block" id="questions-fold" open>'), 'the questions are a fold, open in the page');
+ assert.ok(r.text.includes('document.getElementById("questions-fold")'), 'the fold has the script that closes it on a phone');
+ assert.match(r.text, /Do I need to install anything to ride\?/);
+ });
+ } finally {
+ await t.close();
+ }
+ done();
+})().catch((e) => { console.error(e); process.exit(1); });