0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-12 04:32:41 +00:00

Merge branch 'master' into SwappableThemes-ReorganizeFolderStructure

This commit is contained in:
Trevor Buckner
2022-09-09 10:51:08 -04:00
6 changed files with 22810 additions and 22754 deletions

View File

@@ -39,6 +39,26 @@ pre {
## changelog ## changelog
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).
### Friday 08/09/2022 - v3.2.2
{{taskList
##### Jeddai:
* [x] Fix brews not deleting from User page when removed from Google Drive externally.
Fixes issues: [#2325](https://github.com/naturalcrit/homebrewery/issues/2325)
##### G-Ambatte:
* [x] Brew Tags are now searchable on the User page
Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [#2319](https://github.com/naturalcrit/homebrewery/issues/2319), [#2334](https://github.com/naturalcrit/homebrewery/issues/2334)
* [x] Several tweaks to the User page
Fixes issues: [#1797](https://github.com/naturalcrit/homebrewery/issues/1797), [#2315](https://github.com/naturalcrit/homebrewery/issues/2315), [#2326](https://github.com/naturalcrit/homebrewery/issues/2326), [#2328](https://github.com/naturalcrit/homebrewery/issues/2328)
}}
### Wednesday 31/08/2022 - v3.2.1 ### Wednesday 31/08/2022 - v3.2.1
{{taskList {{taskList

View File

@@ -95,6 +95,9 @@ const BrewItem = createClass({
render : function(){ render : function(){
const brew = this.props.brew; const brew = this.props.brew;
if(Array.isArray(brew.tags)) { // temporary fix until dud tags are cleaned
brew.tags = brew.tags?.filter(tag => tag); //remove tags that are empty strings
}
const dateFormatString = 'YYYY-MM-DD HH:mm:ss'; const dateFormatString = 'YYYY-MM-DD HH:mm:ss';
return <div className='brewItem'> return <div className='brewItem'>
@@ -104,11 +107,15 @@ const BrewItem = createClass({
</div> </div>
<hr /> <hr />
<div className='info'> <div className='info'>
{brew.tags ? <>
<span className='brewTags' title={`Tags:\n${brew.tags.join('\n')}`}> {brew.tags?.length ? <>
<i className='fas fa-tags'/> {brew.tags.join(', ')} <div className='brewTags' title={`Tags:\n${brew.tags.join('\n')}`}>
</span> <i className='fas fa-tags'/>
<br /> {brew.tags.map((tag, idx)=>{
let matches = tag.match(/^(?:([^:]+):)?([^:]+)$/);
return <span className={matches[1]}>{matches[2]}</span>;
})}
</div>
</> : <></> </> : <></>
} }
<span title={`Authors:\n${brew.authors?.join('\n')}`}> <span title={`Authors:\n${brew.authors?.join('\n')}`}>

View File

@@ -29,13 +29,23 @@
.info{ .info{
position: initial; position: initial;
bottom: 2px; bottom: 2px;
font-family : ScalySans; font-family : ScalySansRemake;
font-size : 1.2em; font-size : 1.2em;
&>span{ &>span{
margin-right : 12px; margin-right : 12px;
line-height : 1.5em; line-height : 1.5em;
} }
} }
.brewTags span {
background-color: #c8ac6e3b;
margin: 2px;
padding: 2px;
border: 1px solid #c8ac6e;
border-radius: 4px;
white-space: nowrap;
display: inline-block;
font-weight: bold;
}
&:hover{ &:hover{
.links{ .links{
opacity : 1; opacity : 1;

1564
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "homebrewery", "name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown", "description": "Create authentic looking D&D homebrews using only markdown",
"version": "3.2.1", "version": "3.2.2",
"engines": { "engines": {
"node": "16.11.x" "node": "16.11.x"
}, },
@@ -51,9 +51,9 @@
] ]
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.18.13", "@babel/core": "^7.19.0",
"@babel/plugin-transform-runtime": "^7.18.10", "@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.18.10", "@babel/preset-env": "^7.19.0",
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"body-parser": "^1.20.0", "body-parser": "^1.20.0",
"classnames": "^2.3.1", "classnames": "^2.3.1",
@@ -74,7 +74,7 @@
"marked-extended-tables": "^1.0.5", "marked-extended-tables": "^1.0.5",
"markedLegacy": "npm:marked@^0.3.19", "markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.29.4", "moment": "^2.29.4",
"mongoose": "^6.5.4", "mongoose": "^6.6.0",
"nanoid": "3.3.4", "nanoid": "3.3.4",
"nconf": "^0.12.0", "nconf": "^0.12.0",
"react": "^16.14.0", "react": "^16.14.0",
@@ -87,8 +87,8 @@
}, },
"devDependencies": { "devDependencies": {
"eslint": "^8.23.0", "eslint": "^8.23.0",
"eslint-plugin-react": "^7.31.1", "eslint-plugin-react": "^7.31.7",
"jest": "^29.0.1", "jest": "^29.0.2",
"supertest": "^6.2.4" "supertest": "^6.2.4"
} }
} }

View File

@@ -15,17 +15,24 @@ const { nanoid } = require('nanoid');
// }); // });
// }; // };
const getId = (req)=>{
// Set the id and initial potential google id, where the google id is present on the existing brew.
let id = req.params.id, googleId = req.body?.googleId;
// If the id is longer than 12, then it's a google id + the edit id. This splits the longer id up.
if(id.length > 12) {
googleId = id.slice(0, -12);
id = id.slice(-12);
}
return { id, googleId };
};
const getBrew = (accessType)=>{ const getBrew = (accessType)=>{
// Create middleware with the accessType passed in as part of the scope // Create middleware with the accessType passed in as part of the scope
return async (req, res, next)=>{ return async (req, res, next)=>{
// Set the id and initial potential google id, where the google id is present on the existing brew. // Get relevant IDs for the brew
let id = req.params.id, googleId = req.body?.googleId; const { id, googleId } = getId(req);
// If the id is longer than 12, then it's a google id + the edit id. This splits the longer id up.
if(id.length > 12) {
googleId = id.slice(0, -12);
id = id.slice(-12);
}
// Try to find the document in the Homebrewery database -- if it doesn't exist, that's fine. // Try to find the document in the Homebrewery database -- if it doesn't exist, that's fine.
let stub = await HomebrewModel.get(accessType === 'edit' ? { editId: id } : { shareId: id }) let stub = await HomebrewModel.get(accessType === 'edit' ? { editId: id } : { shareId: id })
.catch((err)=>{ .catch((err)=>{
@@ -259,7 +266,17 @@ const deleteGoogleBrew = async (account, id, editId, res)=>{
return true; return true;
}; };
const deleteBrew = async (req, res)=>{ const deleteBrew = async (req, res, next)=>{
// Delete an orphaned stub if its Google brew doesn't exist
try {
await getBrew('edit')(req, res, ()=>{});
} catch (err) {
const { id, googleId } = getId(req);
console.warn(`No google brew found for id ${googleId}, the stub with id ${id} will be deleted.`);
await HomebrewModel.deleteOne({ editId: id });
return next();
}
let brew = req.brew; let brew = req.brew;
const { googleId, editId } = brew; const { googleId, editId } = brew;
const account = req.account; const account = req.account;
@@ -312,8 +329,8 @@ const deleteBrew = async (req, res)=>{
router.post('/api', asyncHandler(newBrew)); router.post('/api', asyncHandler(newBrew));
router.put('/api/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew)); router.put('/api/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew));
router.put('/api/update/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew)); router.put('/api/update/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew));
router.delete('/api/:id', asyncHandler(getBrew('edit')), asyncHandler(deleteBrew)); router.delete('/api/:id', asyncHandler(deleteBrew));
router.get('/api/remove/:id', asyncHandler(getBrew('edit')), asyncHandler(deleteBrew)); router.get('/api/remove/:id', asyncHandler(deleteBrew));
module.exports = { module.exports = {
homebrewApi : router, homebrewApi : router,