mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-27 16:03:07 +00:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2065ff80ff | ||
|
|
b24bba87d9 | ||
|
|
5583fc76f3 | ||
|
|
e810445ac9 | ||
|
|
5afbb4ee4e | ||
|
|
6ae4cd143c | ||
|
|
978329fdc9 | ||
|
|
f754ecd6c3 | ||
|
|
62a827ce49 | ||
|
|
e971da2b59 | ||
|
|
2d092cb290 | ||
|
|
5b66ecb06f | ||
|
|
22a9799674 | ||
|
|
7c813be13a | ||
|
|
e94148b2f0 | ||
|
|
ec4f6e4327 | ||
|
|
fcbd117784 | ||
|
|
dab716a9e0 | ||
|
|
9265e25c73 | ||
|
|
4ad63d5bce | ||
|
|
f89c897488 | ||
|
|
521ff5e7e3 | ||
|
|
89d8cb3b0a | ||
|
|
a0e92b54d0 | ||
|
|
62f549f038 | ||
|
|
e8f3b0c8d0 | ||
|
|
587ce78f4e | ||
|
|
7ca1dd3c68 | ||
|
|
58543f0b4d | ||
|
|
e88253f364 | ||
|
|
bdf37d8fe7 | ||
|
|
22908207a3 | ||
|
|
7239b89108 | ||
|
|
0ea80bd758 | ||
|
|
f6d623ace3 | ||
|
|
63ad8b3411 | ||
|
|
50cc757a5c | ||
|
|
70430f84e1 | ||
|
|
80db261c88 | ||
|
|
5631ef7be7 | ||
|
|
2745a4d6c1 | ||
|
|
33190b5c89 | ||
|
|
354a5832e4 | ||
|
|
f57c0f0886 | ||
|
|
954a393fce | ||
|
|
01dbac78ce | ||
|
|
594ea8ab59 | ||
|
|
033493a31b | ||
|
|
e79b099633 | ||
|
|
5bc948ab0a | ||
|
|
28c5d7d84a | ||
|
|
b9cfc2e6af |
@@ -6,7 +6,7 @@ version: 2
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:8.9
|
- image: circleci/node:12.16.3
|
||||||
- image: circleci/mongo:3.4-jessie
|
- image: circleci/mongo:3.4-jessie
|
||||||
|
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
@@ -30,4 +30,3 @@ jobs:
|
|||||||
|
|
||||||
# run tests!
|
# run tests!
|
||||||
- run: npm run circleci
|
- run: npm run circleci
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root : true,
|
||||||
parserOptions : {
|
parserOptions : {
|
||||||
ecmaVersion : 9,
|
ecmaVersion : 9,
|
||||||
sourceType : 'module',
|
sourceType : 'module',
|
||||||
@@ -9,6 +9,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
env : {
|
env : {
|
||||||
browser : true,
|
browser : true,
|
||||||
|
node : true
|
||||||
},
|
},
|
||||||
plugins : ['react'],
|
plugins : ['react'],
|
||||||
rules : {
|
rules : {
|
||||||
@@ -47,7 +48,7 @@ module.exports = {
|
|||||||
'no-var' : 'warn',
|
'no-var' : 'warn',
|
||||||
'prefer-const' : 'warn',
|
'prefer-const' : 'warn',
|
||||||
'prefer-template' : 'warn',
|
'prefer-template' : 'warn',
|
||||||
'quotes' : ['warn', 'single', { 'allowTemplateLiterals': true } ],
|
'quotes' : ['warn', 'single', { 'allowTemplateLiterals': true }],
|
||||||
'semi' : ['warn', 'always'],
|
'semi' : ['warn', 'always'],
|
||||||
|
|
||||||
/** Whitespace **/
|
/** Whitespace **/
|
||||||
@@ -66,7 +67,7 @@ module.exports = {
|
|||||||
multiLine : { beforeColon: true, afterColon: true, align: 'colon' },
|
multiLine : { beforeColon: true, afterColon: true, align: 'colon' },
|
||||||
singleLine : { beforeColon: false, afterColon: true }
|
singleLine : { beforeColon: false, afterColon: true }
|
||||||
}],
|
}],
|
||||||
'linebreak-style' : ['warn', 'unix'],
|
'linebreak-style' : 'off',
|
||||||
'no-trailing-spaces' : 'warn',
|
'no-trailing-spaces' : 'warn',
|
||||||
'no-whitespace-before-property' : 'warn',
|
'no-whitespace-before-property' : 'warn',
|
||||||
'object-curly-spacing' : ['warn', 'always'],
|
'object-curly-spacing' : ['warn', 'always'],
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ config/local.*
|
|||||||
|
|
||||||
todo.md
|
todo.md
|
||||||
startDB.bat
|
startDB.bat
|
||||||
|
startMViewer.bat
|
||||||
|
|||||||
15
Dockerfile
15
Dockerfile
@@ -1,14 +1,19 @@
|
|||||||
FROM node:8
|
FROM node:8
|
||||||
|
|
||||||
|
ENV NODE_ENV=docker
|
||||||
|
|
||||||
# Create app directory
|
# Create app directory
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# Bundle app source
|
# Copy package.json into the image, then run yarn install
|
||||||
|
# This improves caching so we don't have to download the dependencies every time the code changes
|
||||||
|
COPY package.json ./
|
||||||
|
# --ignore-scripts tells yarn not to run postbuild. We run it explicitly later
|
||||||
|
RUN yarn install --ignore-scripts
|
||||||
|
|
||||||
|
# Bundle app source and build application
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN yarn build
|
||||||
ENV NODE_ENV=docker
|
|
||||||
|
|
||||||
RUN yarn
|
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
CMD [ "yarn", "start" ]
|
CMD [ "yarn", "start" ]
|
||||||
12
README.DOCKER.md
Normal file
12
README.DOCKER.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Running Homebrewery via Docker
|
||||||
|
|
||||||
|
The repo includes a Dockerfile and a docker-compose.yml file.
|
||||||
|
|
||||||
|
To run the application via docker-compose.yml:
|
||||||
|
`docker-compose up -d`
|
||||||
|
|
||||||
|
To stop the application:
|
||||||
|
`docker-compose down`
|
||||||
|
|
||||||
|
To stop the application and remove all data:
|
||||||
|
`docker-compose down -v`
|
||||||
@@ -29,6 +29,10 @@ Fourth, you will need to install the program and run it using the two commands:
|
|||||||
|
|
||||||
You should now be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use the Homebrewery offline.
|
You should now be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use the Homebrewery offline.
|
||||||
|
|
||||||
|
### Running the application via Docker
|
||||||
|
|
||||||
|
Please see the docs here: [README.DOCKER.md](./README.DOCKER.md)
|
||||||
|
|
||||||
### Standalone PHB Stylesheet
|
### Standalone PHB Stylesheet
|
||||||
If you just want the stylesheet that is generated to make pages look like they are from the Player's Handbook, you will find it in the [phb.standalone.css](./phb.standalone.css) file.
|
If you just want the stylesheet that is generated to make pages look like they are from the Player's Handbook, you will find it in the [phb.standalone.css](./phb.standalone.css) file.
|
||||||
|
|
||||||
|
|||||||
37
changelog.md
37
changelog.md
@@ -1,5 +1,15 @@
|
|||||||
# changelog
|
# changelog
|
||||||
|
|
||||||
|
### Friday, 28/08/2020 - v2.9.2
|
||||||
|
- Many dependency updates
|
||||||
|
- Finally fixed this changelog page to not run off the edge :P
|
||||||
|
|
||||||
|
### Sunday, 19/07/2020 - v2.9.1
|
||||||
|
- Fixed paragraphs appearing blank on new columns
|
||||||
|
|
||||||
|
### Wednesday, 20/05/2020 - v2.9.0
|
||||||
|
- Major refactoring of site backend to work with updated dependencies for security (should be invisible to users)
|
||||||
|
|
||||||
### Wednesday, 11/03/2020 - v2.8.2
|
### Wednesday, 11/03/2020 - v2.8.2
|
||||||
- Fixed delete button removing everyone's copy for brews with multiple authors
|
- Fixed delete button removing everyone's copy for brews with multiple authors
|
||||||
- Compressed homebrew text in database
|
- Compressed homebrew text in database
|
||||||
@@ -33,21 +43,17 @@
|
|||||||
### Saturday, 18/02/2017 - v2.7.2
|
### Saturday, 18/02/2017 - v2.7.2
|
||||||
- Adding ability to delete a brew from the user page, incase the user creates a brew that makes the edit page unrender-able. (re:309)
|
- Adding ability to delete a brew from the user page, incase the user creates a brew that makes the edit page unrender-able. (re:309)
|
||||||
|
|
||||||
## BIG NEWS
|
```
|
||||||
With the next major release of Homebrewery, v3.0.0, this tool *will no longer support raw HTML input for brew code*. Most issues and errors users are having are because of this feature and it's become too taxing to help and fix these issues.
|
```
|
||||||
|
|
||||||
All brews made previous to the release of v3.0.0 will still render normally.
|
|
||||||
|
|
||||||
### Thursday, 19/01/2017 - v2.7.0
|
### Thursday, 19/01/2017 - v2.7.0
|
||||||
- Fixed saving multiple authors and multiple systems on brew metadata (thanks u/PalaNolho re:282)
|
- Fixed saving multiple authors and multiple systems on brew metadata (thanks u/PalaNolho re:282)
|
||||||
- Adding in line highlight for new pages
|
- Adding in line highlight for new pages
|
||||||
- Added in a simple brew lookup for admin
|
- Added in a simple brew lookup for admin
|
||||||
|
|
||||||
|
|
||||||
### Saturday, 14/01/2017 - v2.7.0
|
### Saturday, 14/01/2017 - v2.7.0
|
||||||
- Added a new Render Warning overlay. It detects situations where the brew may not be rendering correctly (wrong browser, browser is zoomed in...) and let's the user know
|
- Added a new Render Warning overlay. It detects situations where the brew may not be rendering correctly (wrong browser, browser is zoomed in...) and let's the user know
|
||||||
|
|
||||||
|
|
||||||
### Sunday, 25/12/2016 - v2.7.0
|
### Sunday, 25/12/2016 - v2.7.0
|
||||||
- Switching over to using Vitreum v4
|
- Switching over to using Vitreum v4
|
||||||
- Removed gulp, all tasks are run through npm scripts
|
- Removed gulp, all tasks are run through npm scripts
|
||||||
@@ -60,8 +66,6 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Removed a lot of unused files in shared
|
- Removed a lot of unused files in shared
|
||||||
- vitreum v4 now lets me use codemirror as a pure node dependacy
|
- vitreum v4 now lets me use codemirror as a pure node dependacy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Saturday, 03/12/2016 - v2.6.0
|
### Saturday, 03/12/2016 - v2.6.0
|
||||||
- Added report back to the edit page
|
- Added report back to the edit page
|
||||||
- Changed metaeditor icon
|
- Changed metaeditor icon
|
||||||
@@ -73,18 +77,17 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Added a table of contents snippet (thanks u/tullisar)
|
- Added a table of contents snippet (thanks u/tullisar)
|
||||||
- Added a multicolumn snippet
|
- Added a multicolumn snippet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Thursday, 01/12/2016
|
### Thursday, 01/12/2016
|
||||||
- Added in a snippet for a split table
|
- Added in a snippet for a split table
|
||||||
- Added an account nav item to new page
|
- Added an account nav item to new page
|
||||||
|
|
||||||
|
|
||||||
### Sunday, 27/11/2016 - v2.5.1
|
### Sunday, 27/11/2016 - v2.5.1
|
||||||
- Fixed the column rendering on the new user page. Really should have tested that better
|
- Fixed the column rendering on the new user page. Really should have tested that better
|
||||||
- Added a hover tooltip to fully read the brew description
|
- Added a hover tooltip to fully read the brew description
|
||||||
- Made the brew items take up only 25% allowing you to view more per row.
|
- Made the brew items take up only 25% allowing you to view more per row.
|
||||||
|
|
||||||
|
\page
|
||||||
|
|
||||||
### Wednesday, 23/11/2016 - v2.5.0
|
### Wednesday, 23/11/2016 - v2.5.0
|
||||||
- Metadata can now be added to brews
|
- Metadata can now be added to brews
|
||||||
- Added a metadata editor onto the edit and new pages
|
- Added a metadata editor onto the edit and new pages
|
||||||
@@ -95,7 +98,6 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Added a new user page to see others published brews, as well as all of your own brews.
|
- Added a new user page to see others published brews, as well as all of your own brews.
|
||||||
- Added a new nav item for accessing your profile and logging in
|
- Added a new nav item for accessing your profile and logging in
|
||||||
|
|
||||||
|
|
||||||
### Monday, 14/11/2016
|
### Monday, 14/11/2016
|
||||||
- Updated snippet bar style
|
- Updated snippet bar style
|
||||||
- You can now print from a new page without saving
|
- You can now print from a new page without saving
|
||||||
@@ -120,7 +122,6 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Fixed the noteblock overlapping into titles (thanks u/dsompura!)
|
- Fixed the noteblock overlapping into titles (thanks u/dsompura!)
|
||||||
- Fixed a bad search route in the admin panel (thanks u/SnappyTom!)
|
- Fixed a bad search route in the admin panel (thanks u/SnappyTom!)
|
||||||
|
|
||||||
|
|
||||||
### Friday, 29/07/2016 - v2.2.7
|
### Friday, 29/07/2016 - v2.2.7
|
||||||
- Adding in descriptive note blocks. (Thanks calculuschild!)
|
- Adding in descriptive note blocks. (Thanks calculuschild!)
|
||||||
|
|
||||||
@@ -141,12 +142,9 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Added in a new auto-incremeting page number snippet (thakns u/Ryrok!)
|
- Added in a new auto-incremeting page number snippet (thakns u/Ryrok!)
|
||||||
- Lists in monster stat blocks should be fixed now
|
- Lists in monster stat blocks should be fixed now
|
||||||
|
|
||||||
|
|
||||||
### Saturday, 04/06/2016 - v2.2.0
|
### Saturday, 04/06/2016 - v2.2.0
|
||||||
- MIgrating The Homebrewery over to hombrewery.naturalcrit.com. It know runs on it's own server, with it's own repo separate from the other tools I'm working on. Makes updating and deploying much easier.
|
- MIgrating The Homebrewery over to hombrewery.naturalcrit.com. It know runs on it's own server, with it's own repo separate from the other tools I'm working on. Makes updating and deploying much easier.
|
||||||
|
|
||||||
\page
|
|
||||||
|
|
||||||
### Sunday, 29/05/2016 - v2.1.0
|
### Sunday, 29/05/2016 - v2.1.0
|
||||||
- Finally added a syntax for doing spell lists. A bit in-depth about why this took so long. Essentially I'm running out of syntax to use in stardard Markdown. There are too many unique elements in the PHB-style to be mapped. I solved this earlier by stacking certain elements together (eg. an `<hr>` before a `blockquote` turns it into moster state block), but those are getting unweildly. I would like to simply wrap these in `div`s with classes, but unfortunately Markdown stops processing when within HTML blocks. To get around this I wrote my own override to the Markdown parser and lexer to process Markdown within a simple div class wrapper. This should open the door for more unique syntaxes in the future. Big step!
|
- Finally added a syntax for doing spell lists. A bit in-depth about why this took so long. Essentially I'm running out of syntax to use in stardard Markdown. There are too many unique elements in the PHB-style to be mapped. I solved this earlier by stacking certain elements together (eg. an `<hr>` before a `blockquote` turns it into moster state block), but those are getting unweildly. I would like to simply wrap these in `div`s with classes, but unfortunately Markdown stops processing when within HTML blocks. To get around this I wrote my own override to the Markdown parser and lexer to process Markdown within a simple div class wrapper. This should open the door for more unique syntaxes in the future. Big step!
|
||||||
- Override Ctrl+P (and cmd+P) to launch to the print page. Many people try to just print either the editing or share page to get a PDF. While this dones;t make much sense, I do get a ton of issues about it. So now if you try to do this, it'll just bring you imediately to the print page. Everybody wins!
|
- Override Ctrl+P (and cmd+P) to launch to the print page. Many people try to just print either the editing or share page to get a PDF. While this dones;t make much sense, I do get a ton of issues about it. So now if you try to do this, it'll just bring you imediately to the print page. Everybody wins!
|
||||||
@@ -158,6 +156,8 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Updated the issue template for (hopefully) better reporting
|
- Updated the issue template for (hopefully) better reporting
|
||||||
- Added suggestion to use chrome while PDF printing
|
- Added suggestion to use chrome while PDF printing
|
||||||
|
|
||||||
|
\page
|
||||||
|
|
||||||
### Wednesday, 25/05/2016 -v2.0.5
|
### Wednesday, 25/05/2016 -v2.0.5
|
||||||
- The class table generators have the proper ability score improvement progression.
|
- The class table generators have the proper ability score improvement progression.
|
||||||
|
|
||||||
@@ -171,8 +171,6 @@ All brews made previous to the release of v3.0.0 will still render normally.
|
|||||||
- Bumped up the allowed entity size for extra-large brew (Thanks for reporting it dickboner93)
|
- Bumped up the allowed entity size for extra-large brew (Thanks for reporting it dickboner93)
|
||||||
- Added a little error box when a save fails with a custom link to reporting the issue on github.
|
- Added a little error box when a save fails with a custom link to reporting the issue on github.
|
||||||
|
|
||||||
\page
|
|
||||||
|
|
||||||
### Saturday, 14/05/2016 - v2.0.0 (finally!)
|
### Saturday, 14/05/2016 - v2.0.0 (finally!)
|
||||||
|
|
||||||
I've been working on v2 for a *very* long time. I want to thank you guys for being paitent.
|
I've been working on v2 for a *very* long time. I want to thank you guys for being paitent.
|
||||||
@@ -212,8 +210,6 @@ Massive changelog incoming:
|
|||||||
- Source now opens to it's own route `/source/:sharedId` instead of just a window. Now easier to share, and won't be blocked by some browsers.
|
- Source now opens to it's own route `/source/:sharedId` instead of just a window. Now easier to share, and won't be blocked by some browsers.
|
||||||
- Print page now auto-opens print dialog. If you want to share your print page link, just remove the `?dialog=true` parameter and it won't open the dialog.
|
- Print page now auto-opens print dialog. If you want to share your print page link, just remove the `?dialog=true` parameter and it won't open the dialog.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\page
|
\page
|
||||||
|
|
||||||
### Wednesday, 20/04/2016
|
### Wednesday, 20/04/2016
|
||||||
@@ -281,4 +277,3 @@ Massive changelog incoming:
|
|||||||
* Added `phb.standalone.css` plus a build system for creating it
|
* Added `phb.standalone.css` plus a build system for creating it
|
||||||
* Added page numbers and footer text
|
* Added page numbers and footer text
|
||||||
* Page accent now flips each page
|
* Page accent now flips each page
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./admin.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./brewCleanup.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./brewCompress.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./brewLookup.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./stats.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./brewRenderer.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./errorBar.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
require('./notificationPopup.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./editor.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -138,9 +139,3 @@ const Editor = createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Editor;
|
module.exports = Editor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./metadataEditor.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -50,7 +51,7 @@ const MetadataEditor = createClass({
|
|||||||
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
|
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.get(`/api/remove/${this.props.metadata.editId}`)
|
request.delete(`/api/${this.props.metadata.editId}`)
|
||||||
.send()
|
.send()
|
||||||
.end(function(err, res){
|
.end(function(err, res){
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./snippetbar.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
|
require('./homebrew.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
const { StaticRouter:Router, Switch, Route } = require('react-router-dom');
|
||||||
const CreateRouter = require('pico-router').createRouter;
|
const queryString = require('query-string');
|
||||||
|
|
||||||
const HomePage = require('./pages/homePage/homePage.jsx');
|
const HomePage = require('./pages/homePage/homePage.jsx');
|
||||||
const EditPage = require('./pages/editPage/editPage.jsx');
|
const EditPage = require('./pages/editPage/editPage.jsx');
|
||||||
const UserPage = require('./pages/userPage/userPage.jsx');
|
const UserPage = require('./pages/userPage/userPage.jsx');
|
||||||
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
||||||
const NewPage = require('./pages/newPage/newPage.jsx');
|
const NewPage = require('./pages/newPage/newPage.jsx');
|
||||||
const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
//const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
||||||
const PrintPage = require('./pages/printPage/printPage.jsx');
|
const PrintPage = require('./pages/printPage/printPage.jsx');
|
||||||
|
|
||||||
let Router;
|
|
||||||
const Homebrew = createClass({
|
const Homebrew = createClass({
|
||||||
getDefaultProps : function() {
|
getDefaultProps : function() {
|
||||||
return {
|
return {
|
||||||
@@ -36,55 +36,36 @@ const Homebrew = createClass({
|
|||||||
global.account = this.props.account;
|
global.account = this.props.account;
|
||||||
global.version = this.props.version;
|
global.version = this.props.version;
|
||||||
|
|
||||||
|
|
||||||
Router = CreateRouter({
|
|
||||||
'/edit/:id' : (args)=>{
|
|
||||||
if(!this.props.brew.editId){
|
|
||||||
return <ErrorPage errorId={args.id}/>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <EditPage
|
|
||||||
id={args.id}
|
|
||||||
brew={this.props.brew} />;
|
|
||||||
},
|
|
||||||
|
|
||||||
'/share/:id' : (args)=>{
|
|
||||||
if(!this.props.brew.shareId){
|
|
||||||
return <ErrorPage errorId={args.id}/>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <SharePage
|
|
||||||
id={args.id}
|
|
||||||
brew={this.props.brew} />;
|
|
||||||
},
|
|
||||||
'/user/:username' : (args)=>{
|
|
||||||
return <UserPage
|
|
||||||
username={args.username}
|
|
||||||
brews={this.props.brews}
|
|
||||||
/>;
|
|
||||||
},
|
|
||||||
'/print/:id' : (args, query)=>{
|
|
||||||
return <PrintPage brew={this.props.brew} query={query}/>;
|
|
||||||
},
|
|
||||||
'/print' : (args, query)=>{
|
|
||||||
return <PrintPage query={query}/>;
|
|
||||||
},
|
|
||||||
'/new' : (args)=>{
|
|
||||||
return <NewPage />;
|
|
||||||
},
|
|
||||||
'/changelog' : (args)=>{
|
|
||||||
return <SharePage
|
|
||||||
brew={{ title: 'Changelog', text: this.props.changelog }} />;
|
|
||||||
},
|
|
||||||
'*' : <HomePage
|
|
||||||
welcomeText={this.props.welcomeText} />,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
render : function(){
|
render : function (){
|
||||||
return <div className='homebrew'>
|
return (
|
||||||
<Router defaultUrl={this.props.url}/>
|
<Router location={this.props.url}>
|
||||||
</div>;
|
<div className='homebrew'>
|
||||||
|
<Switch>
|
||||||
|
<Route path='/edit/:id' component={(routeProps)=><EditPage id={routeProps.match.params.id} brew={this.props.brew} />}/>
|
||||||
|
<Route path='/share/:id' component={(routeProps)=><SharePage id={routeProps.match.params.id} brew={this.props.brew} />}/>
|
||||||
|
<Route path='/user/:username' component={(routeProps)=><UserPage username={routeProps.match.params.username} brews={this.props.brews} />}/>
|
||||||
|
<Route path='/print/:id' component={(routeProps)=><PrintPage brew={this.props.brew} query={queryString.parse(routeProps.location.search)} /> } />
|
||||||
|
<Route path='/print' exact component={(routeProps)=><PrintPage query={queryString.parse(routeProps.location.search)} /> } />
|
||||||
|
<Route path='/new' exact component={NewPage}/>
|
||||||
|
<Route path='/changelog' exact component={()=><SharePage brew={{ title: 'Changelog', text: this.props.changelog }} />}/>
|
||||||
|
<Route path='/' component={()=><HomePage welcomeText={this.props.welcomeText}/>}/>
|
||||||
|
</Switch>
|
||||||
|
</div>
|
||||||
|
</Router>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Homebrew;
|
module.exports = Homebrew;
|
||||||
|
|
||||||
|
//TODO: Nicer Error page instead of just "cant get that"
|
||||||
|
// '/share/:id' : (args)=>{
|
||||||
|
// if(!this.props.brew.shareId){
|
||||||
|
// return <ErrorPage errorId={args.id}/>;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return <SharePage
|
||||||
|
// id={args.id}
|
||||||
|
// brew={this.props.brew} />;
|
||||||
|
// },
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
@import 'naturalcrit/styles/core.less';
|
@import 'naturalcrit/styles/core.less';
|
||||||
.homebrew{
|
.homebrew{
|
||||||
height : 100%;
|
height : 100%;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./navbar.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
require('./editPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
|
const { Meta } = require('vitreum/headtags');
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
@@ -134,7 +136,7 @@ const EditPage = createClass({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
request
|
request
|
||||||
.put(`/api/update/${this.props.brew.editId}`)
|
.put(`/api/${this.props.brew.editId}`)
|
||||||
.send(this.state.brew)
|
.send(this.state.brew)
|
||||||
.end((err, res)=>{
|
.end((err, res)=>{
|
||||||
if(err){
|
if(err){
|
||||||
@@ -202,6 +204,7 @@ const EditPage = createClass({
|
|||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div className='editPage page'>
|
return <div className='editPage page'>
|
||||||
|
<Meta name='robots' content='noindex, nofollow' />
|
||||||
{this.renderNavbar()}
|
{this.renderNavbar()}
|
||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./errorPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
require('./homePage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
|
const { Meta } = require('vitreum/headtags');
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
@@ -72,6 +74,7 @@ const HomePage = createClass({
|
|||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div className='homePage page'>
|
return <div className='homePage page'>
|
||||||
|
<Meta name='google-site-verification' content='NwnAQSSJZzAT7N-p5MY6ydQ7Njm67dtbu73ZSyE5Fy4' />
|
||||||
{this.renderNavbar()}
|
{this.renderNavbar()}
|
||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./newPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
require('./printPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
const { Meta } = require('vitreum/headtags');
|
||||||
const Markdown = require('naturalcrit/markdown.js');
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
|
||||||
const PrintPage = createClass({
|
const PrintPage = createClass({
|
||||||
@@ -42,6 +44,7 @@ const PrintPage = createClass({
|
|||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div>
|
return <div>
|
||||||
|
<Meta name='robots' content='noindex, nofollow' />
|
||||||
{this.renderPages()}
|
{this.renderPages()}
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
require('./sharePage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
const { Meta } = require('vitreum/headtags');
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
@@ -45,6 +47,7 @@ const SharePage = createClass({
|
|||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div className='sharePage page'>
|
return <div className='sharePage page'>
|
||||||
|
<Meta name='robots' content='noindex, nofollow' />
|
||||||
<Navbar>
|
<Navbar>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
|
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./brewItem.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -26,7 +27,7 @@ const BrewItem = createClass({
|
|||||||
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
|
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.get(`/api/remove/${this.props.brew.editId}`)
|
request.delete(`/api/${this.props.brew.editId}`)
|
||||||
.send()
|
.send()
|
||||||
.end(function(err, res){
|
.end(function(err, res){
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./userPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
@import (less) 'shared/naturalcrit/styles/reset.less';
|
@import (less) 'shared/naturalcrit/styles/reset.less';
|
||||||
@import (less) './client/homebrew/phbStyle/phb.fonts.css';
|
@import (less) './client/homebrew/phbStyle/phb.fonts.css';
|
||||||
@import (less) './client/homebrew/phbStyle/phb.assets.less';
|
@import (less) './client/homebrew/phbStyle/phb.assets.less';
|
||||||
@@ -340,7 +339,6 @@ body {
|
|||||||
-webkit-column-break-inside : avoid;
|
-webkit-column-break-inside : avoid;
|
||||||
page-break-inside : avoid;
|
page-break-inside : avoid;
|
||||||
break-inside : avoid;
|
break-inside : avoid;
|
||||||
overflow: hidden; /* Firefox fix */
|
|
||||||
}
|
}
|
||||||
//Better spacing for spell blocks
|
//Better spacing for spell blocks
|
||||||
h4+p+hr+ul{
|
h4+p+hr+ul{
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
module.exports = function(vitreum){
|
module.exports = async (name, props={})=>{
|
||||||
return `
|
return `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
|
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
|
||||||
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
||||||
|
<link href=${`/${name}/bundle.css`} rel='stylesheet'></link>
|
||||||
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
|
||||||
<title>The Homebrewery - NaturalCrit</title>
|
<title>The Homebrewery - NaturalCrit</title>
|
||||||
${vitreum.head}
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main id="reactRoot">${vitreum.body}</main>
|
<main id="reactRoot">${require(`../build/${name}/ssr.js`)(props)}</main>
|
||||||
</body>
|
</body>
|
||||||
${vitreum.js}
|
<script src=${`/${name}/bundle.js`}></script>
|
||||||
|
<script>start_app(${JSON.stringify(props)})</script>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
9585
package-lock.json
generated
9585
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -2,6 +2,9 @@
|
|||||||
"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": "2.8.2",
|
"version": "2.8.2",
|
||||||
|
"engines": {
|
||||||
|
"node": "12.16.x"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/naturalcrit/homebrewery.git"
|
"url": "git://github.com/naturalcrit/homebrewery.git"
|
||||||
@@ -9,7 +12,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node scripts/dev.js",
|
"dev": "node scripts/dev.js",
|
||||||
"quick": "node scripts/quick.js",
|
"quick": "node scripts/quick.js",
|
||||||
"build": "node scripts/build.js",
|
"build": "node scripts/buildHomebrew.js",
|
||||||
|
"buildall": "node scripts/buildHomebrew.js && node scripts/buildAdmin.js",
|
||||||
"lint": "eslint --fix **/*.{js,jsx}",
|
"lint": "eslint --fix **/*.{js,jsx}",
|
||||||
"lint:dry": "eslint **/*.{js,jsx}",
|
"lint:dry": "eslint **/*.{js,jsx}",
|
||||||
"circleci": "npm test && eslint **/*.{js,jsx} --max-warnings=0",
|
"circleci": "npm test && eslint **/*.{js,jsx} --max-warnings=0",
|
||||||
@@ -18,7 +22,7 @@
|
|||||||
"test:dev": "pico-check -v -w",
|
"test:dev": "pico-check -v -w",
|
||||||
"phb": "node scripts/phb.js",
|
"phb": "node scripts/phb.js",
|
||||||
"prod": "set NODE_ENV=production && npm run build",
|
"prod": "set NODE_ENV=production && npm run build",
|
||||||
"postinstall": "npm run build",
|
"postinstall": "npm run buildall",
|
||||||
"start": "node server.js"
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"author": "stolksdorf",
|
"author": "stolksdorf",
|
||||||
@@ -36,30 +40,35 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-preset-env": "^1.7.0",
|
"@babel/core": "^7.11.4",
|
||||||
"babel-preset-react": "^6.24.1",
|
"@babel/preset-env": "^7.11.0",
|
||||||
|
"@babel/preset-react": "^7.10.4",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"codemirror": "^5.52.0",
|
"codemirror": "^5.57.0",
|
||||||
"cookie-parser": "^1.4.4",
|
"cookie-parser": "^1.4.5",
|
||||||
"create-react-class": "^15.6.3",
|
"create-react-class": "^15.6.3",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"fs-extra": "9.0.1",
|
||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
"lodash": "^4.17.15",
|
"less": "^3.12.2",
|
||||||
|
"lodash": "^4.17.20",
|
||||||
"marked": "^0.3.19",
|
"marked": "^0.3.19",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.27.0",
|
||||||
"mongoose": "^5.9.2",
|
"mongoose": "^5.10.0",
|
||||||
"nconf": "^0.10.0",
|
"nconf": "^0.10.0",
|
||||||
"pico-router": "^2.1.0",
|
"prop-types": "15.7.2",
|
||||||
"react": "^16.13.0",
|
"query-string": "6.13.1",
|
||||||
"react-dom": "^16.13.0",
|
"react": "^16.13.1",
|
||||||
|
"react-dom": "^16.13.1",
|
||||||
|
"react-router-dom": "5.2.0",
|
||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
"superagent": "^5.2.2",
|
"superagent": "^6.0.0",
|
||||||
"vitreum": "^4.10.1"
|
"vitreum": "github:calculuschild/vitreum#21a8e1c9421f1d3a3b474c12f480feb2fbd28c5b"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^7.7.0",
|
||||||
"eslint-plugin-react": "^7.19.0",
|
"eslint-plugin-react": "^7.20.6",
|
||||||
"pico-check": "^1.3.2"
|
"pico-check": "^1.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
robots.txt
Normal file
2
robots.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Notes
|
||||||
|
User-agent: *
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
const label = 'build';
|
|
||||||
console.time(label);
|
|
||||||
|
|
||||||
const clean = require('vitreum/steps/clean.js');
|
|
||||||
const jsx = require('vitreum/steps/jsx.js');
|
|
||||||
const lib = require('vitreum/steps/libs.js');
|
|
||||||
const less = require('vitreum/steps/less.js');
|
|
||||||
const asset = require('vitreum/steps/assets.js');
|
|
||||||
|
|
||||||
const Proj = require('./project.json');
|
|
||||||
|
|
||||||
clean()
|
|
||||||
.then(lib(Proj.libs))
|
|
||||||
.then(()=>jsx('homebrew', './client/homebrew/homebrew.jsx', { libs: Proj.libs, shared: ['./shared'] }))
|
|
||||||
.then((deps)=>less('homebrew', { shared: ['./shared'] }, deps))
|
|
||||||
.then(()=>jsx('admin', './client/admin/admin.jsx', { libs: Proj.libs, shared: ['./shared'] }))
|
|
||||||
.then((deps)=>less('admin', { shared: ['./shared'] }, deps))
|
|
||||||
.then(()=>asset(Proj.assets, ['./shared', './client']))
|
|
||||||
.then(console.timeEnd.bind(console, label))
|
|
||||||
.catch(console.error);
|
|
||||||
31
scripts/buildAdmin.js
Normal file
31
scripts/buildAdmin.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
const fs = require('fs-extra');
|
||||||
|
const Proj = require('./project.json');
|
||||||
|
|
||||||
|
const { pack } = require('vitreum');
|
||||||
|
const isDev = !!process.argv.find((arg)=>arg=='--dev');
|
||||||
|
|
||||||
|
const lessTransform = require('vitreum/transforms/less.js');
|
||||||
|
const assetTransform = require('vitreum/transforms/asset.js');
|
||||||
|
//const Meta = require('vitreum/headtags');
|
||||||
|
|
||||||
|
const transforms = {
|
||||||
|
'.less' : lessTransform,
|
||||||
|
'*' : assetTransform('./build')
|
||||||
|
};
|
||||||
|
|
||||||
|
const build = async ({ bundle, render, ssr })=>{
|
||||||
|
await fs.outputFile('./build/admin/bundle.css', await lessTransform.generate({ paths: './shared' }));
|
||||||
|
await fs.outputFile('./build/admin/bundle.js', bundle);
|
||||||
|
await fs.outputFile('./build/admin/ssr.js', ssr);
|
||||||
|
await fs.outputFile('./build/admin/render.js', render);
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.emptyDirSync('./build/admin');
|
||||||
|
pack('./client/admin/admin.jsx', {
|
||||||
|
paths : ['./shared'],
|
||||||
|
libs : Proj.libs,
|
||||||
|
dev : isDev && build,
|
||||||
|
transforms
|
||||||
|
})
|
||||||
|
.then(build)
|
||||||
|
.catch(console.error);
|
||||||
31
scripts/buildHomebrew.js
Normal file
31
scripts/buildHomebrew.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
const fs = require('fs-extra');
|
||||||
|
const Proj = require('./project.json');
|
||||||
|
|
||||||
|
const { pack } = require('vitreum');
|
||||||
|
const isDev = !!process.argv.find((arg)=>arg=='--dev');
|
||||||
|
|
||||||
|
const lessTransform = require('vitreum/transforms/less.js');
|
||||||
|
const assetTransform = require('vitreum/transforms/asset.js');
|
||||||
|
//const Meta = require('vitreum/headtags');
|
||||||
|
|
||||||
|
const transforms = {
|
||||||
|
'.less' : lessTransform,
|
||||||
|
'*' : assetTransform('./build')
|
||||||
|
};
|
||||||
|
|
||||||
|
const build = async ({ bundle, render, ssr })=>{
|
||||||
|
await fs.outputFile('./build/homebrew/bundle.css', await lessTransform.generate({ paths: './shared' }));
|
||||||
|
await fs.outputFile('./build/homebrew/bundle.js', bundle);
|
||||||
|
await fs.outputFile('./build/homebrew/ssr.js', ssr);
|
||||||
|
await fs.outputFile('./build/homebrew/render.js', render);
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.emptyDirSync('./build/homebrew');
|
||||||
|
pack('./client/homebrew/homebrew.jsx', {
|
||||||
|
paths : ['./shared'],
|
||||||
|
libs : Proj.libs,
|
||||||
|
dev : isDev && build,
|
||||||
|
transforms
|
||||||
|
})
|
||||||
|
.then(build)
|
||||||
|
.catch(console.error);
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
"codemirror/mode/javascript/javascript.js",
|
"codemirror/mode/javascript/javascript.js",
|
||||||
"moment",
|
"moment",
|
||||||
"superagent",
|
"superagent",
|
||||||
"marked",
|
"marked"
|
||||||
"pico-router"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
26
server.js
26
server.js
@@ -44,9 +44,14 @@ const HomebrewModel = require('./server/homebrew.model.js').model;
|
|||||||
const welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
|
const welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
|
||||||
const changelogText = require('fs').readFileSync('./changelog.md', 'utf8');
|
const changelogText = require('fs').readFileSync('./changelog.md', 'utf8');
|
||||||
|
|
||||||
|
String.prototype.replaceAll = function(s, r){return this.split(s).join(r);};
|
||||||
|
|
||||||
|
//Robots.txt
|
||||||
|
app.get('/robots.txt', (req, res)=>{
|
||||||
|
return res.sendFile(`${__dirname}/robots.txt`);
|
||||||
|
});
|
||||||
|
|
||||||
//Source page
|
//Source page
|
||||||
String.prototype.replaceAll = function(s, r){return this.split(s).join(r);};
|
|
||||||
app.get('/source/:id', (req, res)=>{
|
app.get('/source/:id', (req, res)=>{
|
||||||
HomebrewModel.get({ shareId: req.params.id })
|
HomebrewModel.get({ shareId: req.params.id })
|
||||||
.then((brew)=>{
|
.then((brew)=>{
|
||||||
@@ -59,7 +64,7 @@ app.get('/source/:id', (req, res)=>{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//User Page
|
||||||
app.get('/user/:username', (req, res, next)=>{
|
app.get('/user/:username', (req, res, next)=>{
|
||||||
const fullAccess = req.account && (req.account.username == req.params.username);
|
const fullAccess = req.account && (req.account.username == req.params.username);
|
||||||
HomebrewModel.getByUser(req.params.username, fullAccess)
|
HomebrewModel.getByUser(req.params.username, fullAccess)
|
||||||
@@ -72,7 +77,7 @@ app.get('/user/:username', (req, res, next)=>{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Edit Page
|
||||||
app.get('/edit/:id', (req, res, next)=>{
|
app.get('/edit/:id', (req, res, next)=>{
|
||||||
HomebrewModel.get({ editId: req.params.id })
|
HomebrewModel.get({ editId: req.params.id })
|
||||||
.then((brew)=>{
|
.then((brew)=>{
|
||||||
@@ -115,22 +120,21 @@ app.get('/print/:id', (req, res, next)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Render Page
|
//Render the page
|
||||||
const render = require('vitreum/steps/render');
|
//const render = require('.build/render');
|
||||||
const templateFn = require('./client/template.js');
|
const templateFn = require('./client/template.js');
|
||||||
app.use((req, res)=>{
|
app.use((req, res)=>{
|
||||||
render('homebrew', templateFn, {
|
const props = {
|
||||||
version : require('./package.json').version,
|
version : require('./package.json').version,
|
||||||
url : req.originalUrl,
|
url : req.originalUrl,
|
||||||
welcomeText : welcomeText,
|
welcomeText : welcomeText,
|
||||||
changelog : changelogText,
|
changelog : changelogText,
|
||||||
brew : req.brew,
|
brew : req.brew,
|
||||||
brews : req.brews,
|
brews : req.brews,
|
||||||
account : req.account
|
account : req.account,
|
||||||
})
|
};
|
||||||
.then((page)=>{
|
templateFn('homebrew', props)
|
||||||
return res.send(page);
|
.then((page)=>res.send(page))
|
||||||
})
|
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return res.sendStatus(500);
|
return res.sendStatus(500);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const HomebrewModel = require('./homebrew.model.js').model;
|
const HomebrewModel = require('./homebrew.model.js').model;
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
const Moment = require('moment');
|
const Moment = require('moment');
|
||||||
const render = require('vitreum/steps/render');
|
//const render = require('vitreum/steps/render');
|
||||||
const templateFn = require('../client/template.js');
|
const templateFn = require('../client/template.js');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ router.get('/admin/stats', mw.adminOnly, (req, res)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get('/admin', mw.adminOnly, (req, res)=>{
|
router.get('/admin', mw.adminOnly, (req, res)=>{
|
||||||
render('admin', templateFn, {
|
templateFn('admin', {
|
||||||
url : req.originalUrl
|
url : req.originalUrl
|
||||||
})
|
})
|
||||||
.then((page)=>res.send(page))
|
.then((page)=>res.send(page))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports = (req, res, next)=>{
|
module.exports = (req, res, next)=>{
|
||||||
if(process.env.NODE_ENV === 'local') return next();
|
if(process.env.NODE_ENV === 'local' || process.env.NODE_ENV === 'docker') return next();
|
||||||
if(req.header('x-forwarded-proto') !== 'https') {
|
if(req.header('x-forwarded-proto') !== 'https') {
|
||||||
return res.redirect(302, `https://${req.get('Host')}${req.url}`);
|
return res.redirect(302, `https://${req.get('Host')}${req.url}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const HomebrewModel = require('./homebrew.model.js').model;
|
|||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
|
|
||||||
// const getTopBrews = (cb)=>{
|
// const getTopBrews = (cb) => {
|
||||||
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
|
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
|
||||||
// cb(brews);
|
// cb(brews);
|
||||||
// });
|
// });
|
||||||
@@ -11,53 +11,53 @@ const zlib = require('zlib');
|
|||||||
|
|
||||||
const getGoodBrewTitle = (text)=>{
|
const getGoodBrewTitle = (text)=>{
|
||||||
const titlePos = text.indexOf('# ');
|
const titlePos = text.indexOf('# ');
|
||||||
if(titlePos !== -1){
|
if(titlePos !== -1) {
|
||||||
const ending = text.indexOf('\n', titlePos);
|
const ending = text.indexOf('\n', titlePos);
|
||||||
return text.substring(titlePos + 2, ending);
|
return text.substring(titlePos + 2, ending);
|
||||||
} else {
|
} else {
|
||||||
return _.find(text.split('\n'), (line)=>{
|
return _.find(text.split('\n'), (line)=>line);
|
||||||
return line;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const newBrew = (req, res)=>{
|
||||||
|
const authors = (req.account) ? [req.account.username] : [];
|
||||||
router.post('/api', (req, res)=>{
|
|
||||||
|
|
||||||
let authors = [];
|
|
||||||
if(req.account) authors = [req.account.username];
|
|
||||||
|
|
||||||
const newHomebrew = new HomebrewModel(_.merge({},
|
const newHomebrew = new HomebrewModel(_.merge({},
|
||||||
req.body,
|
req.body,
|
||||||
{ authors: authors }
|
{ authors: authors }
|
||||||
));
|
));
|
||||||
|
|
||||||
if(!newHomebrew.title){
|
if(!newHomebrew.title) {
|
||||||
newHomebrew.title = getGoodBrewTitle(newHomebrew.text);
|
newHomebrew.title = getGoodBrewTitle(newHomebrew.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
newHomebrew.textBin = zlib.deflateRawSync(newHomebrew.text); // Compress brew text to binary before saving
|
// Compress brew text to binary before saving
|
||||||
newHomebrew.text = undefined; // Delete the non-binary text field since it's not needed anymore
|
newHomebrew.textBin = zlib.deflateRawSync(newHomebrew.text);
|
||||||
|
// Delete the non-binary text field since it's not needed anymore
|
||||||
|
newHomebrew.text = undefined;
|
||||||
|
|
||||||
newHomebrew.save((err, obj)=>{
|
newHomebrew.save((err, obj)=>{
|
||||||
if(err){
|
if(err) {
|
||||||
console.error(err, err.toString(), err.stack);
|
console.error(err, err.toString(), err.stack);
|
||||||
return res.status(500).send(`Error while creating new brew, ${err.toString()}`);
|
return res.status(500).send(`Error while creating new brew, ${err.toString()}`);
|
||||||
}
|
}
|
||||||
return res.json(obj);
|
return res.json(obj);
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
router.put('/api/update/:id', (req, res)=>{
|
const updateBrew = (req, res)=>{
|
||||||
HomebrewModel.get({ editId: req.params.id })
|
HomebrewModel.get({ editId: req.params.id })
|
||||||
.then((brew)=>{
|
.then((brew)=>{
|
||||||
brew = _.merge(brew, req.body);
|
brew = _.merge(brew, req.body);
|
||||||
brew.textBin = zlib.deflateRawSync(req.body.text); // Compress brew text to binary before saving
|
// Compress brew text to binary before saving
|
||||||
brew.text = undefined; // Delete the non-binary text field since it's not needed anymore
|
brew.textBin = zlib.deflateRawSync(req.body.text);
|
||||||
|
// Delete the non-binary text field since it's not needed anymore
|
||||||
|
brew.text = undefined;
|
||||||
brew.updatedAt = new Date();
|
brew.updatedAt = new Date();
|
||||||
|
|
||||||
if(req.account) brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
|
if(req.account) {
|
||||||
|
brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
|
||||||
|
}
|
||||||
|
|
||||||
brew.markModified('authors');
|
brew.markModified('authors');
|
||||||
brew.markModified('systems');
|
brew.markModified('systems');
|
||||||
@@ -68,62 +68,63 @@ router.put('/api/update/:id', (req, res)=>{
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
console.error(err);
|
||||||
return res.status(500).send('Error while saving');
|
return res.status(500).send('Error while saving');
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
router.get('/api/remove/:id', (req, res)=>{
|
const deleteBrew = (req, res)=>{
|
||||||
HomebrewModel.find({ editId: req.params.id }, (err, objs)=>{
|
HomebrewModel.find({ editId: req.params.id }, (err, objs)=>{
|
||||||
if(!objs.length || err) return res.status(404).send('Can not find homebrew with that id');
|
if(!objs.length || err) {
|
||||||
|
return res.status(404).send('Can not find homebrew with that id');
|
||||||
|
}
|
||||||
|
|
||||||
const brew = objs[0];
|
const brew = objs[0];
|
||||||
|
|
||||||
// Remove current user as author
|
if(req.account) {
|
||||||
if(req.account){
|
// Remove current user as author
|
||||||
brew.authors = _.pull(brew.authors, req.account.username);
|
brew.authors = _.pull(brew.authors, req.account.username);
|
||||||
brew.markModified('authors');
|
brew.markModified('authors');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete brew if there are no authors left
|
if(brew.authors.length === 0) {
|
||||||
if(!brew.authors.length)
|
// Delete brew if there are no authors left
|
||||||
brew.remove((err)=>{
|
brew.remove((err)=>{
|
||||||
if(err) return res.status(500).send('Error while removing');
|
if(err) return res.status(500).send('Error while removing');
|
||||||
return res.status(200).send();
|
return res.status(200).send();
|
||||||
});
|
});
|
||||||
// Otherwise, save the brew with updated author list
|
} else {
|
||||||
else
|
// Otherwise, save the brew with updated author list
|
||||||
brew.save((err, savedBrew)=>{
|
brew.save((err, savedBrew)=>{
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
return res.status(200).send(savedBrew);
|
return res.status(200).send(savedBrew);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
router.post('/api', newBrew);
|
||||||
|
router.put('/api/:id', updateBrew);
|
||||||
|
router.put('/api/update/:id', updateBrew);
|
||||||
|
router.delete('/api/:id', deleteBrew);
|
||||||
|
router.get('/api/remove/:id', deleteBrew);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
module.exports = function(app) {
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(app){
|
|
||||||
|
|
||||||
app;
|
app;
|
||||||
|
|
||||||
|
app.get('/api/search', mw.adminOnly, function(req, res) {
|
||||||
|
|
||||||
|
|
||||||
app.get('/api/search', mw.adminOnly, function(req, res){
|
|
||||||
|
|
||||||
var page = req.query.page || 0;
|
var page = req.query.page || 0;
|
||||||
var count = req.query.count || 20;
|
var count = req.query.count || 20;
|
||||||
|
|
||||||
var query = {};
|
var query = {};
|
||||||
if(req.query && req.query.id){
|
if (req.query && req.query.id) {
|
||||||
query = {
|
query = {
|
||||||
"$or" : [{
|
"$or": [{
|
||||||
editId : req.query.id
|
editId : req.query.id
|
||||||
},{
|
}, {
|
||||||
shareId : req.query.id
|
shareId : req.query.id
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
@@ -134,21 +135,17 @@ module.exports = function(app){
|
|||||||
}, {
|
}, {
|
||||||
skip: page*count,
|
skip: page*count,
|
||||||
limit: count*1
|
limit: count*1
|
||||||
}, function(err, objs){
|
}, function(err, objs) {
|
||||||
if(err) console.log(err);
|
if (err) console.error(err);
|
||||||
return res.json({
|
return res.json({
|
||||||
page : page,
|
page : page,
|
||||||
count : count,
|
count : count,
|
||||||
total : homebrewTotal,
|
total : homebrewTotal,
|
||||||
brews : objs
|
brews : objs
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
require('./renderWarnings.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -25,10 +25,10 @@ const RenderWarnings = createClass({
|
|||||||
if(!isChrome){
|
if(!isChrome){
|
||||||
return <li key='chrome'>
|
return <li key='chrome'>
|
||||||
<em>Built for Chrome </em> <br />
|
<em>Built for Chrome </em> <br />
|
||||||
Other browsers do not support
|
Other browsers have not been tested for compatiblilty. If you
|
||||||
<a target='_blank' href='https://developer.mozilla.org/en-US/docs/Web/CSS/column-span#Browser_compatibility'>
|
experience issues with your document not rendering or printing
|
||||||
key features
|
properly, please try using the latest version of Chrome before
|
||||||
</a> this site uses.
|
submitting a bug report.
|
||||||
</li>;
|
</li>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./codeEditor.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./nav.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//@import (less) 'naturalcrit/styles/style.fonts.css';
|
||||||
nav{
|
nav{
|
||||||
background-color : #333;
|
background-color : #333;
|
||||||
.navContent{
|
.navContent{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require('./splitPane.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
@import 'naturalcrit/styles/colors.less';
|
@import 'naturalcrit/styles/colors.less';
|
||||||
@import 'naturalcrit/styles/tooltip.less';
|
@import 'naturalcrit/styles/tooltip.less';
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family : CodeLight;
|
font-family : 'CodeLight';
|
||||||
src : url('/assets/naturalcrit/styles/CODE Light.otf');
|
src : data-uri('naturalcrit/styles/CODE Light.otf') format('opentype');
|
||||||
}
|
}
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family : CodeBold;
|
font-family : 'CodeBold';
|
||||||
src : url('/assets/naturalcrit/styles/CODE Bold.otf');
|
src : data-uri('naturalcrit/styles/CODE Bold.otf') format('opentype');
|
||||||
}
|
}
|
||||||
html,body, #reactRoot{
|
html,body, #reactRoot{
|
||||||
height : 100vh;
|
height : 100vh;
|
||||||
|
|||||||
Reference in New Issue
Block a user