0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

Update server.js

Initial commit of incorporating `brew.style` into /source and /download pages
This commit is contained in:
Sean Robertson
2021-06-18 11:24:20 +12:00
parent 9d80f21ae7
commit 4638c3e1d9

View File

@@ -113,7 +113,7 @@ app.get('/source/:id', asyncHandler(async (req, res)=>{
const brew = await getBrewFromId(req.params.id, 'share');
const replaceStrings = { '&': '&amp;', '<': '&lt;', '>': '&gt;' };
let text = brew.text;
let text = `\`\`\`css\n${brew.style}\n\`\`\`\n\n${brew.text}`;
for (const replaceStr in replaceStrings) {
text = text.replaceAll(replaceStr, replaceStrings[replaceStr]);
}
@@ -132,8 +132,9 @@ app.get('/download/:id', asyncHandler(async (req, res)=>{
'Cache-Control' : 'no-cache',
'Content-Type' : 'text/plain',
'Content-Disposition' : `attachment; filename="${fileName}.txt"`
});
res.status(200).send(brew.text);
});
let text = `\`\`\`css\n${brew.style}\n\`\`\`\n\n${brew.text}`;
res.status(200).send(text);
}));
//User Page