0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 18:48:39 +00:00

Rework HTML Download options to use a DOM snatch and grab

Still requires path manipulation.

Stubs the same for Zipfiles.
This commit is contained in:
David Bolack
2026-02-08 19:48:57 -06:00
parent f16c8b7663
commit 2791c2259b
3 changed files with 32 additions and 113 deletions
+2 -22
View File
@@ -27,9 +27,8 @@ import asyncHandler from 'express-async-handler';
import templateFn from '../client/template.js';
import { model as HomebrewModel } from './homebrew.model.js';
import { DEFAULT_BREW } from './brewDefaults.js';
import { splitTextStyleAndMetadata,
simulateRender } from '../shared/helpers.js';
import { DEFAULT_BREW } from './brewDefaults.js';
import { splitTextStyleAndMetadata } from '../shared/helpers.js';
//==== Middleware Imports ====//
import contentNegotiation from './middleware/content-negotiation.js';
@@ -240,25 +239,6 @@ app.get('/source/:id', asyncHandler(getBrew('share')), (req, res)=>{
res.status(200).send(text);
});
//Export the Brew as HTML
app.get('/export/:mode/:id', asyncHandler(getBrew('admin')), asyncHandler(simulateRender), (req, res)=>{
const id = req.params.id;
const mode = req.params.mode;
const { brew } = req;
sanitizeBrew(brew, 'share');
const prefix = 'HB - ';
let fileName = sanitizeFilename(`${prefix}${brew.title}`).replaceAll(' ', '');
if(!fileName || !fileName.length) { fileName = `${prefix}-Untitled-Brew`; };
// res.set({
// 'Cache-Control' : 'no-cache',
// 'Content-Type' : 'text/plain',
// 'Content-Disposition' : `attachment; filename*=UTF-8''${encodeRFC3986ValueChars(fileName)}.html`
// });
res.status(200).send(brew.html);
});
//Download brew source page
app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{