Compact export toolbar and inline HTML assets

This commit is contained in:
Codex
2026-07-08 06:10:27 +00:00
parent 0c57525807
commit 746fe2a65d
3 changed files with 104 additions and 20 deletions
+23
View File
@@ -14,6 +14,7 @@ import {
deleteAllArtifactRoots,
deleteArtifactsFor,
screenshotPath,
selfContainedHtml,
zipArtifact
} from "./artifacts.js";
@@ -163,6 +164,28 @@ app.get(`${config.basePath}/:slug/download.html`, (req, res) => {
res.download(artifactIndexPath(req.params.slug), `${req.params.slug}.html`);
});
app.get(`${config.basePath}/:slug/download`, async (req, res, next) => {
try {
const row = store.getCaptureBySlug(req.params.slug);
if (!row) {
res.status(404).send("Not found");
return;
}
try {
const html = await selfContainedHtml(req.params.slug);
res.setHeader("Content-Type", "text/html; charset=utf-8");
res.attachment(`${req.params.slug}.html`);
res.send(html);
} catch {
const zipPath = path.join(config.cacheDir, `${req.params.slug}.zip`);
await zipArtifact(req.params.slug, zipPath);
res.download(zipPath, `${req.params.slug}.zip`);
}
} catch (error) {
next(error);
}
});
app.get(`${config.basePath}/:slug/download.zip`, async (req, res, next) => {
try {
const row = store.getCaptureBySlug(req.params.slug);