Compact export toolbar and inline HTML assets
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user