0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-07 01:12:44 +00:00

Shift functionality to new file in attempt to reduce code duplication in server.js

This commit is contained in:
G.Ambatte
2021-01-17 22:07:26 +13:00
parent 715ddf2b8c
commit 7fccb7e03e
3 changed files with 26 additions and 29 deletions

View File

@@ -62,7 +62,7 @@ const SharePage = createClass({
<Nav.item href={`/source/${this.processShareId()}`} color='teal' icon='fa-code'>
view source
</Nav.item>
<Nav.item href={`/source_dl/${this.processShareId()}`} color='teal' icon='fa-download'>
<Nav.item href={`/source_dl/${this.processShareId()}`} color='red' icon='fa-download'>
download source
</Nav.item>
<RecentNavItem brew={this.props.brew} storageKey='view' />

View File

@@ -0,0 +1,14 @@
const sourceDL = function(res, brew) {
const fileName = brew.title.replaceAll(' ', '-').replaceAll(':', '').replaceAll('/', '');
res.status(200);
res.set({
'Cache-Control' : 'no-cache',
'Content-Type' : 'text/plain',
'Content-Disposition' : `attachment; filename="HomeBrewery-${fileName}.txt"`
});
return res;
};
module.exports = sourceDL;