openvibers/openrestream Commits

Answer /index.md and /updates.md, the Markdown twins llms.txt links (#241)

OP OpenVibers committed 4 days ago · b9955b3313 · 2 files, +18 −0

The twin renderer calls the UI router for / and /updates, whose page
helper calls res.vary("Cookie"); the capture response it runs against
did not implement vary(), so the render threw and both twins answered
404. Implement it and test both twins for text/markdown and the page's
own heading.

Changes

ddiff --git a/server/agent-pages.js b/server/agent-pages.js
iindex dff1436..e6a93af 100644
---- a/server/agent-pages.js
++++ b/server/agent-pages.js
@@@ -33,6 +33,9 @@ function captureResponse() {
getHeader(name) { return this.headers[String(name)]; },
get(name) { return this.headers[String(name)]; },
removeHeader(name) { delete this.headers[String(name)]; },
++ // The page's cache policy varies on Cookie (server/ui/routes.js page()); a twin is rendered from the same
++ // page code, so the capture has to answer it.
++ vary() { return this; },
type(value) { this.headers['Content-Type'] = value === 'html' ? 'text/html; charset=utf-8' : String(value); return this; },
location(url) { this.headers.Location = url; return this; },
send(body) { this.body = body; this.headersSent = true; return this; },
ddiff --git a/test/discovery.test.js b/test/discovery.test.js
iindex 77eb28e..3083b4b 100644
---- a/test/discovery.test.js
++++ b/test/discovery.test.js
@@@ -88,6 +88,21 @@ t('llms-full.txt (SEO-33): the site in full, from the same descriptor as llms.tx
}
});
++t('the twins llms.txt links answer Markdown, headed like their pages', async () => {
++ const api = await bootApi({ env: { BASE_URL: 'https://openre.stream' } });
++ try {
++ for (const [path, heading] of [['/index.md', /# Go live once\.\s+Stream everywhere\./], ['/updates.md', /# What shipped on OpenRestream/]]) {
++ const r = await request(api.base, 'GET', path, { headers: { Accept: 'text/html' } });
++ assert.strictEqual(r.status, 200, `${path} answers 200`);
++ assert.match(r.headers.get('content-type'), /^text\/markdown/, `${path} is Markdown`);
++ assert.ok(r.text.startsWith('---\ntitle:'), `${path} carries the page title`);
++ assert.match(r.text, heading, `${path} names the page heading`);
++ }
++ } finally {
++ await api.close();
++ }
++});
++
t('the front page leads with open restreaming, links to Live for browser go-live, and says what runs here', async () => {
const api = await bootApi({ env: { BASE_URL: 'https://openre.stream' } });
try {