0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-23 16:33:05 +00:00

Compare commits

...

36 Commits

Author SHA1 Message Date
Trevor Buckner
a9a9804517 v3.4.2 2022-12-10 14:15:09 -05:00
Trevor Buckner
0bde44ec2f Merge pull request #2470 from jeddai/remove-google-get-during-update
update getBrew usages to not fetch google brew during updates
2022-12-10 13:54:58 -05:00
Trevor Buckner
13ad179a1b Merge pull request #2523 from G-Ambatte/showGoogleAuthStatus-#2520
Add link to instructions to refresh Google creds
2022-12-10 13:34:17 -05:00
Trevor Buckner
b72acd9e59 cleanup 2022-12-10 13:31:57 -05:00
G.Ambatte
d0a1ef9571 Change to aggregate query, rename variables 2022-12-09 18:35:17 +13:00
G.Ambatte
d1f049871f Merge branch 'master' into showGoogleAuthStatus-#2520 2022-12-09 07:56:25 +13:00
Trevor Buckner
070184b309 Merge pull request #2553 from naturalcrit/dependabot/npm_and_yarn/react-router-dom-6.4.5
Bump react-router-dom from 6.4.4 to 6.4.5
2022-12-07 22:49:39 -05:00
Trevor Buckner
cbb41676e0 Merge pull request #2551 from naturalcrit/dependabot/npm_and_yarn/marked-4.2.4
Bump marked from 4.2.3 to 4.2.4
2022-12-07 22:49:09 -05:00
Trevor Buckner
81130dd514 Merge pull request #2550 from naturalcrit/dependabot/npm_and_yarn/supertest-6.3.3
Bump supertest from 6.3.2 to 6.3.3
2022-12-07 22:48:59 -05:00
dependabot[bot]
61d3edca17 Bump react-router-dom from 6.4.4 to 6.4.5
Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.4.4 to 6.4.5.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@6.4.5/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router-dom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 03:01:48 +00:00
dependabot[bot]
248b56a706 Bump marked from 4.2.3 to 4.2.4
Bumps [marked](https://github.com/markedjs/marked) from 4.2.3 to 4.2.4.
- [Release notes](https://github.com/markedjs/marked/releases)
- [Changelog](https://github.com/markedjs/marked/blob/master/.releaserc.json)
- [Commits](https://github.com/markedjs/marked/compare/v4.2.3...v4.2.4)

---
updated-dependencies:
- dependency-name: marked
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 03:01:13 +00:00
dependabot[bot]
90f8d1d6da Bump supertest from 6.3.2 to 6.3.3
Bumps [supertest](https://github.com/visionmedia/supertest) from 6.3.2 to 6.3.3.
- [Release notes](https://github.com/visionmedia/supertest/releases)
- [Commits](https://github.com/visionmedia/supertest/compare/v6.3.2...v6.3.3)

---
updated-dependencies:
- dependency-name: supertest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 03:00:58 +00:00
Trevor Buckner
8f08b71475 Merge pull request #2547 from jeddai/tags-validation-fix
Fix tags validation issues
2022-12-07 12:54:22 -05:00
Trevor Buckner
cc6527029c Merge pull request #2546 from naturalcrit/dependabot/npm_and_yarn/mongoose-6.8.0
Bump mongoose from 6.7.5 to 6.8.0
2022-12-07 11:32:27 -05:00
Charlie Humphreys
8a110567fc remove call to persist 2022-12-07 07:32:22 -06:00
Charlie Humphreys
4e2f6b1d26 move callIfExists to base file scope 2022-12-05 22:39:38 -06:00
Charlie Humphreys
208593d203 add callIfExists, which will call a method only if it exists 2022-12-05 22:06:06 -06:00
Charlie Humphreys
99019be152 switch updateOne to findOneAndUpdate and return the saved instead of the brew passed in 2022-12-05 21:00:44 -06:00
dependabot[bot]
fa73e1707d Bump mongoose from 6.7.5 to 6.8.0
Bumps [mongoose](https://github.com/Automattic/mongoose) from 6.7.5 to 6.8.0.
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/mongoose/compare/6.7.5...6.8.0)

---
updated-dependencies:
- dependency-name: mongoose
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-06 03:00:40 +00:00
Trevor Buckner
d7de2e3d21 Merge pull request #2545 from naturalcrit/v3.4.1
Up version to v3.4.1
2022-12-05 21:38:11 -05:00
Trevor Buckner
903ff4fd09 Merge pull request #2542 from naturalcrit/dependabot/npm_and_yarn/supertest-6.3.2
Bump supertest from 6.3.1 to 6.3.2
2022-12-05 21:37:55 -05:00
Trevor Buckner
feaabacc94 Merge pull request #2544 from naturalcrit/dependabot/npm_and_yarn/eslint-8.29.0
Bump eslint from 8.28.0 to 8.29.0
2022-12-05 21:37:40 -05:00
Trevor Buckner
bc0846c190 Merge pull request #2537 from Gazook89/Update-Injector-RegEx
change injector regex to work with safari
2022-12-05 21:18:24 -05:00
Gazook89
ecdcaadfa9 remove | from regexp 2022-12-05 11:25:24 -06:00
dependabot[bot]
db2478f73d Bump eslint from 8.28.0 to 8.29.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.28.0 to 8.29.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.28.0...v8.29.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-05 03:01:41 +00:00
dependabot[bot]
5d6a7e692f Bump supertest from 6.3.1 to 6.3.2
Bumps [supertest](https://github.com/visionmedia/supertest) from 6.3.1 to 6.3.2.
- [Release notes](https://github.com/visionmedia/supertest/releases)
- [Commits](https://github.com/visionmedia/supertest/compare/v6.3.1...v6.3.2)

---
updated-dependencies:
- dependency-name: supertest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-05 03:00:45 +00:00
Gazook89
0fbeca1536 Merge branch 'master' into Update-Injector-RegEx 2022-12-04 20:17:46 -06:00
Gazook89
31d58f9075 change regex to work with safari. 2022-12-01 11:55:37 -06:00
G.Ambatte
89e6bada56 Add link to instructions to refresh Google creds 2022-11-29 10:26:44 +13:00
Charlie Humphreys
fec1766e26 switch fetchGoogle to stubOnly 2022-11-21 16:21:36 -06:00
Charlie Humphreys
f26e3d6cd1 remove tags from google brew fetch 2022-11-18 17:53:47 -06:00
Charlie Humphreys
13b43e8902 Merge branch 'master' into remove-google-get-during-update 2022-11-16 23:15:11 -06:00
Charlie Humphreys
2e305d5636 remove authorship piece from this PR 2022-11-16 22:37:59 -06:00
Charlie Humphreys
f9711de634 add elvis for the possibility that the save failed 2022-11-16 22:32:50 -06:00
Charlie Humphreys
2c6779bb1c adjust getBrew to check authorship, change update method to not perform a get 2022-11-16 22:28:00 -06:00
Charlie Humphreys
0867b142da update getBrew usages to not fetch google brew during updates 2022-10-27 21:44:26 -05:00
9 changed files with 991 additions and 941 deletions

View File

@@ -44,6 +44,23 @@ pre {
## changelog
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).
### Saturday 10/12/2022 - v3.4.2
{{taskList
##### Jeddai
* [x] Fix broken tags editor
* [x] Reduce server load to fix some saving issues
Fixes issues [#2322](https://github.com/naturalcrit/homebrewery/issues/2322)
##### Gazook
* [x] Account page help link for Google Drive errors
Fixes issues [#2520](https://github.com/naturalcrit/homebrewery/issues/2520)
}}
### Monday 05/12/2022 - v3.4.1
{{taskList

View File

@@ -139,10 +139,10 @@ const Editor = createClass({
// Highlight injectors {style}
if(line.includes('{') && line.includes('}')){
const regex = /(?<!{){(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1}/g;
const regex = /(?:^|[^{\n])({(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\2})/gm;
let match;
while ((match = regex.exec(line)) != null) {
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'injection' });
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'injection' });
}
}
// Highlight inline spans {{content}}

View File

@@ -9,12 +9,18 @@ const Nav = require('naturalcrit/nav/nav.jsx');
const StringArrayEditor = require('../stringArrayEditor/stringArrayEditor.jsx');
const Themes = require('themes/themes.json');
const validations = require('./validations.js')
const validations = require('./validations.js');
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
const homebreweryThumbnail = require('../../thumbnail.png');
const callIfExists = (val, fn, ...args)=>{
if(val[fn]) {
val[fn](...args);
}
};
const MetadataEditor = createClass({
displayName : 'MetadataEditor',
getDefaultProps : function() {
@@ -53,28 +59,25 @@ const MetadataEditor = createClass({
},
handleFieldChange : function(name, e){
e.persist();
// load validation rules, and check input value against them
const inputRules = validations[name] ?? [];
const validationErr = inputRules.map((rule)=>rule(e.target.value)).filter(Boolean);
// if no validation rules, save to props
if(validationErr.length === 0){
e.target.setCustomValidity('');
callIfExists(e.target, 'setCustomValidity', '');
this.props.onChange({
...this.props.metadata,
[name] : e.target.value
});
} else {
// if validation issues, display built-in browser error popup with each error.
console.log(validationErr);
const errMessage = validationErr.map((err)=>{
return `- ${err}`;
}).join('\n');
e.target.setCustomValidity(errMessage);
e.target.reportValidity();
};
callIfExists(e.target, 'setCustomValidity', errMessage);
callIfExists(e.target, 'reportValidity');
}
},
handleSystem : function(system, e){

View File

@@ -42,7 +42,6 @@ const AccountPage = createClass({
},
renderUiItems : function() {
// console.log(this.props.uiItems);
return <>
<div className='dataGroup'>
<h1>Account Information <i className='fas fa-user'></i></h1>
@@ -51,12 +50,16 @@ const AccountPage = createClass({
</div>
<div className='dataGroup'>
<h3>Homebrewery Information <NaturalCritIcon /></h3>
<p><strong>Brews on Homebrewery: </strong> {this.props.uiItems.mongoCount || '-'}</p>
<p><strong>Brews on Homebrewery: </strong> {this.props.uiItems.mongoCount}</p>
</div>
<div className='dataGroup'>
<h3>Google Information <i className='fab fa-google-drive'></i></h3>
<p><strong>Linked to Google: </strong> {this.props.uiItems.googleId ? 'YES' : 'NO'}</p>
{this.props.uiItems.googleId ? <p><strong>Brews on Google Drive: </strong> {this.props.uiItems.fileCount || '-'}</p> : '' }
{this.props.uiItems.googleId &&
<p>
<strong>Brews on Google Drive: </strong> {this.props.uiItems.googleCount ?? <>Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a></>}
</p>
}
</div>
</>;
},

1803
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown",
"version": "3.4.1",
"version": "3.4.2",
"engines": {
"node": "16.11.x"
},
@@ -70,26 +70,26 @@
"jwt-simple": "^0.5.6",
"less": "^3.13.1",
"lodash": "^4.17.21",
"marked": "4.2.3",
"marked": "4.2.4",
"marked-extended-tables": "^1.0.5",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.29.4",
"mongoose": "^6.7.5",
"mongoose": "^6.8.0",
"nanoid": "3.3.4",
"nconf": "^0.12.0",
"npm": "^8.10.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-frame-component": "4.1.3",
"react-router-dom": "6.4.4",
"react-router-dom": "6.4.5",
"sanitize-filename": "1.6.3",
"superagent": "^6.1.0",
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
},
"devDependencies": {
"eslint": "^8.28.0",
"eslint": "^8.29.0",
"eslint-plugin-react": "^7.31.11",
"jest": "^29.2.2",
"supertest": "^6.3.1"
"supertest": "^6.3.3"
}
}

View File

@@ -280,7 +280,6 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{
title : req.brew.title || 'Untitled Brew',
description : req.brew.description || 'No description.',
image : req.brew.thumbnail || defaultMetaTags.image,
type : 'article'
};
@@ -341,7 +340,7 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
data.title = 'Account Information Page';
let auth;
let files;
let googleCount = [];
if(req.account) {
if(req.account.googleId) {
try {
@@ -353,9 +352,9 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
}
if(auth.credentials.access_token) {
try {
files = await GoogleActions.listGoogleBrews(auth);
googleCount = await GoogleActions.listGoogleBrews(auth);
} catch (e) {
files = undefined;
googleCount = undefined;
console.log('List Google files failed!');
console.log(e);
}
@@ -363,18 +362,19 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
}
const query = { authors: req.account.username, googleId: { $exists: false } };
const brews = await HomebrewModel.find(query, 'id')
const mongoCount = await HomebrewModel.countDocuments(query)
.catch((err)=>{
mongoCount = 0;
console.log(err);
});
data.uiItems = {
username : req.account.username,
issued : req.account.issued,
mongoCount : brews.length,
googleId : Boolean(req.account.googleId),
authCheck : Boolean(req.account.googleId && auth.credentials.access_token),
fileCount : files?.length || '-'
username : req.account.username,
issued : req.account.issued,
googleId : Boolean(req.account.googleId),
authCheck : Boolean(req.account.googleId && auth.credentials.access_token),
mongoCount : mongoCount,
googleCount : googleCount?.length
};
}

View File

@@ -253,7 +253,6 @@ const GoogleActions = {
text : file.data,
description : obj.data.description,
tags : obj.data.properties.tags ? obj.data.properties.tags : '',
systems : obj.data.properties.systems ? obj.data.properties.systems.split(',') : [],
authors : [],
published : obj.data.properties.published ? obj.data.properties.published == 'true' : false,

View File

@@ -27,7 +27,7 @@ const getId = (req)=>{
return { id, googleId };
};
const getBrew = (accessType)=>{
const getBrew = (accessType, stubOnly = false)=>{
// Create middleware with the accessType passed in as part of the scope
return async (req, res, next)=>{
// Get relevant IDs for the brew
@@ -45,7 +45,7 @@ const getBrew = (accessType)=>{
stub = stub?.toObject();
// If there is a google id, try to find the google brew
if(googleId || stub?.googleId) {
if(!stubOnly && (googleId || stub?.googleId)) {
let googleError;
const googleBrew = await GoogleActions.getGoogleBrew(googleId || stub?.googleId, id, accessType)
.catch((err)=>{
@@ -59,14 +59,14 @@ const getBrew = (accessType)=>{
}
// If after all of that we still don't have a brew, throw an exception
if(!stub) {
if(!stub && !stubOnly) {
throw 'Brew not found in Homebrewery database or Google Drive';
}
if(typeof stub.tags === 'string') {
if(typeof stub?.tags === 'string') {
stub.tags = [];
}
req.brew = stub;
req.brew = stub || {};
next();
};
@@ -235,23 +235,22 @@ const updateBrew = async (req, res)=>{
brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
}
// Fetch the brew from the database again (if it existed there to begin with), and assign the existing brew to it
brew = _.assign(await HomebrewModel.findOne({ _id: brew._id }), brew);
if(!brew.markModified) {
// If it wasn't in the database, create a new db brew
brew = new HomebrewModel(brew);
// define a function to catch our save errors
const saveError = (err)=>{
console.error(err);
res.status(err.status || 500).send(err.message || 'Unable to save brew to Homebrewery database');
};
let saved;
if(!brew._id) {
// if the brew does not have a stub id, create and save it, then write the new value back to the brew.
saved = await new HomebrewModel(brew).save().catch(saveError);
brew = saved?.toObject();
} else {
// if the brew does have a stub id, update it using the stub id as the key.
saved = await HomebrewModel.findOneAndUpdate({ _id: brew._id }, brew, {
returnOriginal : false
}).catch(saveError);
}
brew.markModified('authors');
brew.markModified('systems');
// Save the database brew
const saved = await brew.save()
.catch((err)=>{
console.error(err);
res.status(err.status || 500).send(err.message || 'Unable to save brew to Homebrewery database');
});
if(!saved) return;
// Call and wait for afterSave to complete
const after = await afterSave();
@@ -327,8 +326,8 @@ const deleteBrew = async (req, res, next)=>{
};
router.post('/api', asyncHandler(newBrew));
router.put('/api/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew));
router.put('/api/update/:id', asyncHandler(getBrew('edit')), asyncHandler(updateBrew));
router.put('/api/:id', asyncHandler(getBrew('edit', true)), asyncHandler(updateBrew));
router.put('/api/update/:id', asyncHandler(getBrew('edit', true)), asyncHandler(updateBrew));
router.delete('/api/:id', asyncHandler(deleteBrew));
router.get('/api/remove/:id', asyncHandler(deleteBrew));