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:
@@ -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' />
|
||||
|
||||
14
client/homebrew/pages/sharePage/source_dl.jsx
Normal file
14
client/homebrew/pages/sharePage/source_dl.jsx
Normal 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;
|
||||
Reference in New Issue
Block a user