mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-31 23:52:48 +00:00
merge master into google-document-stubs
This commit is contained in:
@@ -234,17 +234,40 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
|
||||
//Print Page
|
||||
app.get('/print/:id', asyncHandler(getBrew('share')), sanitizeMiddleware('share'), splitTextStyleAndMetadata);
|
||||
|
||||
const nodeEnv = config.get('node_env');
|
||||
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
|
||||
// Local only
|
||||
if(isLocalEnvironment){
|
||||
// Login
|
||||
app.post('/local/login', (req, res)=>{
|
||||
const username = req.body.username;
|
||||
if(!username) return;
|
||||
|
||||
const payload = jwt.encode({ username: username, issued: new Date }, config.get('secret'));
|
||||
return res.json(payload);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Render the page
|
||||
const templateFn = require('./../client/template.js');
|
||||
app.use((req, res)=>{
|
||||
// Create configuration object
|
||||
const configuration = {
|
||||
local : isLocalEnvironment,
|
||||
environment : nodeEnv
|
||||
};
|
||||
const props = {
|
||||
version : require('./../package.json').version,
|
||||
publicUrl : config.get('publicUrl') ?? '',
|
||||
url : req.originalUrl,
|
||||
brew : req.brew,
|
||||
brews : req.brews,
|
||||
googleBrews : req.googleBrews,
|
||||
account : req.account,
|
||||
enable_v3 : config.get('enable_v3')
|
||||
enable_v3 : config.get('enable_v3'),
|
||||
config : configuration
|
||||
};
|
||||
const title = req.brew ? req.brew.title : '';
|
||||
templateFn('homebrew', title, props)
|
||||
|
||||
@@ -126,7 +126,8 @@ const GoogleActions = {
|
||||
views : parseInt(file.properties.views),
|
||||
tags : '',
|
||||
published : file.properties.published ? file.properties.published == 'true' : false,
|
||||
systems : []
|
||||
systems : [],
|
||||
thumbnail : file.properties.thumbnail
|
||||
};
|
||||
});
|
||||
return brews;
|
||||
@@ -149,6 +150,7 @@ const GoogleActions = {
|
||||
'renderer' : brew.renderer || 'legacy',
|
||||
'isStubbed' : true,
|
||||
'updatedAt' : new Date().toISOString(),
|
||||
thumbnail : brew.thumbnail
|
||||
}
|
||||
},
|
||||
media : {
|
||||
@@ -188,7 +190,8 @@ const GoogleActions = {
|
||||
'renderer' : brew.renderer || 'legacy',
|
||||
'isStubbed' : true,
|
||||
'createdAt' : new Date().toISOString(),
|
||||
'version' : 1
|
||||
'version' : 1,
|
||||
'thumbnail' : brew.thumbnail || ''
|
||||
}
|
||||
};
|
||||
|
||||
@@ -267,6 +270,7 @@ const GoogleActions = {
|
||||
views : parseInt(obj.data.properties.views) || 0, //brews with no view parameter will return undefined
|
||||
version : parseInt(obj.data.properties.version) || 0,
|
||||
renderer : obj.data.properties.renderer ? obj.data.properties.renderer : 'legacy',
|
||||
thumbnail : obj.data.properties.thumbnail || '',
|
||||
|
||||
googleId : id
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ const HomebrewSchema = mongoose.Schema({
|
||||
renderer : { type: String, default: '' },
|
||||
authors : [String],
|
||||
published : { type: Boolean, default: false },
|
||||
thumbnail : { type: String, default: '' },
|
||||
|
||||
createdAt : { type: Date, default: Date.now },
|
||||
updatedAt : { type: Date, default: Date.now },
|
||||
|
||||
Reference in New Issue
Block a user