0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 19:32:47 +00:00

Edit working - with noise.

This commit is contained in:
David Bolack
2024-02-27 19:33:33 -06:00
parent 50c9d95ce0
commit 56851f2c2d
3 changed files with 21 additions and 4 deletions

View File

@@ -211,7 +211,10 @@ const MetadataEditor = createClass({
});
};
const currentTheme = mergedThemes[`${_.upperFirst(this.props.metadata.themeClass?this.props.metadata.themeClass:this.props.metadata.renderer)}`][this.props.metadata.theme];
const currentTheme = mergedThemes[`${_.upperFirst(this.props.metadata.theme[0] === '#' ? 'Brew' : this.props.metadata.renderer)}`][this.props.metadata.theme];
console.log('currentTheme');
console.log(this.props.metadata.themeClass);
console.log('currentTheme');
let dropdown;
if(this.props.metadata.renderer == 'legacy') {

View File

@@ -286,6 +286,9 @@ app.get('/user/:username', async (req, res, next)=>{
//Edit Page
app.get('/edit/:id', asyncHandler(getBrew('edit')), async(req, res, next)=>{
req.brew = req.brew.toObject ? req.brew.toObject() : req.brew;
console.log('Load Edit');
console.log(req.brew);
console.log('Load Edit');
req.ogMeta = { ...defaultMetaTags,
title : req.brew.title || 'Untitled Brew',

View File

@@ -49,6 +49,9 @@ const splitTextStyleAndMetadata = (brew)=>{
};
const getUsersBrewThemes = async (username, id)=>{
console.log('getUsersBrewThemes');
console.log(username);
console.log(id);
const fields = [
'title',
'tags',
@@ -56,6 +59,7 @@ const getUsersBrewThemes = async (username, id)=>{
'thumbnail',
'textBin'
];
const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['theme', 'Theme'] }, editId: { $ne: id } }) //lean() converts results to JSObjects
.catch((error)=>{throw 'Can not find brews';});
@@ -65,7 +69,7 @@ const getUsersBrewThemes = async (username, id)=>{
}
};
brews.forEach(async (brew)=>{
for await (const brew of brews) {
const brewTheme = await HomebrewModel.get({ editId: brew.editId }, ['textBin']);
splitTextStyleAndMetadata(brewTheme);
userThemes.Brew[`#${brew.editId}`] = {
@@ -76,8 +80,9 @@ const getUsersBrewThemes = async (username, id)=>{
path : `#${brew.editId}`,
thumbnail : brew.thumbnail.length > 0 ? brew.thumbnail : '/assets/naturalCritLogoWhite.svg'
};
});
};
console.log('getUsersBrewThemes end');
return userThemes;
};
@@ -156,13 +161,19 @@ const api = {
const userID = accessType === 'edit' ? req.account.username : stub.authors.split(',')[0];
// Clean up brew: fill in missing fields with defaults / fix old invalid values
const userThemes = await getUsersBrewThemes(userID, id);
if(stub) {
stub.tags = stub.tags || undefined; // Clear empty strings
stub.renderer = stub.renderer || undefined; // Clear empty strings
stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields
stub.userThemes = await getUsersBrewThemes(userID, id);
stub.userThemes = userThemes;
}
console.log('stub.userThemes');
console.log(stub.userThemes);
console.log(stub.userThemes);
console.log('stub.userThemes');
req.brew = stub ?? {};
next();
};