Default the public catalog to colored PDFs
Some checks are pending
offline / test (push) Waiting to run

Render published markdown with pandoc + WeasyPrint (indigo tables,
dark code). Home page links to PDFs with a top-right switch to
Markdown indexes. Serve CONSOLE.pdf from the operator console.
This commit is contained in:
George Lambert 2026-09-11 14:23:19 -04:00
parent cf4ef9e3af
commit 5ad3222def
9 changed files with 957 additions and 182 deletions

View file

@ -108,11 +108,27 @@ export function startControlServer(sup, mon) {
fs.createReadStream(dest).pipe(res);
return;
}
if (req.method === 'GET' && url.pathname.startsWith('/docs/screenshots/')) {
if (req.method === 'GET' && url.pathname.startsWith('/docs/')) {
const dest = path.normalize(path.join(PUBLIC, '..', url.pathname));
const root = path.normalize(path.join(PUBLIC, '..'));
if (!dest.startsWith(root) || !fs.existsSync(dest)) return json(res, 404, { error: 'not found' });
res.writeHead(200, { 'content-type': 'image/png' });
const root = path.normalize(path.join(PUBLIC, '..', 'docs'));
if (
!(dest === root || dest.startsWith(root + path.sep)) ||
!fs.existsSync(dest) ||
!fs.statSync(dest).isFile()
) {
return json(res, 404, { error: 'not found' });
}
const ext = path.extname(dest).toLowerCase();
const types = {
'.png': 'image/png',
'.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg',
'.svg': 'image/svg+xml',
'.pdf': 'application/pdf',
'.md': 'text/markdown; charset=utf-8',
'.html': 'text/html; charset=utf-8',
};
res.writeHead(200, { 'content-type': types[ext] || 'application/octet-stream' });
fs.createReadStream(dest).pipe(res);
return;
}