mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-25 18:23:01 +00:00
Compare commits
1 Commits
3.1.1
...
TestReactF
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f3388c687 |
@@ -2,23 +2,17 @@
|
|||||||
#
|
#
|
||||||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
||||||
#
|
#
|
||||||
version: 2.1
|
version: 2
|
||||||
|
|
||||||
orbs:
|
|
||||||
node: circleci/node@3.0.0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/node:16.11.0
|
- image: circleci/node:16.10.0
|
||||||
- image: mongo:4.4
|
- image: circleci/mongo:4.4
|
||||||
|
|
||||||
working_directory: ~/homebrewery
|
working_directory: ~/repo
|
||||||
executor: node/default
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- checkout:
|
- checkout
|
||||||
path: ~/homebrewery
|
|
||||||
|
|
||||||
# Download and cache dependencies
|
# Download and cache dependencies
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -27,48 +21,12 @@ jobs:
|
|||||||
# fallback to using the latest cache if no exact match is found
|
# fallback to using the latest cache if no exact match is found
|
||||||
- v1-dependencies-
|
- v1-dependencies-
|
||||||
|
|
||||||
- node/install-npm
|
- run: npm install
|
||||||
- node/install-packages:
|
|
||||||
app-dir: ~/homebrewery
|
|
||||||
cache-path: node_modules
|
|
||||||
override-ci-command: npm i
|
|
||||||
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
paths:
|
paths:
|
||||||
- node_modules
|
- node_modules
|
||||||
key: v1-dependencies-{{ checksum "package.json" }}
|
key: v1-dependencies-{{ checksum "package.json" }}
|
||||||
|
|
||||||
- persist_to_workspace:
|
|
||||||
root: .
|
|
||||||
paths:
|
|
||||||
- .
|
|
||||||
|
|
||||||
test:
|
|
||||||
docker:
|
|
||||||
- image: cimg/node:16.11.0
|
|
||||||
|
|
||||||
working_directory: ~/homebrewery
|
|
||||||
parallelism: 4
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- attach_workspace:
|
|
||||||
at: .
|
|
||||||
|
|
||||||
# run tests!
|
# run tests!
|
||||||
- run:
|
- run: npm run circleci
|
||||||
name: Test - Basic
|
|
||||||
command: npm run test:basic
|
|
||||||
- run:
|
|
||||||
name: Test - Mustache Spans
|
|
||||||
command: npm run test:mustache-span
|
|
||||||
- run:
|
|
||||||
name: Test - Routes
|
|
||||||
command: npm run test:route
|
|
||||||
|
|
||||||
workflows:
|
|
||||||
build_and_test:
|
|
||||||
jobs:
|
|
||||||
- build
|
|
||||||
- test:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
|
|||||||
57
README.md
57
README.md
@@ -9,37 +9,37 @@ using [Markdown][markdown-url]. It is distributed under the terms of the [MIT Li
|
|||||||
[markdown-url]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
|
[markdown-url]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
The easiest way to get started using The Homebrewery is to use it
|
The easiest way to get started using the Homebrewery is to use it
|
||||||
[on our website][homebrewery-url]. The code is open source, so feel free to
|
[on our website][homebrewery-url]. The code is open source, so feel free to
|
||||||
clone it and tinker with it. If you want to make changes to the code, you can run
|
clone it, tinker with it. If you want to make changes to the code, you can run
|
||||||
your own local version for testing by following the installation instructions
|
your own local version for testing by following the installation instructions
|
||||||
below.
|
below.
|
||||||
|
|
||||||
[homebrewery-url]: https://homebrewery.naturalcrit.com
|
[homebrewery-url]: https://homebrewery.naturalcrit.com
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
First, install three programs that The Homebrewery requires to run and retrieve
|
First, install three programs that the Homebrewery requires to run and retrieve
|
||||||
updates:
|
updates:
|
||||||
|
|
||||||
1. install [node](https://nodejs.org/en/)
|
1. install [node](https://nodejs.org/en/)
|
||||||
1. install [mongodb](https://www.mongodb.com/try/download/community) (Community version)
|
1. install [mongodb](https://www.mongodb.com/try/download/community) (Community version)
|
||||||
|
|
||||||
For the easiest installation, follow these steps:
|
For easiest installation, follow these steps:
|
||||||
1. In the installer, uncheck the option to run as a service.
|
1. In the installer, uncheck the option to run as a service
|
||||||
1. You can install MongoDB Compass if you want a GUI to view your database documents.
|
1. You can install MongoDB Compass if you want a GUI to view your database documents
|
||||||
1. Go to the C:\ drive and create a folder called "data".
|
1. Go to the C drive and create a folder called "data"
|
||||||
1. Inside the "data" folder, create a new folder called "db".
|
1. Inside the "data" folder, create a new folder called "db"
|
||||||
1. Open a command prompt or other terminal and navigate to your MongoDB install folder (C:\Program Files\Mongo\Server\4.4\bin).
|
1. Open a command prompt or other terminal and navigate to your mongodb install folder (c:program files\mongo\server\4.4\bin)
|
||||||
1. In the command prompt, run "mongod", which will start up your local database server.
|
1. In the command prompt, run "mongod", which will start up your local database server
|
||||||
1. While MongoD is running, open a second command prompt and navigate to the MongoDB install folder.
|
1. While MongoD is running, open a second command prompt and navigate to the mongodb install folder
|
||||||
1. In the second command prompt, run "mongo", which allows you to edit the database.
|
1. In the second command prompt, run "mongo", which allows you to edit the database
|
||||||
1. Type `use homebrewery` to create The Homebrewery database. You should see `switched to db homebrewery`.
|
1. Type `use homebrewery` to create the homebrewery database. You should see `switched to db homebrewery`
|
||||||
1. Type `db.brews.insert({"title":"test"})` to create a blank document. You should see `WriteResult({ "nInserted" : 1 })`.
|
1. Type `db.brews.insert({"title":"test"})` to create a blank document. You should see `WriteResult({ "nInserted" : 1 })`
|
||||||
1. Search in Windows for "Advanced system settings" and open it.
|
1. Search in Windows for "Advanced system settings" and open it
|
||||||
1. Click "Environment variables", find the "path" variable, and double-click to open it.
|
1. Click "Environment variables", find the "path" variable, and double-click to open it
|
||||||
1. Click "New" and paste in the path to the MongoDB "bin" folder.
|
1. Click "New" and paste in the path to the mongodb "bin" folder
|
||||||
1. Click "OK" three times to close all the windows.
|
1. Click "OK", "OK", "OK" to close all the windows
|
||||||
1. install [git](https://git-scm.com/downloads) (select the option that allows Git to run from the command prompt).
|
1. install [git](https://git-scm.com/downloads) (select the option that allows Git to run from the command prompt)
|
||||||
|
|
||||||
Checkout the repo ([documentation][github-clone-repo-docs-url]):
|
Checkout the repo ([documentation][github-clone-repo-docs-url]):
|
||||||
```
|
```
|
||||||
@@ -54,7 +54,7 @@ the project to run locally.
|
|||||||
You can set this temporarily in your shell of choice:
|
You can set this temporarily in your shell of choice:
|
||||||
* Windows Powershell: `$env:NODE_ENV="local"`
|
* Windows Powershell: `$env:NODE_ENV="local"`
|
||||||
* Windows CMD: `set NODE_ENV=local`
|
* Windows CMD: `set NODE_ENV=local`
|
||||||
* Linux / macOS: `export NODE_ENV=local`
|
* Linux / OSX: `export NODE_ENV=local`
|
||||||
|
|
||||||
Third, you will need to install the Node dependencies, compile the app, and run
|
Third, you will need to install the Node dependencies, compile the app, and run
|
||||||
it using the two commands:
|
it using the two commands:
|
||||||
@@ -63,7 +63,7 @@ it using the two commands:
|
|||||||
1. `npm start`
|
1. `npm start`
|
||||||
|
|
||||||
You should now be able to go to [http://localhost:8000](http://localhost:8000)
|
You should now be able to go to [http://localhost:8000](http://localhost:8000)
|
||||||
in your browser and use The Homebrewery offline.
|
in your browser and use the Homebrewery offline.
|
||||||
|
|
||||||
### Running the application via Docker
|
### Running the application via Docker
|
||||||
|
|
||||||
@@ -95,11 +95,11 @@ You can check out the [changelog](./changelog.md).
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under the [MIT license](./license), which means you
|
This project is licensed under the [MIT license](./license). Which means you
|
||||||
are free to use The Homebrewery in any way that you want, except for claiming
|
are free to use The Homebrewery in any way that you want, except for claiming
|
||||||
that you made it yourself.
|
that you made it yourself.
|
||||||
|
|
||||||
If you wish to sell, or in some way gain profit for, what's created on this site,
|
If you wish to sell or in some way gain profit for what's created on this site,
|
||||||
it's your responsibility to ensure you have the proper licenses/rights for any
|
it's your responsibility to ensure you have the proper licenses/rights for any
|
||||||
images or resources used.
|
images or resources used.
|
||||||
|
|
||||||
@@ -108,12 +108,13 @@ images or resources used.
|
|||||||
You are welcome to contribute to the development and maintenance of the
|
You are welcome to contribute to the development and maintenance of the
|
||||||
project! There are several ways of doing that:
|
project! There are several ways of doing that:
|
||||||
- At the moment, we have a huge backlog of [issues][repo-issues-url] and some
|
- At the moment, we have a huge backlog of [issues][repo-issues-url] and some
|
||||||
of them are outdated, duplicates, or don't contain any useful info. To help, you can [mark duplicates][github-mark-duplicate-url], try to
|
of them are outdated, duplicates or doesn't contain any useful info. In order
|
||||||
reproduce some complex or weird issues, try finding a workaround for a
|
to help you can [mark duplicates][github-mark-duplicate-url], try to
|
||||||
reported bug, or just mention our issue managers team to let them know about
|
reproduce some complex or weird issues, try with finding a workaround for a
|
||||||
outdated issues via `@naturalcrit/issue-managers`.
|
reported bug or just mention issue managers team to let them know about
|
||||||
|
outdated issue via `@naturalcrit/issue-managers`.
|
||||||
- Our [subreddit][subreddit-url] is constantly growing and there are number of
|
- Our [subreddit][subreddit-url] is constantly growing and there are number of
|
||||||
bug reports. Any help with sorting them out is very welcome.
|
bug reports: any help with sorting them out is very welcome.
|
||||||
- And of course you can contribute by fixing a bug or implementing a new
|
- And of course you can contribute by fixing a bug or implementing a new
|
||||||
feature by yourself, we are waiting for your
|
feature by yourself, we are waiting for your
|
||||||
[pull requests][github-pr-docs-url]!
|
[pull requests][github-pr-docs-url]!
|
||||||
|
|||||||
101
changelog.md
101
changelog.md
@@ -29,114 +29,21 @@ pre {
|
|||||||
.page p + pre {
|
.page p + pre {
|
||||||
margin-top : 0.1cm;
|
margin-top : 0.1cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page .openSans {
|
|
||||||
font-family: 'Open Sans';
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 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).
|
||||||
|
|
||||||
### Thursday 09/06/2022 - v3.1.1
|
|
||||||
{{taskList
|
|
||||||
|
|
||||||
##### Calculuschild:
|
|
||||||
|
|
||||||
* [x] Fixed class table decorations appearing on top of the table in PDF output.
|
|
||||||
|
|
||||||
Fixes issues: [#1784](https://github.com/naturalcrit/homebrewery/issues/1784)
|
|
||||||
|
|
||||||
* [x] Fix bottom decoration on half class tables disappearing when the table is too short.
|
|
||||||
|
|
||||||
Fixes issues: [#2202](https://github.com/naturalcrit/homebrewery/issues/2202)
|
|
||||||
}}
|
|
||||||
|
|
||||||
### Monday 06/06/2022 - v3.1.0
|
|
||||||
{{taskList
|
|
||||||
|
|
||||||
##### G-Ambatte:
|
|
||||||
|
|
||||||
* [x] "Jump to Preview/Editor" buttons added to the divider bar. Easily sync between the editor and preview panels!
|
|
||||||
|
|
||||||
Fixes issues: [#1756](https://github.com/naturalcrit/homebrewery/issues/1756)
|
|
||||||
|
|
||||||
* [x] Speedups to the user page for users with large and/or many brews.
|
|
||||||
|
|
||||||
Fixes issues: [#2147](https://github.com/naturalcrit/homebrewery/issues/2147)
|
|
||||||
|
|
||||||
* [x] Search text on the user page is saved to the URL for easy bookmarking in your browser
|
|
||||||
|
|
||||||
Fixes issues: [#1858](https://github.com/naturalcrit/homebrewery/issues/1858)
|
|
||||||
|
|
||||||
* [x] Added easy login system for offline installs.
|
|
||||||
|
|
||||||
Fixes issues: [#269](https://github.com/naturalcrit/homebrewery/issues/269)
|
|
||||||
|
|
||||||
* [x] New **THUMBNAIL** option in the {{fa,fa-info-circle}} **Properties** menu. This image will show up in social media links.
|
|
||||||
|
|
||||||
Fixes issues: [#820](https://github.com/naturalcrit/homebrewery/issues/820)
|
|
||||||
}}
|
|
||||||
|
|
||||||
### Wednesday 27/03/2022 - v3.0.8
|
|
||||||
{{taskList
|
|
||||||
* [x] Style updates to user page.
|
|
||||||
|
|
||||||
* [x] Added a logout button (finally)! You can find it under {{openSans **USERNAME {{fa,fa-user}} → LOGOUT {{fas,fa-power-off}}**}}
|
|
||||||
|
|
||||||
Fixes issues: [#303](https://github.com/naturalcrit/homebrewery/issues/303)
|
|
||||||
|
|
||||||
* [x] Clarified the default text when submitting an issue via Reddit post.
|
|
||||||
|
|
||||||
* [x] Fixed broken Table of Contents links in PDFs. (Thanks lucastucious!)
|
|
||||||
|
|
||||||
Fixes issues: [#1749](https://github.com/naturalcrit/homebrewery/issues/1749)
|
|
||||||
|
|
||||||
* [x] Fixed window resizing causing the edit page divider to get lost off of the edge of the page.
|
|
||||||
|
|
||||||
Fixes issues: [#2053](https://github.com/naturalcrit/homebrewery/issues/2053)
|
|
||||||
|
|
||||||
* [x] Fixed Class Table decorations overlapping main text.
|
|
||||||
|
|
||||||
Fixes issues: [#1985](https://github.com/naturalcrit/homebrewery/issues/1985)
|
|
||||||
|
|
||||||
* [x] Updated {{openSans **STYLE EDITOR {{fa,fa-pencil-alt}} → REMOVE DROP CAP {{fas,fa-remove-format}}**}} snippet to also remove small-caps first line font.
|
|
||||||
|
|
||||||
* [x] Background work in preparation for brew themes.
|
|
||||||
}}
|
|
||||||
|
|
||||||
### Wednesday 02/02/2022 - v3.0.7
|
|
||||||
{{taskList
|
|
||||||
* [x] Revert active line highlighting.
|
|
||||||
|
|
||||||
Fixes issues: [#1913](https://github.com/naturalcrit/homebrewery/issues/1913)
|
|
||||||
|
|
||||||
* [x] Added install steps for Ubuntu. [HERE](https://github.com/naturalcrit/homebrewery/blob/master/install/README.UBUNTU.md)
|
|
||||||
|
|
||||||
Fixes issues: [#1900](https://github.com/naturalcrit/homebrewery/issues/1900)
|
|
||||||
|
|
||||||
* [x] Added social media links to home page.
|
|
||||||
|
|
||||||
* [x] Increase brews visible on the user page to 1,000.
|
|
||||||
|
|
||||||
Fixes issues: [#1943](https://github.com/naturalcrit/homebrewery/issues/1943)
|
|
||||||
|
|
||||||
* [x] Added a Legacy to V3 migration guide under {{openSans **NEED HELP? {{fa,fa-question-circle}} → MIGRATE {{fas,fa-file-import}}**}}
|
|
||||||
|
|
||||||
* [x] Background refactoring and unit tests.
|
|
||||||
}}
|
|
||||||
|
|
||||||
### Saturday 18/12/2021 - v3.0.6
|
### Saturday 18/12/2021 - v3.0.6
|
||||||
{{taskList
|
{{taskList
|
||||||
* [x] Fixed text wrapping for long strings in code blocks.
|
* [x] Fixed text wrapping for long strings in code blocks.
|
||||||
|
|
||||||
Fixes issues: [#1736](https://github.com/naturalcrit/homebrewery/issues/1736)
|
Fixes issues: [#1736](https://github.com/naturalcrit/homebrewery/issues/1736)
|
||||||
|
|
||||||
* [x] Code search/replace PC: `CTRL F / CTRL SHIFT F` / Mac: `CMD F / OPTION CMD F`
|
* [x] Code search/replace `CTRL F / CTRL SHIFT F`
|
||||||
|
|
||||||
Fixes issues: [#1201](https://github.com/naturalcrit/homebrewery/issues/1201)
|
Fixes issues: [#1201](https://github.com/naturalcrit/homebrewery/issues/1201)
|
||||||
|
|
||||||
* [x] Auto-closing HTML tags and curly braces `{{ }}`
|
* [x] Auto-closing HTML tags and curly braces `{{ }}`
|
||||||
* [x] Highlight current active line
|
* [x] Highlight current active line
|
||||||
|
|
||||||
@@ -149,7 +56,7 @@ For a full record of development, visit our [Github Page](https://github.com/nat
|
|||||||
* [x] Make columns even in V3 Table of Contents.
|
* [x] Make columns even in V3 Table of Contents.
|
||||||
|
|
||||||
Fixes issues: [#1671](https://github.com/naturalcrit/homebrewery/issues/1671)
|
Fixes issues: [#1671](https://github.com/naturalcrit/homebrewery/issues/1671)
|
||||||
|
|
||||||
* [x] Fix `CTRL P` failing to print from `/new` pages.
|
* [x] Fix `CTRL P` failing to print from `/new` pages.
|
||||||
|
|
||||||
Fixes issues: [#1815](https://github.com/naturalcrit/homebrewery/issues/1815)
|
Fixes issues: [#1815](https://github.com/naturalcrit/homebrewery/issues/1815)
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ const BrewRenderer = createClass({
|
|||||||
</div>
|
</div>
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
<Frame id='BrewRenderer' initialContent={this.state.initialContent}
|
<Frame initialContent={this.state.initialContent}
|
||||||
style={{ width: '100%', height: '100%', visibility: this.state.visibility }}
|
style={{ width: '100%', height: '100%', visibility: this.state.visibility }}
|
||||||
contentDidMount={this.frameDidMount}>
|
contentDidMount={this.frameDidMount}>
|
||||||
<div className={'brewRenderer'}
|
<div className={'brewRenderer'}
|
||||||
|
|||||||
@@ -61,14 +61,8 @@ const Editor = createClass({
|
|||||||
window.removeEventListener('resize', this.updateEditorSize);
|
window.removeEventListener('resize', this.updateEditorSize);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate : function(prevProps, prevState, snapshot) {
|
componentDidUpdate : function() {
|
||||||
this.highlightCustomMarkdown();
|
this.highlightCustomMarkdown();
|
||||||
if(prevProps.moveBrew !== this.props.moveBrew) {
|
|
||||||
this.brewJump();
|
|
||||||
};
|
|
||||||
if(prevProps.moveSource !== this.props.moveSource) {
|
|
||||||
this.sourceJump();
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateEditorSize : function() {
|
updateEditorSize : function() {
|
||||||
@@ -96,20 +90,15 @@ const Editor = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleViewChange : function(newView){
|
handleViewChange : function(newView){
|
||||||
this.props.setMoveArrows(newView === 'text');
|
|
||||||
this.setState({
|
this.setState({
|
||||||
view : newView
|
view : newView
|
||||||
}, this.updateEditorSize); //TODO: not sure if updateeditorsize needed
|
}, this.updateEditorSize); //TODO: not sure if updateeditorsize needed
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentPage : function(){
|
getCurrentPage : function(){
|
||||||
const lines = this.props.brew.text.split('\n').slice(0, this.refs.codeEditor.getCursorPosition().line + 1);
|
const lines = this.props.brew.text.split('\n').slice(0, this.cursorPosition.line + 1);
|
||||||
return _.reduce(lines, (r, line)=>{
|
return _.reduce(lines, (r, line)=>{
|
||||||
if(
|
if(line.indexOf('\\page') !== -1) r++;
|
||||||
(this.props.renderer == 'legacy' && line.indexOf('\\page') !== -1)
|
|
||||||
||
|
|
||||||
(this.props.renderer == 'V3' && line.match(/^\\page$/))
|
|
||||||
) r++;
|
|
||||||
return r;
|
return r;
|
||||||
}, 1);
|
}, 1);
|
||||||
},
|
},
|
||||||
@@ -131,7 +120,6 @@ const Editor = createClass({
|
|||||||
//reset custom line styles
|
//reset custom line styles
|
||||||
codeMirror.removeLineClass(lineNumber, 'background', 'pageLine');
|
codeMirror.removeLineClass(lineNumber, 'background', 'pageLine');
|
||||||
codeMirror.removeLineClass(lineNumber, 'text');
|
codeMirror.removeLineClass(lineNumber, 'text');
|
||||||
codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash');
|
|
||||||
|
|
||||||
// Styling for \page breaks
|
// Styling for \page breaks
|
||||||
if((this.props.renderer == 'legacy' && line.includes('\\page')) ||
|
if((this.props.renderer == 'legacy' && line.includes('\\page')) ||
|
||||||
@@ -186,76 +174,9 @@ const Editor = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
brewJump : function(targetPage=this.getCurrentPage()){
|
brewJump : function(){
|
||||||
if(!window) return;
|
const currentPage = this.getCurrentPage();
|
||||||
// console.log(`Scroll to: p${targetPage}`);
|
window.location.hash = `p${currentPage}`;
|
||||||
const brewRenderer = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0];
|
|
||||||
const currentPos = brewRenderer.scrollTop;
|
|
||||||
const targetPos = window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).getBoundingClientRect().top;
|
|
||||||
const interimPos = targetPos >= 0 ? -30 : 30;
|
|
||||||
|
|
||||||
const bounceDelay = 100;
|
|
||||||
const scrollDelay = 500;
|
|
||||||
|
|
||||||
if(!this.throttleBrewMove) {
|
|
||||||
this.throttleBrewMove = _.throttle((currentPos, interimPos, targetPos)=>{
|
|
||||||
brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' });
|
|
||||||
setTimeout(()=>{
|
|
||||||
brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' });
|
|
||||||
}, bounceDelay);
|
|
||||||
}, scrollDelay, { leading: true, trailing: false });
|
|
||||||
};
|
|
||||||
this.throttleBrewMove(currentPos, interimPos, targetPos);
|
|
||||||
|
|
||||||
// const hashPage = (page != 1) ? `p${page}` : '';
|
|
||||||
// window.location.hash = hashPage;
|
|
||||||
},
|
|
||||||
|
|
||||||
sourceJump : function(targetLine=null){
|
|
||||||
if(this.isText()) {
|
|
||||||
if(targetLine == null) {
|
|
||||||
targetLine = 0;
|
|
||||||
|
|
||||||
const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page');
|
|
||||||
const brewRendererHeight = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).getBoundingClientRect().height;
|
|
||||||
|
|
||||||
let currentPage = 1;
|
|
||||||
for (const page of pageCollection) {
|
|
||||||
if(page.getBoundingClientRect().bottom > (brewRendererHeight / 2)) {
|
|
||||||
currentPage = parseInt(page.id.slice(1)) || 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const textSplit = this.props.renderer == 'V3' ? /^\\page$/gm : /\\page/;
|
|
||||||
const textString = this.props.brew.text.split(textSplit).slice(0, currentPage-1).join(textSplit);
|
|
||||||
const textPosition = textString.length;
|
|
||||||
const lineCount = textString.match('\n') ? textString.slice(0, textPosition).split('\n').length : 0;
|
|
||||||
|
|
||||||
targetLine = lineCount - 1; //Scroll to `\page`, which is one line back.
|
|
||||||
|
|
||||||
let currentY = this.refs.codeEditor.codeMirror.getScrollInfo().top;
|
|
||||||
let targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true);
|
|
||||||
|
|
||||||
//Scroll 1/10 of the way every 10ms until 1px off.
|
|
||||||
const incrementalScroll = setInterval(()=>{
|
|
||||||
currentY += (targetY - currentY) / 10;
|
|
||||||
this.refs.codeEditor.codeMirror.scrollTo(null, currentY);
|
|
||||||
|
|
||||||
// Update target: target height is not accurate until within +-10 lines of the visible window
|
|
||||||
if(Math.abs(targetY - currentY > 100))
|
|
||||||
targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true);
|
|
||||||
|
|
||||||
// End when close enough
|
|
||||||
if(Math.abs(targetY - currentY) < 1) {
|
|
||||||
this.refs.codeEditor.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference
|
|
||||||
this.refs.codeEditor.setCursorPosition({ line: targetLine + 1, ch: 0 });
|
|
||||||
this.refs.codeEditor.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
|
|
||||||
clearInterval(incrementalScroll);
|
|
||||||
}
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//Called when there are changes to the editor's dimensions
|
//Called when there are changes to the editor's dimensions
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ const request = require('superagent');
|
|||||||
|
|
||||||
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
|
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
|
||||||
|
|
||||||
const homebreweryThumbnail = require('../../thumbnail.png');
|
|
||||||
|
|
||||||
const MetadataEditor = createClass({
|
const MetadataEditor = createClass({
|
||||||
displayName : 'MetadataEditor',
|
displayName : 'MetadataEditor',
|
||||||
getDefaultProps : function() {
|
getDefaultProps : function() {
|
||||||
@@ -27,23 +25,6 @@ const MetadataEditor = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState : function(){
|
|
||||||
return {
|
|
||||||
showThumbnail : true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleThumbnailDisplay : function(){
|
|
||||||
this.setState({
|
|
||||||
showThumbnail : !this.state.showThumbnail
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
renderThumbnail : function(){
|
|
||||||
if(!this.state.showThumbnail) return;
|
|
||||||
return <img className='thumbnail-preview' src={this.props.metadata.thumbnail || homebreweryThumbnail}></img>;
|
|
||||||
},
|
|
||||||
|
|
||||||
handleFieldChange : function(name, e){
|
handleFieldChange : function(name, e){
|
||||||
this.props.onChange(_.merge({}, this.props.metadata, {
|
this.props.onChange(_.merge({}, this.props.metadata, {
|
||||||
[name] : e.target.value
|
[name] : e.target.value
|
||||||
@@ -78,7 +59,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.delete(`/api/${this.props.metadata.googleId ?? ''}${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 = '/';
|
||||||
@@ -181,18 +162,6 @@ const MetadataEditor = createClass({
|
|||||||
<textarea value={this.props.metadata.description} className='value'
|
<textarea value={this.props.metadata.description} className='value'
|
||||||
onChange={(e)=>this.handleFieldChange('description', e)} />
|
onChange={(e)=>this.handleFieldChange('description', e)} />
|
||||||
</div>
|
</div>
|
||||||
<div className='field thumbnail'>
|
|
||||||
<label>thumbnail</label>
|
|
||||||
<input type='text'
|
|
||||||
value={this.props.metadata.thumbnail}
|
|
||||||
placeholder='my.thumbnail.url'
|
|
||||||
className='value'
|
|
||||||
onChange={(e)=>this.handleFieldChange('thumbnail', e)} />
|
|
||||||
<button className='display' onClick={this.toggleThumbnailDisplay}>
|
|
||||||
<i className={`fas fa-caret-${this.state.showThumbnail ? 'right' : 'left'}`} />
|
|
||||||
</button>
|
|
||||||
{this.renderThumbnail()}
|
|
||||||
</div>
|
|
||||||
{/*}
|
{/*}
|
||||||
<div className='field tags'>
|
<div className='field tags'>
|
||||||
<label>tags</label>
|
<label>tags</label>
|
||||||
|
|||||||
@@ -24,33 +24,6 @@
|
|||||||
flex : 1 1 auto;
|
flex : 1 1 auto;
|
||||||
min-width : 200px;
|
min-width : 200px;
|
||||||
}
|
}
|
||||||
&.thumbnail{
|
|
||||||
height : 1.4em;
|
|
||||||
label{
|
|
||||||
line-height: 2.0em;
|
|
||||||
}
|
|
||||||
.value{
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
button{
|
|
||||||
border: 1px solid #999;
|
|
||||||
color: white;
|
|
||||||
padding: 0px 5px;
|
|
||||||
background-color: black;
|
|
||||||
&:hover{
|
|
||||||
background-color: #777;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.thumbnail-preview{
|
|
||||||
position : relative;
|
|
||||||
width : 80px;
|
|
||||||
height : min-content;
|
|
||||||
border : 2px solid white;
|
|
||||||
margin-left : 5px;
|
|
||||||
max-height : 115px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.description.field textarea.value{
|
.description.field textarea.value{
|
||||||
resize : none;
|
resize : none;
|
||||||
|
|||||||
@@ -97,11 +97,7 @@ module.exports = [
|
|||||||
gen : dedent`/* Removes Drop Caps */
|
gen : dedent`/* Removes Drop Caps */
|
||||||
.page h1+p:first-letter {
|
.page h1+p:first-letter {
|
||||||
all: unset;
|
all: unset;
|
||||||
}\n\n
|
}\n\n`
|
||||||
/* Removes Small-Caps in first line */
|
|
||||||
.page h1+p:first-line {
|
|
||||||
all: unset;
|
|
||||||
}`
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Tweak Drop Cap',
|
name : 'Tweak Drop Cap',
|
||||||
|
|||||||
@@ -32,16 +32,11 @@ const Homebrew = createClass({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
componentWillMount : function() {
|
||||||
getInitialState : function() {
|
|
||||||
global.account = this.props.account;
|
global.account = this.props.account;
|
||||||
global.version = this.props.version;
|
global.version = this.props.version;
|
||||||
global.enable_v3 = this.props.enable_v3;
|
global.enable_v3 = this.props.enable_v3;
|
||||||
global.config = this.props.config;
|
|
||||||
|
|
||||||
return {};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function (){
|
render : function (){
|
||||||
return (
|
return (
|
||||||
<Router location={this.props.url}>
|
<Router location={this.props.url}>
|
||||||
@@ -51,7 +46,7 @@ const Homebrew = createClass({
|
|||||||
<Route path='/share/:id' component={(routeProps)=><SharePage 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='/new/:id' component={(routeProps)=><NewPage id={routeProps.match.params.id} brew={this.props.brew} />}/>
|
<Route path='/new/:id' component={(routeProps)=><NewPage id={routeProps.match.params.id} brew={this.props.brew} />}/>
|
||||||
<Route path='/new' exact component={(routeProps)=><NewPage />}/>
|
<Route path='/new' exact component={(routeProps)=><NewPage />}/>
|
||||||
<Route path='/user/:username' component={(routeProps)=><UserPage username={routeProps.match.params.username} brews={this.props.brews} query={queryString.parse(routeProps.location.search)}/>}/>
|
<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/: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='/print' exact component={(routeProps)=><PrintPage query={queryString.parse(routeProps.location.search)} />}/>
|
||||||
<Route path='/changelog' exact component={()=><SharePage brew={this.props.brew} />}/>
|
<Route path='/changelog' exact component={()=><SharePage brew={this.props.brew} />}/>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const request = require('superagent');
|
|
||||||
|
|
||||||
const Account = createClass({
|
const Account = createClass({
|
||||||
displayName : 'AccountNavItem',
|
displayName : 'AccountNavItem',
|
||||||
@@ -19,84 +18,13 @@ const Account = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleLogout : function(){
|
|
||||||
if(confirm('Are you sure you want to log out?')) {
|
|
||||||
// Reset divider position
|
|
||||||
window.localStorage.removeItem('naturalcrit-pane-split');
|
|
||||||
// Clear login cookie
|
|
||||||
let domain = '';
|
|
||||||
if(window.location?.hostname) {
|
|
||||||
let domainArray = window.location.hostname.split('.');
|
|
||||||
if(domainArray.length > 2){
|
|
||||||
domainArray = [''].concat(domainArray.slice(-2));
|
|
||||||
}
|
|
||||||
domain = domainArray.join('.');
|
|
||||||
}
|
|
||||||
document.cookie = `nc_session=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;samesite=lax;${domain ? `domain=${domain}` : ''}`;
|
|
||||||
window.location = '/';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
localLogin : async function(){
|
|
||||||
const username = prompt('Enter username:');
|
|
||||||
if(!username) {return;}
|
|
||||||
|
|
||||||
const expiry = new Date;
|
|
||||||
expiry.setFullYear(expiry.getFullYear() + 1);
|
|
||||||
|
|
||||||
const token = await request.post('/local/login')
|
|
||||||
.send({ username })
|
|
||||||
.then((response)=>{
|
|
||||||
return response.body;
|
|
||||||
})
|
|
||||||
.catch((err)=>{
|
|
||||||
console.warn(err);
|
|
||||||
});
|
|
||||||
if(!token) return;
|
|
||||||
|
|
||||||
document.cookie = `nc_session=${token};expires=${expiry};path=/;samesite=lax;${window.domain ? `domain=${window.domain}` : ''}`;
|
|
||||||
window.location.reload(true);
|
|
||||||
},
|
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
// Logged in
|
|
||||||
if(global.account){
|
if(global.account){
|
||||||
return <Nav.dropdown>
|
return <Nav.item href={`/user/${global.account.username}`} color='yellow' icon='fas fa-user'>
|
||||||
<Nav.item
|
{global.account.username}
|
||||||
className='account'
|
</Nav.item>;
|
||||||
color='orange'
|
|
||||||
icon='fas fa-user'
|
|
||||||
>
|
|
||||||
{global.account.username}
|
|
||||||
</Nav.item>
|
|
||||||
<Nav.item
|
|
||||||
href={`/user/${global.account.username}`}
|
|
||||||
color='yellow'
|
|
||||||
icon='fas fa-beer'
|
|
||||||
>
|
|
||||||
brews
|
|
||||||
</Nav.item>
|
|
||||||
<Nav.item
|
|
||||||
className='logout'
|
|
||||||
color='red'
|
|
||||||
icon='fas fa-power-off'
|
|
||||||
onClick={this.handleLogout}
|
|
||||||
>
|
|
||||||
logout
|
|
||||||
</Nav.item>
|
|
||||||
</Nav.dropdown>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logged out
|
|
||||||
// LOCAL ONLY
|
|
||||||
if(global.config.local) {
|
|
||||||
return <Nav.item color='teal' icon='fas fa-sign-in-alt' onClick={this.localLogin}>
|
|
||||||
login
|
|
||||||
</Nav.item>;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Logged out
|
|
||||||
// Production site
|
|
||||||
return <Nav.item href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`} color='teal' icon='fas fa-sign-in-alt'>
|
return <Nav.item href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`} color='teal' icon='fas fa-sign-in-alt'>
|
||||||
login
|
login
|
||||||
</Nav.item>;
|
</Nav.item>;
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
const React = require('react');
|
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const dedent = require('dedent-tabs').default;
|
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
|
||||||
|
|
||||||
module.exports = function(props){
|
|
||||||
return <Nav.dropdown>
|
|
||||||
<Nav.item color='grey' icon='fas fa-question-circle'>
|
|
||||||
need help?
|
|
||||||
</Nav.item>
|
|
||||||
<Nav.item color='red' icon='fas fa-fw fa-bug'
|
|
||||||
href={`https://www.reddit.com/r/homebrewery/submit?selftext=true&text=${encodeURIComponent(dedent`
|
|
||||||
**Browser(s)** :
|
|
||||||
**Operating System** :
|
|
||||||
**Legacy or v3 Renderer** :
|
|
||||||
**Issue** : `)}`}
|
|
||||||
newTab={true}
|
|
||||||
rel='noopener noreferrer'>
|
|
||||||
report issue
|
|
||||||
</Nav.item>
|
|
||||||
<Nav.item color='blue' icon='fas fa-fw fa-file-import'
|
|
||||||
href='/migrate'
|
|
||||||
newTab={true}
|
|
||||||
rel='noopener noreferrer'>
|
|
||||||
migrate
|
|
||||||
</Nav.item>
|
|
||||||
</Nav.dropdown>;
|
|
||||||
};
|
|
||||||
13
client/homebrew/navbar/issue.navitem.jsx
Normal file
13
client/homebrew/navbar/issue.navitem.jsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const React = require('react');
|
||||||
|
const createClass = require('create-react-class');
|
||||||
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
|
||||||
|
module.exports = function(props){
|
||||||
|
return <Nav.item
|
||||||
|
newTab={true}
|
||||||
|
color='red'
|
||||||
|
icon='fas fa-bug'
|
||||||
|
href={`https://www.reddit.com/r/homebrewery/submit?selftext=true&title=${encodeURIComponent('[Issue] Describe Your Issue Here')}`} >
|
||||||
|
report issue
|
||||||
|
</Nav.item>;
|
||||||
|
};
|
||||||
@@ -14,10 +14,12 @@ const Navbar = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState : function() {
|
componentDidMount : function() {
|
||||||
return {
|
//const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
|
||||||
ver : global.version
|
this.setState({
|
||||||
};
|
//showNonChromeWarning : !isChrome,
|
||||||
|
ver : window.version
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
@import 'naturalcrit/styles/colors.less';
|
|
||||||
@navbarHeight : 28px;
|
@navbarHeight : 28px;
|
||||||
@keyframes pinkColoring {
|
@keyframes coloring {
|
||||||
//from {color: white;}
|
//from {color: white;}
|
||||||
//to {color: red;}
|
//to {color: red;}
|
||||||
0% {color: pink;}
|
0% {color: pink;}
|
||||||
@@ -63,21 +62,19 @@
|
|||||||
}
|
}
|
||||||
i{
|
i{
|
||||||
.animate(color);
|
.animate(color);
|
||||||
animation-name: pinkColoring;
|
animation-name: coloring;
|
||||||
animation-duration: 2s;
|
animation-duration: 2s;
|
||||||
color: pink;
|
color: pink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.recent.navItem {
|
.recent.navItem{
|
||||||
position : relative;
|
position : relative;
|
||||||
.dropdown{
|
.dropdown{
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 28px;
|
top : 28px;
|
||||||
left : 0px;
|
left : 0px;
|
||||||
z-index : 10000;
|
z-index : 10000;
|
||||||
width : 100%;
|
width : 100%;
|
||||||
overflow : hidden auto;
|
|
||||||
max-height : ~"calc(100vh - 28px)";
|
|
||||||
h4{
|
h4{
|
||||||
display : block;
|
display : block;
|
||||||
box-sizing : border-box;
|
box-sizing : border-box;
|
||||||
@@ -91,12 +88,11 @@
|
|||||||
&:nth-of-type(2){ background-color: darken(@purple, 30%); }
|
&:nth-of-type(2){ background-color: darken(@purple, 30%); }
|
||||||
}
|
}
|
||||||
.item{
|
.item{
|
||||||
#backgroundColors;
|
|
||||||
.animate(background-color);
|
.animate(background-color);
|
||||||
position : relative;
|
position : relative;
|
||||||
display : block;
|
display : block;
|
||||||
box-sizing : border-box;
|
box-sizing : border-box;
|
||||||
padding : 8px 5px 13px;
|
padding : 13px 5px;
|
||||||
background-color : #333;
|
background-color : #333;
|
||||||
color : white;
|
color : white;
|
||||||
text-decoration : none;
|
text-decoration : none;
|
||||||
@@ -142,7 +138,4 @@
|
|||||||
text-align : center;
|
text-align : center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.account.navItem{
|
|
||||||
min-width: 100px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ const RecentItems = createClass({
|
|||||||
if(!this.state.showDropdown) return null;
|
if(!this.state.showDropdown) return null;
|
||||||
|
|
||||||
const makeItems = (brews)=>{
|
const makeItems = (brews)=>{
|
||||||
return _.map(brews, (brew, i)=>{
|
return _.map(brews, (brew)=>{
|
||||||
return <a href={brew.url} className='item' key={`${brew.id}-${i}`} target='_blank' rel='noopener noreferrer' title={brew.title || '[ no title ]'}>
|
return <a href={brew.url} className='item' key={brew.id} target='_blank' rel='noopener noreferrer' title={brew.title || '[ no title ]'}>
|
||||||
<span className='title'>{brew.title || '[ no title ]'}</span>
|
<span className='title'>{brew.title || '[ no title ]'}</span>
|
||||||
<span className='time'>{Moment(brew.ts).fromNow()}</span>
|
<span className='time'>{Moment(brew.ts).fromNow()}</span>
|
||||||
</a>;
|
</a>;
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
require('./listPage.less');
|
|
||||||
const React = require('react');
|
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const moment = require('moment');
|
|
||||||
|
|
||||||
const BrewItem = require('./brewItem/brewItem.jsx');
|
|
||||||
|
|
||||||
const ListPage = createClass({
|
|
||||||
displayName : 'ListPage',
|
|
||||||
getDefaultProps : function() {
|
|
||||||
return {
|
|
||||||
brewCollection : [
|
|
||||||
{
|
|
||||||
title : '',
|
|
||||||
class : '',
|
|
||||||
brews : []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
navItems : <></>
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getInitialState : function() {
|
|
||||||
return {
|
|
||||||
sortType : 'alpha',
|
|
||||||
sortDir : 'asc',
|
|
||||||
filterString : this.props.query?.filter || '',
|
|
||||||
query : this.props.query
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
renderBrews : function(brews){
|
|
||||||
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
|
||||||
|
|
||||||
return _.map(brews, (brew, idx)=>{
|
|
||||||
return <BrewItem brew={brew} key={idx}/>;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
sortBrewOrder : function(brew){
|
|
||||||
if(!brew.title){brew.title = 'No Title';}
|
|
||||||
const mapping = {
|
|
||||||
'alpha' : _.deburr(brew.title.toLowerCase()),
|
|
||||||
'created' : moment(brew.createdAt).format(),
|
|
||||||
'updated' : moment(brew.updatedAt).format(),
|
|
||||||
'views' : brew.views,
|
|
||||||
'latest' : moment(brew.lastViewed).format()
|
|
||||||
};
|
|
||||||
return mapping[this.state.sortType];
|
|
||||||
},
|
|
||||||
|
|
||||||
handleSortOptionChange : function(event){
|
|
||||||
this.setState({
|
|
||||||
sortType : event.target.value
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleSortDirChange : function(event){
|
|
||||||
this.setState({
|
|
||||||
sortDir : `${(this.state.sortDir == 'asc' ? 'desc' : 'asc')}`
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
renderSortOption : function(sortTitle, sortValue){
|
|
||||||
return <td>
|
|
||||||
<button
|
|
||||||
value={`${sortValue}`}
|
|
||||||
onClick={this.handleSortOptionChange}
|
|
||||||
className={`${(this.state.sortType == sortValue ? 'active' : '')}`}
|
|
||||||
>
|
|
||||||
{`${sortTitle}`}
|
|
||||||
</button>
|
|
||||||
</td>;
|
|
||||||
},
|
|
||||||
|
|
||||||
handleFilterTextChange : function(e){
|
|
||||||
this.setState({
|
|
||||||
filterString : e.target.value,
|
|
||||||
});
|
|
||||||
this.updateUrl(e.target.value);
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
|
|
||||||
updateUrl : function(filterTerm){
|
|
||||||
const url = new URL(window.location.href);
|
|
||||||
const urlParams = new URLSearchParams(url.search);
|
|
||||||
if(urlParams.get('filter') == filterTerm)
|
|
||||||
return;
|
|
||||||
if(!filterTerm)
|
|
||||||
urlParams.delete('filter');
|
|
||||||
else
|
|
||||||
urlParams.set('filter', filterTerm);
|
|
||||||
url.search = urlParams;
|
|
||||||
window.history.replaceState(null, null, url);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderFilterOption : function(){
|
|
||||||
return <td>
|
|
||||||
<label>
|
|
||||||
<i className='fas fa-search'></i>
|
|
||||||
<input
|
|
||||||
type='search'
|
|
||||||
autoFocus={true}
|
|
||||||
placeholder='filter title/description'
|
|
||||||
onChange={this.handleFilterTextChange}
|
|
||||||
value={this.state.filterString}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderSortOptions : function(){
|
|
||||||
return <div className='sort-container'>
|
|
||||||
<table>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<h6>Sort by :</h6>
|
|
||||||
</td>
|
|
||||||
{this.renderSortOption('Title', 'alpha')}
|
|
||||||
{this.renderSortOption('Created Date', 'created')}
|
|
||||||
{this.renderSortOption('Updated Date', 'updated')}
|
|
||||||
{this.renderSortOption('Views', 'views')}
|
|
||||||
{/* {this.renderSortOption('Latest', 'latest')} */}
|
|
||||||
<td>
|
|
||||||
<h6>Direction :</h6>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button
|
|
||||||
onClick={this.handleSortDirChange}
|
|
||||||
className='sortDir'
|
|
||||||
>
|
|
||||||
{`${(this.state.sortDir == 'asc' ? '\u25B2 ASC' : '\u25BC DESC')}`}
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
{this.renderFilterOption()}
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>;
|
|
||||||
},
|
|
||||||
|
|
||||||
getSortedBrews : function(brews){
|
|
||||||
const testString = _.deburr(this.state.filterString).toLowerCase();
|
|
||||||
brews = _.filter(brews, (brew)=>{
|
|
||||||
return (_.deburr(brew.title).toLowerCase().includes(testString)) ||
|
|
||||||
(_.deburr(brew.description).toLowerCase().includes(testString));
|
|
||||||
});
|
|
||||||
|
|
||||||
return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderBrewCollection : function(brewCollection){
|
|
||||||
return _.map(brewCollection, (brewGroup, idx)=>{
|
|
||||||
return <div key={idx} className={`brewCollection ${brewGroup.class ?? ''}`}>
|
|
||||||
<h1>{brewGroup.title || 'No Title'}</h1>
|
|
||||||
{this.renderBrews(this.getSortedBrews(brewGroup.brews))}
|
|
||||||
</div>;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
render : function(){
|
|
||||||
return <div className='listPage sitePage'>
|
|
||||||
<link href='/themes/5ePhbLegacy.style.css' rel='stylesheet'/>
|
|
||||||
{this.props.navItems}
|
|
||||||
|
|
||||||
<div className='content V3'>
|
|
||||||
<div className='phb'>
|
|
||||||
{this.renderSortOptions()}
|
|
||||||
{this.renderBrewCollection(this.props.brewCollection)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = ListPage;
|
|
||||||
@@ -10,7 +10,7 @@ const Nav = require('naturalcrit/nav/nav.jsx');
|
|||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
|
|
||||||
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const ReportIssue = require('../../navbar/issue.navitem.jsx');
|
||||||
const PrintLink = require('../../navbar/print.navitem.jsx');
|
const PrintLink = require('../../navbar/print.navitem.jsx');
|
||||||
const Account = require('../../navbar/account.navitem.jsx');
|
const Account = require('../../navbar/account.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
@@ -200,18 +200,73 @@ const EditPage = createClass({
|
|||||||
const brew = this.state.brew;
|
const brew = this.state.brew;
|
||||||
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
||||||
|
|
||||||
const params = `${transfer ? `?transfer${this.state.saveGoogle ? 'To' : 'From'}Google=true` : ''}`;
|
if(this.state.saveGoogle) {
|
||||||
const res = await request
|
if(transfer) {
|
||||||
.put(`/api/update/${brew.editId}${params}`)
|
const res = await request
|
||||||
.send(brew)
|
.post('/api/newGoogle/')
|
||||||
.catch((err)=>{
|
.send(brew)
|
||||||
console.log('Error Updating Local Brew');
|
.catch((err)=>{
|
||||||
this.setState({ errors: err });
|
console.log(err.status === 401
|
||||||
});
|
? 'Not signed in!'
|
||||||
|
: 'Error Transferring to Google!');
|
||||||
|
this.setState({ errors: err, saveGoogle: false });
|
||||||
|
});
|
||||||
|
|
||||||
this.savedBrew = res.body;
|
if(!res) { return; }
|
||||||
if(transfer) {
|
|
||||||
history.replaceState(null, null, `/edit/${this.savedBrew.googleId ?? ''}${this.savedBrew.editId}`);
|
console.log('Deleting Local Copy');
|
||||||
|
await request.delete(`/api/${brew.editId}`)
|
||||||
|
.send()
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log('Error deleting Local Copy');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.savedBrew = res.body;
|
||||||
|
history.replaceState(null, null, `/edit/${this.savedBrew.googleId}${this.savedBrew.editId}`); //update URL to match doc ID
|
||||||
|
} else {
|
||||||
|
const res = await request
|
||||||
|
.put(`/api/updateGoogle/${brew.editId}`)
|
||||||
|
.send(brew)
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log(err.status === 401
|
||||||
|
? 'Not signed in!'
|
||||||
|
: 'Error Saving to Google!');
|
||||||
|
this.setState({ errors: err });
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.savedBrew = res.body;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(transfer) {
|
||||||
|
const res = await request.post('/api')
|
||||||
|
.send(brew)
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log('Error creating Local Copy');
|
||||||
|
this.setState({ errors: err });
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
await request.get(`/api/removeGoogle/${brew.googleId}${brew.editId}`)
|
||||||
|
.send()
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log('Error Deleting Google Brew');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.savedBrew = res.body;
|
||||||
|
history.replaceState(null, null, `/edit/${this.savedBrew.editId}`); //update URL to match doc ID
|
||||||
|
} else {
|
||||||
|
const res = await request
|
||||||
|
.put(`/api/update/${brew.editId}`)
|
||||||
|
.send(brew)
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log('Error Updating Local Brew');
|
||||||
|
this.setState({ errors: err });
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.savedBrew = res.body;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
@@ -276,26 +331,26 @@ const EditPage = createClass({
|
|||||||
console.log(errMsg);
|
console.log(errMsg);
|
||||||
} catch (e){}
|
} catch (e){}
|
||||||
|
|
||||||
// if(this.state.errors.status == '401'){
|
if(this.state.errors.status == '401'){
|
||||||
// return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
// Oops!
|
Oops!
|
||||||
// <div className='errorContainer' onClick={this.clearErrors}>
|
<div className='errorContainer' onClick={this.clearErrors}>
|
||||||
// You must be signed in to a Google account
|
You must be signed in to a Google account
|
||||||
// to save this to<br />Google Drive!<br />
|
to save this to<br />Google Drive!<br />
|
||||||
// <a target='_blank' rel='noopener noreferrer'
|
<a target='_blank' rel='noopener noreferrer'
|
||||||
// href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`}>
|
href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`}>
|
||||||
// <div className='confirm'>
|
<div className='confirm'>
|
||||||
// Sign In
|
Sign In
|
||||||
// </div>
|
</div>
|
||||||
// </a>
|
</a>
|
||||||
// <div className='deny'>
|
<div className='deny'>
|
||||||
// Not Now
|
Not Now
|
||||||
// </div>
|
</div>
|
||||||
// </div>
|
</div>
|
||||||
// </Nav.item>;
|
</Nav.item>;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if(this.state.errors.response.req.url.match(/^\/api.*Google.*$/m)){
|
if(this.state.errors.response.req.url.match(/^\/api\/.*Google.*$/m)){
|
||||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
Oops!
|
Oops!
|
||||||
<div className='errorContainer' onClick={this.clearErrors}>
|
<div className='errorContainer' onClick={this.clearErrors}>
|
||||||
@@ -352,7 +407,7 @@ const EditPage = createClass({
|
|||||||
const title = `${this.props.brew.title} ${systems}`;
|
const title = `${this.props.brew.title} ${systems}`;
|
||||||
const text = `Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
|
const text = `Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
|
||||||
|
|
||||||
**[Homebrewery Link](${global.config.publicUrl}/share/${shareLink})**`;
|
**[Homebrewery Link](https://homebrewery.naturalcrit.com/share/${shareLink})**`;
|
||||||
|
|
||||||
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title)}&text=${encodeURIComponent(text)}`;
|
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title)}&text=${encodeURIComponent(text)}`;
|
||||||
},
|
},
|
||||||
@@ -379,7 +434,7 @@ const EditPage = createClass({
|
|||||||
{this.renderGoogleDriveIcon()}
|
{this.renderGoogleDriveIcon()}
|
||||||
{this.renderSaveButton()}
|
{this.renderSaveButton()}
|
||||||
<NewBrew />
|
<NewBrew />
|
||||||
<HelpNavItem/>
|
<ReportIssue />
|
||||||
<Nav.dropdown>
|
<Nav.dropdown>
|
||||||
<Nav.item color='teal' icon='fas fa-share-alt'>
|
<Nav.item color='teal' icon='fas fa-share-alt'>
|
||||||
share
|
share
|
||||||
@@ -387,7 +442,7 @@ const EditPage = createClass({
|
|||||||
<Nav.item color='blue' href={`/share/${shareLink}`}>
|
<Nav.item color='blue' href={`/share/${shareLink}`}>
|
||||||
view
|
view
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
<Nav.item color='blue' onClick={()=>{navigator.clipboard.writeText(`${global.config.publicUrl}/share/${shareLink}`);}}>
|
<Nav.item color='blue' onClick={()=>{navigator.clipboard.writeText(`https://homebrewery.naturalcrit.com/share/${shareLink}`);}}>
|
||||||
copy url
|
copy url
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
<Nav.item color='blue' href={this.getRedditLink()} newTab={true} rel='noopener noreferrer'>
|
<Nav.item color='blue' href={this.getRedditLink()} newTab={true} rel='noopener noreferrer'>
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ const cx = require('classnames');
|
|||||||
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');
|
||||||
const PatreonNavItem = require('../../navbar/patreon.navitem.jsx');
|
const PatreonNavItem = require('../../navbar/patreon.navitem.jsx');
|
||||||
|
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
|
||||||
|
|
||||||
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ const ErrorPage = createClass({
|
|||||||
|
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
<PatreonNavItem />
|
<PatreonNavItem />
|
||||||
<HelpNavItem />
|
<IssueNavItem />
|
||||||
<RecentNavItem />
|
<RecentNavItem />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ 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');
|
||||||
const NewBrewItem = require('../../navbar/newbrew.navitem.jsx');
|
const NewBrewItem = require('../../navbar/newbrew.navitem.jsx');
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ const HomePage = createClass({
|
|||||||
return <Navbar ver={this.props.ver}>
|
return <Navbar ver={this.props.ver}>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
<NewBrewItem />
|
<NewBrewItem />
|
||||||
<HelpNavItem />
|
<IssueNavItem />
|
||||||
<RecentNavItem />
|
<RecentNavItem />
|
||||||
<AccountNavItem />
|
<AccountNavItem />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
|
|||||||
@@ -1,202 +0,0 @@
|
|||||||
# How to Convert a Legacy Document to v3
|
|
||||||
Here you will find a number of steps to guide you through converting a Legacy document into a Homebrewery v3 document.
|
|
||||||
|
|
||||||
**The first thing you'll want to do is switch the editor's rendering engine from `Legacy` to `v3`.** This will be the renderer we design features for moving forward.
|
|
||||||
|
|
||||||
There are some examples of Legacy code in the code pane if you need more context behind some of the changes.
|
|
||||||
|
|
||||||
**This document will evolve as users like yourself inform us of issues with it, or areas of conversion that it does not cover. _Please_ reach out if you have any suggestions for this document.**
|
|
||||||
|
|
||||||
## Simple Replacements
|
|
||||||
To make your life a little easier with this section, a text editor like [VSCode](https://code.visualstudio.com/) or Notepad will help a lot.
|
|
||||||
|
|
||||||
The following table describes Legacy and other document elements and their Homebrewery counterparts. A simple find/replace should get these in working order.
|
|
||||||
|
|
||||||
| Legacy / Other | Homebrewery |
|
|
||||||
|:----------------|:-----------------------------|
|
|
||||||
| `\pagebreak` | `\page` |
|
|
||||||
| `======` | `\page` |
|
|
||||||
| `\pagebreaknum` | `{{pageNumber,auto}}\n\page` |
|
|
||||||
| `@=====` | `{{pageNumber,auto}}\n\page` |
|
|
||||||
| `\columnbreak` | `\column` |
|
|
||||||
| `.phb` | `.page` |
|
|
||||||
|
|
||||||
## Classed or Styled Divs
|
|
||||||
Anything that relies on the following syntax can be changed to the new Homebrewery v3 curly brace syntax:
|
|
||||||
|
|
||||||
```
|
|
||||||
<div class="classTable wide">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
:
|
|
||||||
The above example is equivalent to the following in v3 syntax.
|
|
||||||
|
|
||||||
```
|
|
||||||
{{classTable,wide
|
|
||||||
...
|
|
||||||
}}
|
|
||||||
```
|
|
||||||
:
|
|
||||||
Some examples of this include class tables (as shown above), descriptive blocks, notes, and spell lists.
|
|
||||||
|
|
||||||
\column
|
|
||||||
|
|
||||||
## Margins and Padding
|
|
||||||
Any manual margins and padding to push text down the page will likely need to be updated. Colons can be used on lines by themselves to push things down the page vertically if you'd rather not set pixel-perfect margins or padding.
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
In Legacy, notes are denoted using markdown blockquote syntax. In Homebrewery v3, this is replaced by the curly brace syntax.
|
|
||||||
|
|
||||||
<!--
|
|
||||||
> ##### Catchy Title
|
|
||||||
> Useful Information
|
|
||||||
-->
|
|
||||||
|
|
||||||
{{note
|
|
||||||
##### Title
|
|
||||||
Information
|
|
||||||
}}
|
|
||||||
|
|
||||||
## Split Tables
|
|
||||||
Split tables also use the curly brace syntax, as the new renderer can handle style values separately from class names.
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<div style='column-count:2'>
|
|
||||||
|
|
||||||
| d8 | Loot |
|
|
||||||
|:---:|:-----------:|
|
|
||||||
| 1 | 100gp |
|
|
||||||
| 2 | 200gp |
|
|
||||||
| 3 | 300gp |
|
|
||||||
| 4 | 400gp |
|
|
||||||
|
|
||||||
| d8 | Loot |
|
|
||||||
|:---:|:-----------:|
|
|
||||||
| 5 | 500gp |
|
|
||||||
| 6 | 600gp |
|
|
||||||
| 7 | 700gp |
|
|
||||||
| 8 | 1000gp |
|
|
||||||
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
##### Typical Difficulty Classes
|
|
||||||
{{column-count:2
|
|
||||||
| Task Difficulty | DC |
|
|
||||||
|:----------------|:--:|
|
|
||||||
| Very easy | 5 |
|
|
||||||
| Easy | 10 |
|
|
||||||
| Medium | 15 |
|
|
||||||
|
|
||||||
| Task Difficulty | DC |
|
|
||||||
|:------------------|:--:|
|
|
||||||
| Hard | 20 |
|
|
||||||
| Very hard | 25 |
|
|
||||||
| Nearly impossible | 30 |
|
|
||||||
}}
|
|
||||||
|
|
||||||
## Blockquotes
|
|
||||||
Blockquotes are denoted by the `>` character at the beginning of the line. In Homebrewery's v3 renderer, they hold virtually no meaning and have no CSS styling. You are free to use blockquotes when styling your document or creating themes without needing to worry about your CSS affecting other parts of the document.
|
|
||||||
|
|
||||||
{{pageNumber,auto}}
|
|
||||||
|
|
||||||
\page
|
|
||||||
|
|
||||||
## Stat Blocks
|
|
||||||
|
|
||||||
There are pretty significant differences between stat blocks on the Legacy renderer and Homebrewery v3. This section contains a list of changes that will need to be made to update the stat block.
|
|
||||||
|
|
||||||
### Initial Changes
|
|
||||||
You will want to **remove all leading** `___` that started the stat block in Legacy, and replace that with `{{monster` before the stat block, and `}}` after it.
|
|
||||||
|
|
||||||
**If you want a frame** around the stat block, you can add `,frame` to the curly brace definition.
|
|
||||||
|
|
||||||
**If the stat block was wide**, make sure to add `,wide` to the curly brace definition.
|
|
||||||
|
|
||||||
### Blockquotes
|
|
||||||
The key difference is the lack of blockquotes. Legacy documents use the `>` symbol at the start of the line for each line in the stat block, and the v3 renderer does not. **You will want to remove all `>` characters at the beginning of all lines, and delete any leading spaces.**
|
|
||||||
|
|
||||||
### Lists
|
|
||||||
The basic characteristics and advanced characteristics sections are not list elements in Homebrewery. You will want to **remove all `-` or `*` characters from the beginning of lines.**
|
|
||||||
|
|
||||||
### Spacing
|
|
||||||
In order to have the correct spacing after removing the list elements, you will want to **add two colons between the name of each basic/advanced characteristic and its value.** _(see example in the code pane)_
|
|
||||||
|
|
||||||
Additionally, in the special traits and actions sections, you will want to add a colon at the beginning of each line that separates a trait/action from another, as seen below. **Any empty lines between special traits and actions should contain only a colon.** _(see example in the code pane)_
|
|
||||||
|
|
||||||
\column
|
|
||||||
|
|
||||||
{{margin-top:102px}}
|
|
||||||
|
|
||||||
<!--
|
|
||||||
### Legacy/Other Document Example:
|
|
||||||
___
|
|
||||||
> ## Centaur
|
|
||||||
> *Large Monstrosity, neutral good*
|
|
||||||
>___
|
|
||||||
> - **Armor Class** 12
|
|
||||||
> - **Hit Points** 45(6d10 + 12)
|
|
||||||
> - **Speed** 50ft.
|
|
||||||
>___
|
|
||||||
>|STR|DEX|CON|INT|WIS|CHA|
|
|
||||||
>|:---:|:---:|:---:|:---:|:---:|:---:|
|
|
||||||
>|18 (+4)|14 (+2)|14 (+2)|9 (-1)|13 (+1)|11 (+0)|
|
|
||||||
>___
|
|
||||||
> - **Skills** Athletics +6, Perception +3, Survival +3
|
|
||||||
> - **Senses** passive Perception 13
|
|
||||||
> - **Languages** Elvish, Sylvan
|
|
||||||
> - **Challenge** 2 (450 XP)
|
|
||||||
> ___
|
|
||||||
> ***Charge.*** If the centaur moves at least 30 feet straight toward a target and then hits it with a pike attack on the same turn, the target takes an extra 10 (3d6) piercing damage.
|
|
||||||
>
|
|
||||||
> ***Second Thing*** More details.
|
|
||||||
>
|
|
||||||
> ### Actions
|
|
||||||
> ***Multiattack.*** The centaur makes two attacks: one with its pike and one with its hooves or two with its longbow.
|
|
||||||
>
|
|
||||||
> ***Pike.*** *Melee Weapon Attack:* +6 to hit, reach 10 ft., one target. *Hit:* 9 (1d10 + 4) piercing damage.
|
|
||||||
>
|
|
||||||
> ***Hooves.*** *Melee Weapon Attack:* +6 to hit, reach 5 ft., one target. *Hit:* 11 (2d6 + 4) bludgeoning damage.
|
|
||||||
>
|
|
||||||
> ***Longbow.*** *Ranged Weapon Attack:* +4 to hit, range 150/600 ft., one target. *Hit:* 6 (1d8 + 2) piercing damage.
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Homebrewery v3 Example:
|
|
||||||
|
|
||||||
{{monster
|
|
||||||
## Centaur
|
|
||||||
*Large monstrosity, neutral good*
|
|
||||||
___
|
|
||||||
**Armor Class** :: 12
|
|
||||||
**Hit Points** :: 45(6d10 + 12)
|
|
||||||
**Speed** :: 50ft.
|
|
||||||
___
|
|
||||||
| STR | DEX | CON | INT | WIS | CHA |
|
|
||||||
|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|
|
|
||||||
|18 (+4)|14 (+2)|14 (+2)|9 (-1) |13 (+1)|11 (+0)|
|
|
||||||
___
|
|
||||||
**Skills** :: Athletics +6, Perception +3, Survival +3
|
|
||||||
**Senses** :: passive Perception 13
|
|
||||||
**Languages** :: Elvish, Sylvan
|
|
||||||
**Challenge** :: 2 (450 XP)
|
|
||||||
___
|
|
||||||
***Charge.*** If the centaur moves at least 30 feet straight toward a target and then hits it with a pike attack on the same turn, the target takes an extra 10 (3d6) piercing damage.
|
|
||||||
:
|
|
||||||
***Second Thing*** More details.
|
|
||||||
|
|
||||||
### Actions
|
|
||||||
***Multiattack.*** The centaur makes two attacks: one with its pike and one with its hooves or two with its longbow.
|
|
||||||
:
|
|
||||||
***Pike.*** *Melee Weapon Attack:* +6 to hit, reach 10 ft., one target. *Hit:* 9 (1d10 + 4) piercing damage.
|
|
||||||
:
|
|
||||||
***Hooves.*** *Melee Weapon Attack:* +6 to hit, reach 5 ft., one target. *Hit:* 11 (2d6 + 4) bludgeoning damage.
|
|
||||||
:
|
|
||||||
***Longbow.*** *Ranged Weapon Attack:* +4 to hit, range 150/600 ft., one target. *Hit:* 6 (1d8 + 2) piercing damage.
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{pageNumber,auto}}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# The Homebrewery
|
# The Homebrewery
|
||||||
|
|
||||||
Welcome traveler from an antique land. Please sit and tell us of what you have seen. The unheard of monsters, who slither and bite. Tell us of the wondrous items and and artifacts you have found, their mysteries yet to be unlocked. Of the vexing vocations and surprising skills you have seen.
|
Welcome traveler from an antique land. Please sit and tell us of what you have seen. The unheard of monsters, who slither and bite. Tell us of the wondrous items and and artifacts you have found, their mysteries yet to be unlocked. Of the vexing vocations and surprising skills you have seen.
|
||||||
|
|
||||||
### Homebrew D&D made easy
|
### Homebrew D&D made easy
|
||||||
@@ -58,20 +57,17 @@ The Homebrewery is licensed using the [MIT License](https://github.com/naturalcr
|
|||||||
If you wish to sell or in some way gain profit for what you make on this site, it's your responsibility to ensure you have the proper licenses/rights for any images or resources used.
|
If you wish to sell or in some way gain profit for what you make on this site, it's your responsibility to ensure you have the proper licenses/rights for any images or resources used.
|
||||||
|
|
||||||
### More Resources
|
### More Resources
|
||||||
<a href='https://discord.gg/by3deKx' target='_blank'><img src='/assets/discordOfManyThings.svg' alt='Discord of Many Things Logo' title='Discord of Many Things Logo' style='width:50px; float: right; padding-left: 10px;'/></a>
|
If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/wiki/resources).
|
||||||
If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/wiki/resources). The <a href='https://discord.gg/by3deKx' target='_blank' title='Discord of Many Things'>Discord of Many Things</a> is another great resource to connect with fellow homebrewers for help and feedback.
|
|
||||||
|
|
||||||
<img src='https://i.imgur.com/hMna6G0.png' style='position:absolute;bottom:40px;right:30px;width:280px' />
|
|
||||||
|
|
||||||
|
<img src='https://i.imgur.com/hMna6G0.png' style='position:absolute;bottom:50px;right:30px;width:280px' />
|
||||||
|
|
||||||
<div class='pageNumber'>1</div>
|
<div class='pageNumber'>1</div>
|
||||||
<div class='footnote'>PART 1 | FANCINESS</div>
|
<div class='footnote'>PART 1 | FANCINESS</div>
|
||||||
|
|
||||||
<div style='position: absolute; top: 20px; right: 20px;'>
|
|
||||||
<a href='https://discord.gg/by3deKx' target='_blank' title='Discord of Many Things'><img src='/assets/discord.png' style='height:30px'/></a>
|
|
||||||
<a href='https://github.com/naturalcrit/homebrewery' target='_blank' title='Github' style='color: black; padding-left: 5px;'><img src='/assets/github.png' style='height:30px'/></a>
|
|
||||||
<a href='https://patreon.com/NaturalCrit' target='_blank' title='Patreon' style='color: black; padding-left: 5px;'><img src='/assets/patreon.png' style='height:30px'/></a>
|
|
||||||
<a href='https://www.reddit.com/r/homebrewery/' target='_blank' title='Reddit' style='color: black; padding-left: 5px;'><img src='/assets/reddit.png' style='height:30px'/></a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
\page
|
\page
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
.page #example + table td {
|
.page #example + table td {
|
||||||
border:1px dashed #00000030;
|
border:1px dashed #00000030;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
padding-bottom : 1.1cm;
|
padding-bottom : 1.1cm;
|
||||||
}
|
}
|
||||||
@@ -49,9 +50,9 @@ If you want to save ink or have a monochrome printer, add the **PRINT → {{fas,
|
|||||||
\column
|
\column
|
||||||
|
|
||||||
## New in V3.0.0
|
## New in V3.0.0
|
||||||
We've implemented an extended Markdown-like syntax for block and span elements, plus a few other changes, eliminating the need for HTML tags like `div` and `span` in most cases. No raw HTML tags should be needed in a brew (*but can still be used if you insist*).
|
With the latest major update to *The Homebrewery* we've implemented an extended Markdown-like syntax for block and span elements, plus a few other changes, eliminating the need for HTML tags like `div` and `span` in most cases. No raw HTML tags should be needed in a brew, and going forward, raw HTML will no longer receive debugging support (*but can still be used if you insist*).
|
||||||
|
|
||||||
Much of the syntax and styling has changed in V3, so converting a Legacy brew to V3 (or vice-versa) will require tweaking your document. *However*, all brews made prior to the release of v3.0.0 will still render normally, and you may switch between the "Legacy" brew renderer and the newer "V3" renderer via the {{fa,fa-info-circle}} **Properties** button on your brew at any time.
|
Much of the syntax and styling has changed in V3. Code in one version may be broken in the other, and updating an older brew to V3 will require more than just a copy and paste. *However*, all brews made prior to the release of v3.0.0 will still render normally, and you may switch between the "Legacy" brew renderer and the newer "V3" renderer via the {{fa,fa-info-circle}} **Properties** button on your brew at any time.
|
||||||
|
|
||||||
Scroll down to the next page for a brief summary of the changes and new features available in V3!
|
Scroll down to the next page for a brief summary of the changes and new features available in V3!
|
||||||
|
|
||||||
@@ -79,15 +80,8 @@ If you wish to sell or in some way gain profit for what's created on this site,
|
|||||||
If you'd like to credit me in your brew, I'd be flattered! Just reference that you made it with The Homebrewery.
|
If you'd like to credit me in your brew, I'd be flattered! Just reference that you made it with The Homebrewery.
|
||||||
|
|
||||||
### More Homebrew Resources
|
### More Homebrew Resources
|
||||||
<a href='https://discord.gg/by3deKx' target='_blank'><img src='/assets/discordOfManyThings.svg' alt='Discord of Many Things Logo' title='Discord of Many Things Logo' style='width:50px; float: right; padding-left: 10px;'/></a>
|
Check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/wiki/resources).
|
||||||
If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/wiki/resources). The <a href='https://discord.gg/by3deKx' target='_blank' title='Discord of Many Things'>Discord of Many Things</a> is another great resource to connect with fellow homebrewers for help and feedback.
|
|
||||||
|
|
||||||
{{position:absolute;top:20px;right:20px;width:auto
|
|
||||||
<a href='https://discord.gg/by3deKx' target='_blank' title='Discord of Many Things' style='color: black;'><img src='/assets/discord.png' style='height:30px'/></a>
|
|
||||||
<a href='https://github.com/naturalcrit/homebrewery' target='_blank' title='Github' style='color: black; padding-left: 5px;'><img src='/assets/github.png' style='height:30px'/></a>
|
|
||||||
<a href='https://patreon.com/NaturalCrit' target='_blank' title='Patreon' style='color: black; padding-left: 5px;'><img src='/assets/patreon.png' style='height:30px'/></a>
|
|
||||||
<a href='https://www.reddit.com/r/homebrewery/' target='_blank' title='Reddit' style='color: black; padding-left: 5px;'><img src='/assets/reddit.png' style='height:30px'/></a>
|
|
||||||
}}
|
|
||||||
|
|
||||||
\page
|
\page
|
||||||
|
|
||||||
@@ -129,7 +123,9 @@ A blank line can be achieved with a run of one or more `:` alone on a line. More
|
|||||||
Much nicer than `<br><br><br><br><br>`
|
Much nicer than `<br><br><br><br><br>`
|
||||||
|
|
||||||
### Definition Lists
|
### Definition Lists
|
||||||
**Example** :: V3 uses HTML *definition lists* to create "lists" with hanging indents.
|
V3 uses HTML *definition lists* to create "lists" with hanging indents.
|
||||||
|
|
||||||
|
**Senses** :: Here is some text that is long and overflows into a second line, creating a "hanging indent".
|
||||||
|
|
||||||
### Column Breaks
|
### Column Breaks
|
||||||
Column and page breaks with `\column` and `\page`.
|
Column and page breaks with `\column` and `\page`.
|
||||||
@@ -157,9 +153,9 @@ These can be combined to span a cell across both columns and rows. Cells must ha
|
|||||||
| 6A | 6B ^| 6C |
|
| 6A | 6B ^| 6C |
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
Images must be hosted online somewhere, like [Imgur](https://www.imgur.com). You use the address to that image to reference it in your brew\*.
|
Images must be hosted online somewhere, like [Imgur](https://www.imgur.com). You use the address to that image to reference it in your brew\*. Images can be included using Markdown-style images.
|
||||||
|
|
||||||
Using *Curly Injection* you can assign an id, classes, or inline CSS properties to the Markdown image syntax.
|
Using *Curly Injection* you can assign an id, classes, or specific inline CSS properties to the image.
|
||||||
|
|
||||||
 {width:100px,border:"2px solid",border-radius:10px}
|
 {width:100px,border:"2px solid",border-radius:10px}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const Nav = require('naturalcrit/nav/nav.jsx');
|
|||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
|
||||||
|
|
||||||
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
||||||
const Editor = require('../../editor/editor.jsx');
|
const Editor = require('../../editor/editor.jsx');
|
||||||
@@ -157,24 +157,45 @@ const NewPage = createClass({
|
|||||||
const index = brew.text.indexOf('```\n\n');
|
const index = brew.text.indexOf('```\n\n');
|
||||||
brew.style = `${brew.style ? `${brew.style}\n` : ''}${brew.text.slice(7, index - 1)}`;
|
brew.style = `${brew.style ? `${brew.style}\n` : ''}${brew.text.slice(7, index - 1)}`;
|
||||||
brew.text = brew.text.slice(index + 5);
|
brew.text = brew.text.slice(index + 5);
|
||||||
}
|
};
|
||||||
|
|
||||||
brew.pageCount=((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
brew.pageCount=((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
||||||
|
|
||||||
const res = await request
|
if(this.state.saveGoogle) {
|
||||||
.post(`/api${this.state.saveGoogle ? '?transferToGoogle=true' : ''}`)
|
const res = await request
|
||||||
|
.post('/api/newGoogle/')
|
||||||
.send(brew)
|
.send(brew)
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
console.log(err.status === 401
|
||||||
|
? 'Not signed in!'
|
||||||
|
: 'Error Creating New Google Brew!');
|
||||||
this.setState({ isSaving: false, errors: err });
|
this.setState({ isSaving: false, errors: err });
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
if(!res) return;
|
|
||||||
|
|
||||||
brew = res.body;
|
brew = res.body;
|
||||||
localStorage.removeItem(BREWKEY);
|
localStorage.removeItem(BREWKEY);
|
||||||
localStorage.removeItem(STYLEKEY);
|
localStorage.removeItem(STYLEKEY);
|
||||||
localStorage.removeItem(METAKEY);
|
localStorage.removeItem(METAKEY);
|
||||||
window.location = `/edit/${brew.googleId ?? ''}${brew.editId}`;
|
window.location = `/edit/${brew.googleId}${brew.editId}`;
|
||||||
|
} else {
|
||||||
|
request.post('/api')
|
||||||
|
.send(brew)
|
||||||
|
.end((err, res)=>{
|
||||||
|
if(err){
|
||||||
|
this.setState({
|
||||||
|
isSaving : false
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.onbeforeunload = function(){};
|
||||||
|
brew = res.body;
|
||||||
|
localStorage.removeItem(BREWKEY);
|
||||||
|
localStorage.removeItem(STYLEKEY);
|
||||||
|
localStorage.removeItem(METAKEY);
|
||||||
|
window.location = `/edit/${brew.editId}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
renderSaveButton : function(){
|
renderSaveButton : function(){
|
||||||
@@ -187,26 +208,26 @@ const NewPage = createClass({
|
|||||||
console.log(errMsg);
|
console.log(errMsg);
|
||||||
} catch (e){}
|
} catch (e){}
|
||||||
|
|
||||||
// if(this.state.errors.status == '401'){
|
if(this.state.errors.status == '401'){
|
||||||
// return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
// Oops!
|
Oops!
|
||||||
// <div className='errorContainer' onClick={this.clearErrors}>
|
<div className='errorContainer' onClick={this.clearErrors}>
|
||||||
// You must be signed in to a Google account
|
You must be signed in to a Google account
|
||||||
// to save this to<br />Google Drive!<br />
|
to save this to<br />Google Drive!<br />
|
||||||
// <a target='_blank' rel='noopener noreferrer'
|
<a target='_blank' rel='noopener noreferrer'
|
||||||
// href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`}>
|
href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`}>
|
||||||
// <div className='confirm'>
|
<div className='confirm'>
|
||||||
// Sign In
|
Sign In
|
||||||
// </div>
|
</div>
|
||||||
// </a>
|
</a>
|
||||||
// <div className='deny'>
|
<div className='deny'>
|
||||||
// Not Now
|
Not Now
|
||||||
// </div>
|
</div>
|
||||||
// </div>
|
</div>
|
||||||
// </Nav.item>;
|
</Nav.item>;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if(this.state.errors.response.req.url.match(/^\/api.*Google.*$/m)){
|
if(this.state.errors.response.req.url.match(/^\/api\/.*Google.*$/m)){
|
||||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
Oops!
|
Oops!
|
||||||
<div className='errorContainer' onClick={this.clearErrors}>
|
<div className='errorContainer' onClick={this.clearErrors}>
|
||||||
@@ -270,7 +291,7 @@ const NewPage = createClass({
|
|||||||
<Nav.section>
|
<Nav.section>
|
||||||
{this.renderSaveButton()}
|
{this.renderSaveButton()}
|
||||||
{this.renderLocalPrintButton()}
|
{this.renderLocalPrintButton()}
|
||||||
<HelpNavItem />
|
<IssueNavItem />
|
||||||
<RecentNavItem />
|
<RecentNavItem />
|
||||||
<AccountNavItem />
|
<AccountNavItem />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const cx = require('classnames');
|
|||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
|
|
||||||
const googleDriveIcon = require('../../../../googleDrive.png');
|
const googleDriveIcon = require('../../../googleDrive.png');
|
||||||
const dedent = require('dedent-tabs').default;
|
const dedent = require('dedent-tabs').default;
|
||||||
|
|
||||||
const BrewItem = createClass({
|
const BrewItem = createClass({
|
||||||
@@ -31,11 +31,19 @@ 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.delete(`/api/${this.props.brew.googleId ?? ''}${this.props.brew.editId}`)
|
if(this.props.brew.googleId) {
|
||||||
.send()
|
request.get(`/api/removeGoogle/${this.props.brew.googleId}${this.props.brew.editId}`)
|
||||||
.end(function(err, res){
|
.send()
|
||||||
location.reload();
|
.end(function(err, res){
|
||||||
});
|
location.reload();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
request.delete(`/api/${this.props.brew.editId}`)
|
||||||
|
.send()
|
||||||
|
.end(function(err, res){
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
renderDeleteBrewLink : function(){
|
renderDeleteBrewLink : function(){
|
||||||
@@ -17,8 +17,6 @@
|
|||||||
-webkit-column-break-inside : avoid;
|
-webkit-column-break-inside : avoid;
|
||||||
page-break-inside : avoid;
|
page-break-inside : avoid;
|
||||||
break-inside : avoid;
|
break-inside : avoid;
|
||||||
box-shadow : 0px 4px 5px 0px #333;
|
|
||||||
background-color : #cab2802e;
|
|
||||||
.text {
|
.text {
|
||||||
min-height : 54px;
|
min-height : 54px;
|
||||||
h4{
|
h4{
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
|
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');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|
||||||
const ListPage = require('../basePages/listPage/listPage.jsx');
|
const moment = require('moment');
|
||||||
|
|
||||||
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');
|
||||||
@@ -11,7 +12,16 @@ const Navbar = require('../../navbar/navbar.jsx');
|
|||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
const Account = require('../../navbar/account.navitem.jsx');
|
const Account = require('../../navbar/account.navitem.jsx');
|
||||||
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const BrewItem = require('./brewItem/brewItem.jsx');
|
||||||
|
const ReportIssue = require('../../navbar/issue.navitem.jsx');
|
||||||
|
|
||||||
|
// const brew = {
|
||||||
|
// title : 'SUPER Long title woah now',
|
||||||
|
// authors : []
|
||||||
|
// };
|
||||||
|
|
||||||
|
//const BREWS = _.times(25, ()=>{ return brew;});
|
||||||
|
|
||||||
|
|
||||||
const UserPage = createClass({
|
const UserPage = createClass({
|
||||||
displayName : 'UserPage',
|
displayName : 'UserPage',
|
||||||
@@ -19,51 +29,163 @@ const UserPage = createClass({
|
|||||||
return {
|
return {
|
||||||
username : '',
|
username : '',
|
||||||
brews : [],
|
brews : [],
|
||||||
query : ''
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getInitialState : function() {
|
getInitialState : function() {
|
||||||
const usernameWithS = this.props.username + (this.props.username.endsWith('s') ? `'` : `'s`);
|
|
||||||
|
|
||||||
const brews = _.groupBy(this.props.brews, (brew)=>{
|
|
||||||
return (brew.published ? 'published' : 'private');
|
|
||||||
});
|
|
||||||
|
|
||||||
const brewCollection = [
|
|
||||||
{
|
|
||||||
title : `${usernameWithS} published brews`,
|
|
||||||
class : 'published',
|
|
||||||
brews : brews.published
|
|
||||||
}
|
|
||||||
];
|
|
||||||
if(this.props.username == global.account?.username){
|
|
||||||
brewCollection.push(
|
|
||||||
{
|
|
||||||
title : `${usernameWithS} unpublished brews`,
|
|
||||||
class : 'unpublished',
|
|
||||||
brews : brews.private
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
brewCollection : brewCollection
|
sortType : 'alpha',
|
||||||
|
sortDir : 'asc',
|
||||||
|
filterString : ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
getUsernameWithS : function() {
|
||||||
|
if(this.props.username.endsWith('s'))
|
||||||
|
return `${this.props.username}'`;
|
||||||
|
return `${this.props.username}'s`;
|
||||||
|
},
|
||||||
|
|
||||||
navItems : function() {
|
renderBrews : function(brews){
|
||||||
return <Navbar>
|
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
||||||
<Nav.section>
|
|
||||||
<NewBrew />
|
const sortedBrews = this.sortBrews(brews);
|
||||||
<HelpNavItem />
|
|
||||||
<RecentNavItem />
|
return _.map(sortedBrews, (brew, idx)=>{
|
||||||
<Account />
|
return <BrewItem brew={brew} key={idx}/>;
|
||||||
</Nav.section>
|
});
|
||||||
</Navbar>;
|
},
|
||||||
|
|
||||||
|
sortBrewOrder : function(brew){
|
||||||
|
if(!brew.title){brew.title = 'No Title';}
|
||||||
|
const mapping = {
|
||||||
|
'alpha' : _.deburr(brew.title.toLowerCase()),
|
||||||
|
'created' : moment(brew.createdAt).format(),
|
||||||
|
'updated' : moment(brew.updatedAt).format(),
|
||||||
|
'views' : brew.views,
|
||||||
|
'latest' : moment(brew.lastViewed).format()
|
||||||
|
};
|
||||||
|
return mapping[this.state.sortType];
|
||||||
|
},
|
||||||
|
|
||||||
|
sortBrews : function(brews){
|
||||||
|
return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSortOptionChange : function(event){
|
||||||
|
this.setState({
|
||||||
|
sortType : event.target.value
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSortDirChange : function(event){
|
||||||
|
this.setState({
|
||||||
|
sortDir : `${(this.state.sortDir == 'asc' ? 'desc' : 'asc')}`
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
renderSortOption : function(sortTitle, sortValue){
|
||||||
|
return <td>
|
||||||
|
<button
|
||||||
|
value={`${sortValue}`}
|
||||||
|
onClick={this.handleSortOptionChange}
|
||||||
|
className={`sortOption ${(this.state.sortType == sortValue ? 'active' : '')}`}
|
||||||
|
>
|
||||||
|
{`${sortTitle}`}
|
||||||
|
</button>
|
||||||
|
</td>;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFilterTextChange : function(e){
|
||||||
|
this.setState({
|
||||||
|
filterString : e.target.value
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
|
||||||
|
renderFilterOption : function(){
|
||||||
|
return <td>
|
||||||
|
<label className='filterOption'>
|
||||||
|
<i className='fas fa-search'></i>
|
||||||
|
<input
|
||||||
|
type='search'
|
||||||
|
placeholder='search title/description'
|
||||||
|
onChange={this.handleFilterTextChange}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</td>;
|
||||||
|
},
|
||||||
|
|
||||||
|
renderSortOptions : function(){
|
||||||
|
return <div className='sort-container'>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h6>Sort by :</h6>
|
||||||
|
</td>
|
||||||
|
{this.renderSortOption('Title', 'alpha')}
|
||||||
|
{this.renderSortOption('Created Date', 'created')}
|
||||||
|
{this.renderSortOption('Updated Date', 'updated')}
|
||||||
|
{this.renderSortOption('Views', 'views')}
|
||||||
|
{/* {this.renderSortOption('Latest', 'latest')} */}
|
||||||
|
<td>
|
||||||
|
<h6>Direction :</h6>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
onClick={this.handleSortDirChange}
|
||||||
|
className='sortDir'
|
||||||
|
>
|
||||||
|
{`${(this.state.sortDir == 'asc' ? '\u25B2 ASC' : '\u25BC DESC')}`}
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
{this.renderFilterOption()}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>;
|
||||||
|
},
|
||||||
|
|
||||||
|
getSortedBrews : function(){
|
||||||
|
const testString = _.deburr(this.state.filterString).toLowerCase();
|
||||||
|
const brewCollection = this.state.filterString ? _.filter(this.props.brews, (brew)=>{
|
||||||
|
return (_.deburr(brew.title).toLowerCase().includes(testString)) ||
|
||||||
|
(_.deburr(brew.description).toLowerCase().includes(testString));
|
||||||
|
}) : this.props.brews;
|
||||||
|
return _.groupBy(brewCollection, (brew)=>{
|
||||||
|
return (brew.published ? 'published' : 'private');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <ListPage brewCollection={this.state.brewCollection} navItems={this.navItems()} query={this.props.query}></ListPage>;
|
const brews = this.getSortedBrews();
|
||||||
|
|
||||||
|
return <div className='userPage sitePage'>
|
||||||
|
<link href='/themes/5ePhbLegacy.style.css' rel='stylesheet'/>
|
||||||
|
<Navbar>
|
||||||
|
<Nav.section>
|
||||||
|
<NewBrew />
|
||||||
|
<ReportIssue />
|
||||||
|
<RecentNavItem />
|
||||||
|
<Account />
|
||||||
|
</Nav.section>
|
||||||
|
</Navbar>
|
||||||
|
|
||||||
|
<div className='content V3'>
|
||||||
|
<div className='phb'>
|
||||||
|
{this.renderSortOptions()}
|
||||||
|
<div className='published'>
|
||||||
|
<h1>{this.getUsernameWithS()} published brews</h1>
|
||||||
|
{this.renderBrews(brews.published)}
|
||||||
|
</div>
|
||||||
|
{this.props.username == global.account?.username &&
|
||||||
|
<div className='unpublished'>
|
||||||
|
<h1>{this.getUsernameWithS()} unpublished brews</h1>
|
||||||
|
{this.renderBrews(brews.private)}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
-webkit-column-gap : auto;
|
-webkit-column-gap : auto;
|
||||||
-moz-column-gap : auto;
|
-moz-column-gap : auto;
|
||||||
}
|
}
|
||||||
.listPage{
|
.userPage{
|
||||||
.content{
|
.content{
|
||||||
overflow-y : scroll;
|
overflow-y : scroll;
|
||||||
.phb{
|
.phb{
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.9 KiB |
@@ -1,6 +1,4 @@
|
|||||||
module.exports = async(name, title = '', props = {})=>{
|
module.exports = async(name, title = '', props = {})=>{
|
||||||
const HOMEBREWERY_PUBLIC_URL=props.config.publicUrl;
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -9,13 +7,6 @@ module.exports = async(name, title = '', props = {})=>{
|
|||||||
<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 href=${`/${name}/bundle.css`} rel='stylesheet' />
|
||||||
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
|
||||||
<meta property="og:title" content="${props.brew?.title || 'Homebrewery - Untitled Brew'}">
|
|
||||||
<meta property="og:url" content="${HOMEBREWERY_PUBLIC_URL}/${props.brew?.shareId ? `share/${props.brew.shareId}` : ''}">
|
|
||||||
<meta property="og:image" content="${props.brew?.thumbnail || `${HOMEBREWERY_PUBLIC_URL}/thumbnail.png`}">
|
|
||||||
<meta property="og:description" content="${props.brew?.description || 'No description.'}">
|
|
||||||
<meta property="og:site_name" content="The Homebrewery - Make your Homebrew content look legit!">
|
|
||||||
<meta property="og:type" content="article">
|
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
|
||||||
<title>${title.length ? `${title} - The Homebrewery`: 'The Homebrewery - NaturalCrit'}</title>
|
<title>${title.length ? `${title} - The Homebrewery`: 'The Homebrewery - NaturalCrit'}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -3,7 +3,5 @@
|
|||||||
"naturalcrit_url" : "local.naturalcrit.com:8010",
|
"naturalcrit_url" : "local.naturalcrit.com:8010",
|
||||||
"secret" : "secret",
|
"secret" : "secret",
|
||||||
"web_port" : 8000,
|
"web_port" : 8000,
|
||||||
"enable_v3" : true,
|
"enable_v3" : true
|
||||||
"local_environments" : ["docker", "local"],
|
|
||||||
"publicUrl" : "https://homebrewery.naturalcrit.com"
|
|
||||||
}
|
}
|
||||||
|
|||||||
6684
package-lock.json
generated
6684
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
49
package.json
49
package.json
@@ -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.1.1",
|
"version": "3.0.6",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "16.11.x"
|
"node": "16.11.x"
|
||||||
},
|
},
|
||||||
@@ -20,9 +20,6 @@
|
|||||||
"verify": "npm run lint && npm test",
|
"verify": "npm run lint && npm test",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:dev": "jest --verbose --watch",
|
"test:dev": "jest --verbose --watch",
|
||||||
"test:basic": "jest tests/markdown/basic.test.js --verbose",
|
|
||||||
"test:mustache-span": "jest tests/markdown/mustache-span.test.js --verbose",
|
|
||||||
"test:route": "jest tests/routes/static-pages.test.js --verbose",
|
|
||||||
"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 buildall",
|
"postinstall": "npm run buildall",
|
||||||
@@ -34,7 +31,6 @@
|
|||||||
"build/*"
|
"build/*"
|
||||||
],
|
],
|
||||||
"jest": {
|
"jest": {
|
||||||
"testTimeout": 15000,
|
|
||||||
"modulePaths": [
|
"modulePaths": [
|
||||||
"mode_modules",
|
"mode_modules",
|
||||||
"shared",
|
"shared",
|
||||||
@@ -51,45 +47,46 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
"@babel/core": "^7.16.12",
|
||||||
"@babel/plugin-transform-runtime": "^7.18.2",
|
"@babel/plugin-transform-runtime": "^7.16.10",
|
||||||
"@babel/preset-env": "^7.18.2",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@babel/preset-react": "^7.17.12",
|
"@babel/preset-react": "^7.16.7",
|
||||||
"body-parser": "^1.20.0",
|
"body-parser": "^1.19.1",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"codemirror": "^5.65.5",
|
"codemirror": "^5.65.1",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"create-react-class": "^15.7.0",
|
"create-react-class": "^15.7.0",
|
||||||
"dedent-tabs": "^0.10.1",
|
"dedent-tabs": "^0.10.1",
|
||||||
"express": "^4.18.1",
|
"express": "^4.17.2",
|
||||||
"express-async-handler": "^1.2.0",
|
"express-async-handler": "^1.2.0",
|
||||||
"express-static-gzip": "2.1.7",
|
"express-static-gzip": "2.1.1",
|
||||||
"fs-extra": "10.1.0",
|
"fs-extra": "10.0.0",
|
||||||
"googleapis": "101.0.0",
|
"googleapis": "92.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
"less": "^3.13.1",
|
"less": "^3.13.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"marked": "4.0.16",
|
"marked": "4.0.11",
|
||||||
"marked-extended-tables": "^1.0.3",
|
"marked-extended-tables": "^1.0.3",
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.1",
|
||||||
"mongoose": "^6.3.6",
|
"mongoose": "^6.1.8",
|
||||||
"nanoid": "3.3.4",
|
"nanoid": "3.2.0",
|
||||||
"nconf": "^0.12.0",
|
"nconf": "^0.11.3",
|
||||||
"query-string": "7.1.1",
|
"prop-types": "15.8.0",
|
||||||
|
"query-string": "7.1.0",
|
||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
"react-dom": "^16.14.0",
|
"react-dom": "^16.14.0",
|
||||||
"react-frame-component": "4.1.3",
|
"react-frame-component": "5.2.2-alpha.0",
|
||||||
"react-router-dom": "5.3.0",
|
"react-router-dom": "5.3.0",
|
||||||
"sanitize-filename": "1.6.3",
|
"sanitize-filename": "1.6.3",
|
||||||
"superagent": "^6.1.0",
|
"superagent": "^6.1.0",
|
||||||
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
|
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.17.0",
|
"eslint": "^8.7.0",
|
||||||
"eslint-plugin-react": "^7.30.0",
|
"eslint-plugin-react": "^7.28.0",
|
||||||
"jest": "^28.1.1",
|
"jest": "^27.4.5",
|
||||||
"supertest": "^6.2.3"
|
"supertest": "^6.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ const build = async ({ bundle, render, ssr })=>{
|
|||||||
await fs.outputFile('./build/homebrew/bundle.js', bundle);
|
await fs.outputFile('./build/homebrew/bundle.js', bundle);
|
||||||
await fs.outputFile('./build/homebrew/ssr.js', ssr);
|
await fs.outputFile('./build/homebrew/ssr.js', ssr);
|
||||||
await fs.copy('./themes/fonts', './build/fonts');
|
await fs.copy('./themes/fonts', './build/fonts');
|
||||||
await fs.copy('./themes/assets', './build/assets');
|
|
||||||
let src = './themes/5ePhbLegacy.style.less';
|
let src = './themes/5ePhbLegacy.style.less';
|
||||||
//Parse brew theme files
|
//Parse brew theme files
|
||||||
less.render(fs.readFileSync(src).toString(), {
|
less.render(fs.readFileSync(src).toString(), {
|
||||||
@@ -74,6 +73,6 @@ pack('./client/homebrew/homebrew.jsx', {
|
|||||||
if(isDev){
|
if(isDev){
|
||||||
livereload('./build');
|
livereload('./build');
|
||||||
watchFile('./server.js', {
|
watchFile('./server.js', {
|
||||||
watch : ['./client', './server'] // Watch additional folders if you want
|
watch : ['./client'] // Watch additional folders if you want
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
"codemirror/addon/fold/foldcode.js",
|
"codemirror/addon/fold/foldcode.js",
|
||||||
"codemirror/addon/fold/foldgutter.js",
|
"codemirror/addon/fold/foldgutter.js",
|
||||||
"codemirror/addon/fold/xml-fold.js",
|
"codemirror/addon/fold/xml-fold.js",
|
||||||
"codemirror/addon/scroll/scrollpastend.js",
|
|
||||||
"codemirror/addon/search/search.js",
|
"codemirror/addon/search/search.js",
|
||||||
"codemirror/addon/search/searchcursor.js",
|
"codemirror/addon/search/searchcursor.js",
|
||||||
"codemirror/addon/search/jump-to-line.js",
|
"codemirror/addon/search/jump-to-line.js",
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
const DB = require('./server/db.js');
|
const DB = require('./server/db.js');
|
||||||
const server = require('./server/app.js');
|
const server = require('./server/app.js');
|
||||||
const config = require('./server/config.js');
|
|
||||||
|
const config = require('nconf')
|
||||||
|
.argv()
|
||||||
|
.env({ lowerCase: true })
|
||||||
|
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
||||||
|
.file('defaults', { file: 'config/default.json' });
|
||||||
|
|
||||||
DB.connect(config).then(()=>{
|
DB.connect(config).then(()=>{
|
||||||
// Ensure that we have successfully connected to the database
|
// Ensure that we have successfully connected to the database
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
||||||
// Set working directory to project root
|
|
||||||
process.chdir(`${__dirname}/..`);
|
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const jwt = require('jwt-simple');
|
const jwt = require('jwt-simple');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
const app = express();
|
const app = express();
|
||||||
const config = require('./config.js');
|
|
||||||
|
|
||||||
const homebrewApi = require('./homebrew.api.js');
|
const homebrewApi = require('./homebrew.api.js');
|
||||||
const GoogleActions = require('./googleActions.js');
|
const GoogleActions = require('./googleActions.js');
|
||||||
@@ -25,7 +21,7 @@ const getBrewFromId = asyncHandler(async (id, accessType)=>{
|
|||||||
if(id.length > 12) {
|
if(id.length > 12) {
|
||||||
const googleId = id.slice(0, -12);
|
const googleId = id.slice(0, -12);
|
||||||
id = id.slice(-12);
|
id = id.slice(-12);
|
||||||
brew = await GoogleActions.getGoogleBrew(googleId, id, accessType);
|
brew = await GoogleActions.readFileMetadata(config.get('google_api_key'), googleId, id, accessType);
|
||||||
} else {
|
} else {
|
||||||
brew = await HomebrewModel.get(accessType == 'edit' ? { editId: id } : { shareId: id });
|
brew = await HomebrewModel.get(accessType == 'edit' ? { editId: id } : { shareId: id });
|
||||||
brew = brew.toObject(); // Convert MongoDB object to standard Javascript Object
|
brew = brew.toObject(); // Convert MongoDB object to standard Javascript Object
|
||||||
@@ -66,13 +62,22 @@ const splitTextStyleAndMetadata = (brew)=>{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.use('/', serveCompressedStaticAssets(`build`));
|
app.use('/', serveCompressedStaticAssets(`${__dirname}/../build`));
|
||||||
|
|
||||||
|
process.chdir(__dirname);
|
||||||
|
|
||||||
//app.use(express.static(`${__dirname}/build`));
|
//app.use(express.static(`${__dirname}/build`));
|
||||||
app.use(require('body-parser').json({ limit: '25mb' }));
|
app.use(require('body-parser').json({ limit: '25mb' }));
|
||||||
app.use(require('cookie-parser')());
|
app.use(require('cookie-parser')());
|
||||||
app.use(require('./forcessl.mw.js'));
|
app.use(require('./forcessl.mw.js'));
|
||||||
|
|
||||||
|
// FIXME: the config should be passed as an argument for the app
|
||||||
|
const config = require('nconf')
|
||||||
|
.argv()
|
||||||
|
.env({ lowerCase: true })
|
||||||
|
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
||||||
|
.file('defaults', { file: 'config/default.json' });
|
||||||
|
|
||||||
//Account Middleware
|
//Account Middleware
|
||||||
app.use((req, res, next)=>{
|
app.use((req, res, next)=>{
|
||||||
if(req.cookies && req.cookies.nc_session){
|
if(req.cookies && req.cookies.nc_session){
|
||||||
@@ -94,17 +99,16 @@ app.use(homebrewApi);
|
|||||||
app.use(require('./admin.api.js'));
|
app.use(require('./admin.api.js'));
|
||||||
|
|
||||||
const HomebrewModel = require('./homebrew.model.js').model;
|
const HomebrewModel = require('./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 welcomeTextV3 = require('fs').readFileSync('client/homebrew/pages/homePage/welcome_msg_v3.md', 'utf8');
|
const welcomeTextV3 = require('fs').readFileSync('./../client/homebrew/pages/homePage/welcome_msg_v3.md', 'utf8');
|
||||||
const migrateText = require('fs').readFileSync('client/homebrew/pages/homePage/migrate.md', 'utf8');
|
const changelogText = require('fs').readFileSync('./../changelog.md', 'utf8');
|
||||||
const changelogText = require('fs').readFileSync('changelog.md', 'utf8');
|
const faqText = require('fs').readFileSync('./../faq.md', 'utf8');
|
||||||
const faqText = require('fs').readFileSync('faq.md', 'utf8');
|
|
||||||
|
|
||||||
String.prototype.replaceAll = function(s, r){return this.split(s).join(r);};
|
String.prototype.replaceAll = function(s, r){return this.split(s).join(r);};
|
||||||
|
|
||||||
//Robots.txt
|
//Robots.txt
|
||||||
app.get('/robots.txt', (req, res)=>{
|
app.get('/robots.txt', (req, res)=>{
|
||||||
return res.sendFile(`robots.txt`, { root: process.cwd() });
|
return res.sendFile(`${__dirname}/robots.txt`);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Home page
|
//Home page
|
||||||
@@ -127,17 +131,6 @@ app.get('/v3_preview', async (req, res, next)=>{
|
|||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Legacy/Other Document -> v3 Migration Guide
|
|
||||||
app.get('/migrate', async (req, res, next)=>{
|
|
||||||
const brew = {
|
|
||||||
text : migrateText,
|
|
||||||
renderer : 'V3'
|
|
||||||
};
|
|
||||||
splitTextStyleAndMetadata(brew);
|
|
||||||
req.brew = brew;
|
|
||||||
return next();
|
|
||||||
});
|
|
||||||
|
|
||||||
//Changelog page
|
//Changelog page
|
||||||
app.get('/changelog', async (req, res, next)=>{
|
app.get('/changelog', async (req, res, next)=>{
|
||||||
const brew = {
|
const brew = {
|
||||||
@@ -194,36 +187,19 @@ app.get('/download/:id', asyncHandler(async (req, res)=>{
|
|||||||
app.get('/user/:username', async (req, res, next)=>{
|
app.get('/user/:username', async (req, res, next)=>{
|
||||||
const ownAccount = req.account && (req.account.username == req.params.username);
|
const ownAccount = req.account && (req.account.username == req.params.username);
|
||||||
|
|
||||||
const fields = [
|
let brews = await HomebrewModel.getByUser(req.params.username, ownAccount)
|
||||||
'title',
|
|
||||||
'pageCount',
|
|
||||||
'description',
|
|
||||||
'authors',
|
|
||||||
'published',
|
|
||||||
'views',
|
|
||||||
'shareId',
|
|
||||||
'editId',
|
|
||||||
'createdAt',
|
|
||||||
'updatedAt',
|
|
||||||
'lastViewed'
|
|
||||||
];
|
|
||||||
|
|
||||||
let brews = await HomebrewModel.getByUser(req.params.username, ownAccount, fields)
|
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ownAccount && req?.account?.googleId){
|
if(ownAccount && req?.account?.googleId){
|
||||||
const auth = await GoogleActions.authCheck(req.account, res);
|
const googleBrews = await GoogleActions.listGoogleBrews(req, res)
|
||||||
let googleBrews = await GoogleActions.listGoogleBrews(auth)
|
.catch((err)=>{
|
||||||
.catch((err)=>{
|
console.error(err);
|
||||||
console.error(err);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if(googleBrews) {
|
if(googleBrews)
|
||||||
googleBrews = googleBrews.map((brew)=>({ ...brew, authors: [req.account.username] }));
|
|
||||||
brews = _.concat(brews, googleBrews);
|
brews = _.concat(brews, googleBrews);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req.brews = _.map(brews, (brew)=>{
|
req.brews = _.map(brews, (brew)=>{
|
||||||
@@ -273,31 +249,9 @@ app.get('/print/:id', asyncHandler(async (req, res, next)=>{
|
|||||||
return next();
|
return next();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
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
|
//Render the page
|
||||||
const templateFn = require('./../client/template.js');
|
const templateFn = require('./../client/template.js');
|
||||||
app.use((req, res)=>{
|
app.use((req, res)=>{
|
||||||
// Create configuration object
|
|
||||||
const configuration = {
|
|
||||||
local : isLocalEnvironment,
|
|
||||||
publicUrl : config.get('publicUrl') ?? '',
|
|
||||||
environment : nodeEnv
|
|
||||||
};
|
|
||||||
const props = {
|
const props = {
|
||||||
version : require('./../package.json').version,
|
version : require('./../package.json').version,
|
||||||
url : req.originalUrl,
|
url : req.originalUrl,
|
||||||
@@ -305,8 +259,7 @@ app.use((req, res)=>{
|
|||||||
brews : req.brews,
|
brews : req.brews,
|
||||||
googleBrews : req.googleBrews,
|
googleBrews : req.googleBrews,
|
||||||
account : req.account,
|
account : req.account,
|
||||||
enable_v3 : config.get('enable_v3'),
|
enable_v3 : config.get('enable_v3')
|
||||||
config : configuration
|
|
||||||
};
|
};
|
||||||
const title = req.brew ? req.brew.title : '';
|
const title = req.brew ? req.brew.title : '';
|
||||||
templateFn('homebrew', title, props)
|
templateFn('homebrew', title, props)
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
module.exports = require('nconf')
|
|
||||||
.argv()
|
|
||||||
.env({ lowerCase: true })
|
|
||||||
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
|
||||||
.file('defaults', { file: 'config/default.json' });
|
|
||||||
@@ -3,22 +3,13 @@ const _ = require('lodash');
|
|||||||
const { google } = require('googleapis');
|
const { google } = require('googleapis');
|
||||||
const { nanoid } = require('nanoid');
|
const { nanoid } = require('nanoid');
|
||||||
const token = require('./token.js');
|
const token = require('./token.js');
|
||||||
const config = require('./config.js');
|
const config = require('nconf')
|
||||||
|
.argv()
|
||||||
|
.env({ lowerCase: true }) // Load environment variables
|
||||||
|
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
||||||
|
.file('defaults', { file: 'config/default.json' });
|
||||||
|
|
||||||
const keys = typeof(config.get('service_account')) == 'string' ?
|
//let oAuth2Client;
|
||||||
JSON.parse(config.get('service_account')) :
|
|
||||||
config.get('service_account');
|
|
||||||
let serviceAuth;
|
|
||||||
try {
|
|
||||||
serviceAuth = google.auth.fromJSON(keys);
|
|
||||||
serviceAuth.scopes = [
|
|
||||||
'https://www.googleapis.com/auth/drive'
|
|
||||||
];
|
|
||||||
} catch (err) {
|
|
||||||
console.warn(err);
|
|
||||||
console.log('Please make sure that a Google Service Account is set up properly in your config files.');
|
|
||||||
}
|
|
||||||
google.options({ auth: serviceAuth || config.get('google_api_key') });
|
|
||||||
|
|
||||||
const GoogleActions = {
|
const GoogleActions = {
|
||||||
|
|
||||||
@@ -56,7 +47,7 @@ const GoogleActions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getGoogleFolder : async (auth)=>{
|
getGoogleFolder : async (auth)=>{
|
||||||
const drive = google.drive({ version: 'v3', auth });
|
const drive = google.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
fileMetadata = {
|
fileMetadata = {
|
||||||
'name' : 'Homebrewery',
|
'name' : 'Homebrewery',
|
||||||
@@ -92,8 +83,17 @@ const GoogleActions = {
|
|||||||
return folderId;
|
return folderId;
|
||||||
},
|
},
|
||||||
|
|
||||||
listGoogleBrews : async (auth)=>{
|
listGoogleBrews : async (req, res)=>{
|
||||||
const drive = google.drive({ version: 'v3', auth });
|
|
||||||
|
oAuth2Client = GoogleActions.authCheck(req.account, res);
|
||||||
|
|
||||||
|
//TODO: Change to service account to allow non-owners to view published files.
|
||||||
|
// Requires a driveId parameter in the drive.files.list command
|
||||||
|
// const keys = JSON.parse(config.get('service_account'));
|
||||||
|
// const auth = google.auth.fromJSON(keys);
|
||||||
|
// auth.scopes = ['https://www.googleapis.com/auth/drive'];
|
||||||
|
|
||||||
|
const drive = google.drive({ version: 'v3', auth: oAuth2Client });
|
||||||
|
|
||||||
const obj = await drive.files.list({
|
const obj = await drive.files.list({
|
||||||
pageSize : 1000,
|
pageSize : 1000,
|
||||||
@@ -101,18 +101,18 @@ const GoogleActions = {
|
|||||||
q : 'mimeType != \'application/vnd.google-apps.folder\' and trashed = false'
|
q : 'mimeType != \'application/vnd.google-apps.folder\' and trashed = false'
|
||||||
})
|
})
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(`Error Listing Google Brews`);
|
console.log(`Error Listing Google Brews`);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
throw (err);
|
throw (err);
|
||||||
//TODO: Should break out here, but continues on for some reason.
|
//TODO: Should break out here, but continues on for some reason.
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!obj.data.files.length) {
|
if(!obj.data.files.length) {
|
||||||
console.log('No files found.');
|
console.log('No files found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const brews = obj.data.files.map((file)=>{
|
const brews = obj.data.files.map((file)=>{
|
||||||
return {
|
return {
|
||||||
text : '',
|
text : '',
|
||||||
shareId : file.properties.shareId,
|
shareId : file.properties.shareId,
|
||||||
editId : file.properties.editId,
|
editId : file.properties.editId,
|
||||||
@@ -126,49 +126,65 @@ const GoogleActions = {
|
|||||||
views : parseInt(file.properties.views),
|
views : parseInt(file.properties.views),
|
||||||
tags : '',
|
tags : '',
|
||||||
published : file.properties.published ? file.properties.published == 'true' : false,
|
published : file.properties.published ? file.properties.published == 'true' : false,
|
||||||
systems : [],
|
authors : [req.account.username], //TODO: properly save and load authors to google drive
|
||||||
thumbnail : file.properties.thumbnail
|
systems : []
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return brews;
|
return brews;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateGoogleBrew : async (brew)=>{
|
existsGoogleBrew : async (auth, id)=>{
|
||||||
const drive = google.drive({ version: 'v3' });
|
const drive = google.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
await drive.files.update({
|
const result = await drive.files.get({ fileId: id })
|
||||||
fileId : brew.googleId,
|
|
||||||
resource : {
|
|
||||||
name : `${brew.title}.txt`,
|
|
||||||
description : `${brew.description}`,
|
|
||||||
properties : {
|
|
||||||
title : brew.title,
|
|
||||||
published : brew.published,
|
|
||||||
version : brew.version,
|
|
||||||
renderer : brew.renderer,
|
|
||||||
tags : brew.tags,
|
|
||||||
pageCount : brew.pageCount,
|
|
||||||
systems : brew.systems.join(),
|
|
||||||
thumbnail : brew.thumbnail
|
|
||||||
}
|
|
||||||
},
|
|
||||||
media : {
|
|
||||||
mimeType : 'text/plain',
|
|
||||||
body : brew.text
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log('Error saving to google');
|
console.log('error checking file exists...');
|
||||||
console.error(err);
|
console.error(err);
|
||||||
throw (err);
|
return false;
|
||||||
//return res.status(500).send('Error while saving');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(result){return true;}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateGoogleBrew : async (auth, brew)=>{
|
||||||
|
const drive = google.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
|
if(await GoogleActions.existsGoogleBrew(auth, brew.googleId) == true) {
|
||||||
|
await drive.files.update({
|
||||||
|
fileId : brew.googleId,
|
||||||
|
resource : {
|
||||||
|
name : `${brew.title}.txt`,
|
||||||
|
description : `${brew.description}`,
|
||||||
|
properties : {
|
||||||
|
title : brew.title,
|
||||||
|
published : brew.published,
|
||||||
|
version : brew.version,
|
||||||
|
renderer : brew.renderer,
|
||||||
|
tags : brew.tags,
|
||||||
|
pageCount : brew.pageCount,
|
||||||
|
systems : brew.systems.join()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
media : {
|
||||||
|
mimeType : 'text/plain',
|
||||||
|
body : brew.text
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log('Error saving to google');
|
||||||
|
console.error(err);
|
||||||
|
throw (err);
|
||||||
|
//return res.status(500).send('Error while saving');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (brew);
|
return (brew);
|
||||||
},
|
},
|
||||||
|
|
||||||
newGoogleBrew : async (auth, brew)=>{
|
newGoogleBrew : async (auth, brew)=>{
|
||||||
const drive = google.drive({ version: 'v3', auth });
|
const drive = google.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
const media = {
|
const media = {
|
||||||
mimeType : 'text/plain',
|
mimeType : 'text/plain',
|
||||||
@@ -182,13 +198,12 @@ const GoogleActions = {
|
|||||||
'description' : `${brew.description}`,
|
'description' : `${brew.description}`,
|
||||||
'parents' : [folderId],
|
'parents' : [folderId],
|
||||||
'properties' : { //AppProperties is not accessible
|
'properties' : { //AppProperties is not accessible
|
||||||
'shareId' : brew.shareId || nanoid(12),
|
'shareId' : nanoid(12),
|
||||||
'editId' : brew.editId || nanoid(12),
|
'editId' : nanoid(12),
|
||||||
'title' : brew.title,
|
'title' : brew.title,
|
||||||
'views' : '0',
|
'views' : '0',
|
||||||
'pageCount' : brew.pageCount,
|
'pageCount' : brew.pageCount,
|
||||||
'renderer' : brew.renderer || 'legacy',
|
'renderer' : brew.renderer || 'legacy'
|
||||||
'thumbnail' : brew.thumbnail || ''
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -237,8 +252,9 @@ const GoogleActions = {
|
|||||||
return newHomebrew;
|
return newHomebrew;
|
||||||
},
|
},
|
||||||
|
|
||||||
getGoogleBrew : async (id, accessId, accessType)=>{
|
readFileMetadata : async (auth, id, accessId, accessType)=>{
|
||||||
const drive = google.drive({ version: 'v3' });
|
|
||||||
|
const drive = google.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
const obj = await drive.files.get({
|
const obj = await drive.files.get({
|
||||||
fileId : id,
|
fileId : id,
|
||||||
@@ -257,7 +273,16 @@ const GoogleActions = {
|
|||||||
throw ('Share ID does not match');
|
throw ('Share ID does not match');
|
||||||
}
|
}
|
||||||
|
|
||||||
const serviceDrive = google.drive({ version: 'v3' });
|
//Access file using service account. Using API key only causes "automated query" lockouts after a while.
|
||||||
|
|
||||||
|
const keys = typeof(config.get('service_account')) == 'string' ?
|
||||||
|
JSON.parse(config.get('service_account')) :
|
||||||
|
config.get('service_account');
|
||||||
|
|
||||||
|
const serviceAuth = google.auth.fromJSON(keys);
|
||||||
|
serviceAuth.scopes = ['https://www.googleapis.com/auth/drive'];
|
||||||
|
|
||||||
|
const serviceDrive = google.drive({ version: 'v3', auth: serviceAuth });
|
||||||
|
|
||||||
const file = await serviceDrive.files.get({
|
const file = await serviceDrive.files.get({
|
||||||
fileId : id,
|
fileId : id,
|
||||||
@@ -289,7 +314,6 @@ const GoogleActions = {
|
|||||||
views : parseInt(obj.data.properties.views) || 0, //brews with no view parameter will return undefined
|
views : parseInt(obj.data.properties.views) || 0, //brews with no view parameter will return undefined
|
||||||
version : parseInt(obj.data.properties.version) || 0,
|
version : parseInt(obj.data.properties.version) || 0,
|
||||||
renderer : obj.data.properties.renderer ? obj.data.properties.renderer : 'legacy',
|
renderer : obj.data.properties.renderer ? obj.data.properties.renderer : 'legacy',
|
||||||
thumbnail : obj.data.properties.thumbnail || '',
|
|
||||||
|
|
||||||
gDrive : true,
|
gDrive : true,
|
||||||
googleId : id
|
googleId : id
|
||||||
@@ -299,8 +323,10 @@ const GoogleActions = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteGoogleBrew : async (auth, id)=>{
|
deleteGoogleBrew : async (req, res, id)=>{
|
||||||
const drive = google.drive({ version: 'v3', auth });
|
|
||||||
|
oAuth2Client = GoogleActions.authCheck(req.account, res);
|
||||||
|
const drive = google.drive({ version: 'v3', auth: oAuth2Client });
|
||||||
|
|
||||||
const googleId = id.slice(0, -12);
|
const googleId = id.slice(0, -12);
|
||||||
const accessId = id.slice(-12);
|
const accessId = id.slice(-12);
|
||||||
@@ -312,6 +338,7 @@ const GoogleActions = {
|
|||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log('Error loading from Google');
|
console.log('Error loading from Google');
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(obj && obj.data.properties.editId != accessId) {
|
if(obj && obj.data.properties.editId != accessId) {
|
||||||
@@ -326,10 +353,21 @@ const GoogleActions = {
|
|||||||
console.log('Can\'t delete Google file');
|
console.log('Can\'t delete Google file');
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return res.status(200).send();
|
||||||
},
|
},
|
||||||
|
|
||||||
increaseView : async (id, accessId, accessType, brew)=>{
|
increaseView : async (id, accessId, accessType, brew)=>{
|
||||||
const drive = google.drive({ version: 'v3' });
|
//service account because this is modifying another user's file properties
|
||||||
|
//so we need extended scope
|
||||||
|
const keys = typeof(config.get('service_account')) == 'string' ?
|
||||||
|
JSON.parse(config.get('service_account')) :
|
||||||
|
config.get('service_account');
|
||||||
|
|
||||||
|
const auth = google.auth.fromJSON(keys);
|
||||||
|
auth.scopes = ['https://www.googleapis.com/auth/drive'];
|
||||||
|
|
||||||
|
const drive = google.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
await drive.files.update({
|
await drive.files.update({
|
||||||
fileId : brew.googleId,
|
fileId : brew.googleId,
|
||||||
@@ -346,6 +384,8 @@ const GoogleActions = {
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
//return res.status(500).send('Error while saving');
|
//return res.status(500).send('Error while saving');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const zlib = require('zlib');
|
|||||||
const GoogleActions = require('./googleActions.js');
|
const GoogleActions = require('./googleActions.js');
|
||||||
const Markdown = require('../shared/naturalcrit/markdown.js');
|
const Markdown = require('../shared/naturalcrit/markdown.js');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
const asyncHandler = require('express-async-handler');
|
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -42,195 +41,154 @@ const excludePropsFromUpdate = (brew)=>{
|
|||||||
const propsToExclude = ['views', 'lastViewed'];
|
const propsToExclude = ['views', 'lastViewed'];
|
||||||
for (const prop of propsToExclude) {
|
for (const prop of propsToExclude) {
|
||||||
delete brew[prop];
|
delete brew[prop];
|
||||||
}
|
};
|
||||||
return brew;
|
return brew;
|
||||||
};
|
};
|
||||||
|
|
||||||
const beforeNewSave = (account, brew)=>{
|
const newBrew = (req, res)=>{
|
||||||
|
const brew = req.body;
|
||||||
|
|
||||||
if(!brew.title) {
|
if(!brew.title) {
|
||||||
brew.title = getGoodBrewTitle(brew.text);
|
brew.title = getGoodBrewTitle(brew.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
brew.authors = (account) ? [account.username] : [];
|
brew.authors = (req.account) ? [req.account.username] : [];
|
||||||
brew.text = mergeBrewText(brew);
|
brew.text = mergeBrewText(brew);
|
||||||
};
|
|
||||||
|
|
||||||
const newLocalBrew = async (brew)=>{
|
delete brew.editId;
|
||||||
|
delete brew.shareId;
|
||||||
|
delete brew.googleId;
|
||||||
|
|
||||||
const newHomebrew = new HomebrewModel(brew);
|
const newHomebrew = new HomebrewModel(brew);
|
||||||
// Compress brew text to binary before saving
|
// Compress brew text to binary before saving
|
||||||
newHomebrew.textBin = zlib.deflateRawSync(newHomebrew.text);
|
newHomebrew.textBin = zlib.deflateRawSync(newHomebrew.text);
|
||||||
// Delete the non-binary text field since it's not needed anymore
|
// Delete the non-binary text field since it's not needed anymore
|
||||||
newHomebrew.text = undefined;
|
newHomebrew.text = undefined;
|
||||||
|
|
||||||
let saved = await newHomebrew.save()
|
newHomebrew.save((err, obj)=>{
|
||||||
.catch((err)=>{
|
if(err) {
|
||||||
console.error(err, err.toString(), err.stack);
|
console.error(err, err.toString(), err.stack);
|
||||||
throw `Error while creating new brew, ${err.toString()}`;
|
return res.status(500).send(`Error while creating new brew, ${err.toString()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = obj.toObject();
|
||||||
|
obj.gDrive = false;
|
||||||
|
return res.status(200).send(obj);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateBrew = (req, res)=>{
|
||||||
|
HomebrewModel.get({ editId: req.params.id })
|
||||||
|
.then((brew)=>{
|
||||||
|
const updateBrew = excludePropsFromUpdate(req.body);
|
||||||
|
brew = _.merge(brew, updateBrew);
|
||||||
|
brew.text = mergeBrewText(brew);
|
||||||
|
|
||||||
|
// Compress brew text to binary before saving
|
||||||
|
brew.textBin = zlib.deflateRawSync(brew.text);
|
||||||
|
// Delete the non-binary text field since it's not needed anymore
|
||||||
|
brew.text = undefined;
|
||||||
|
brew.updatedAt = new Date();
|
||||||
|
|
||||||
|
if(req.account) {
|
||||||
|
brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
|
||||||
|
}
|
||||||
|
|
||||||
|
brew.markModified('authors');
|
||||||
|
brew.markModified('systems');
|
||||||
|
|
||||||
|
brew.save((err, obj)=>{
|
||||||
|
if(err) throw err;
|
||||||
|
return res.status(200).send(obj);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.error(err);
|
||||||
|
return res.status(500).send('Error while saving');
|
||||||
});
|
});
|
||||||
|
|
||||||
saved = saved.toObject();
|
|
||||||
saved.gDrive = false;
|
|
||||||
return saved;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const newGoogleBrew = async (account, brew, res)=>{
|
const deleteBrew = (req, res)=>{
|
||||||
const oAuth2Client = GoogleActions.authCheck(account, res);
|
HomebrewModel.find({ editId: req.params.id }, (err, objs)=>{
|
||||||
|
if(!objs.length || err) {
|
||||||
|
return res.status(404).send('Can not find homebrew with that id');
|
||||||
|
}
|
||||||
|
|
||||||
return await GoogleActions.newGoogleBrew(oAuth2Client, brew);
|
const brew = objs[0];
|
||||||
|
|
||||||
|
if(req.account) {
|
||||||
|
// Remove current user as author
|
||||||
|
brew.authors = _.pull(brew.authors, req.account.username);
|
||||||
|
brew.markModified('authors');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(brew.authors.length === 0) {
|
||||||
|
// Delete brew if there are no authors left
|
||||||
|
brew.remove((err)=>{
|
||||||
|
if(err) return res.status(500).send('Error while removing');
|
||||||
|
return res.status(200).send();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Otherwise, save the brew with updated author list
|
||||||
|
brew.save((err, savedBrew)=>{
|
||||||
|
if(err) throw err;
|
||||||
|
return res.status(200).send(savedBrew);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const newBrew = async (req, res)=>{
|
const newGoogleBrew = async (req, res, next)=>{
|
||||||
|
let oAuth2Client;
|
||||||
|
|
||||||
|
try { oAuth2Client = GoogleActions.authCheck(req.account, res); } catch (err) { return res.status(err.status).send(err.message); }
|
||||||
|
|
||||||
const brew = req.body;
|
const brew = req.body;
|
||||||
const { transferToGoogle } = req.query;
|
|
||||||
|
if(!brew.title) {
|
||||||
|
brew.title = getGoodBrewTitle(brew.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
brew.authors = (req.account) ? [req.account.username] : [];
|
||||||
|
brew.text = mergeBrewText(brew);
|
||||||
|
|
||||||
delete brew.editId;
|
delete brew.editId;
|
||||||
delete brew.shareId;
|
delete brew.shareId;
|
||||||
delete brew.googleId;
|
delete brew.googleId;
|
||||||
|
|
||||||
beforeNewSave(req.account, brew);
|
req.body = brew;
|
||||||
|
|
||||||
let saved;
|
try {
|
||||||
if(transferToGoogle) {
|
const newBrew = await GoogleActions.newGoogleBrew(oAuth2Client, brew);
|
||||||
saved = await newGoogleBrew(req.account, brew, res)
|
return res.status(200).send(newBrew);
|
||||||
.catch((err)=>{
|
} catch (err) {
|
||||||
res.status(err.status || err.response.status).send(err.message || err);
|
return res.status(err.response.status).send(err);
|
||||||
});
|
|
||||||
} else {
|
|
||||||
saved = await newLocalBrew(brew)
|
|
||||||
.catch((err)=>{
|
|
||||||
res.status(500).send(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(!saved) return;
|
|
||||||
return res.status(200).send(saved);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateBrew = async (req, res)=>{
|
|
||||||
let brew = excludePropsFromUpdate(req.body);
|
|
||||||
const { transferToGoogle, transferFromGoogle } = req.query;
|
|
||||||
|
|
||||||
let saved;
|
|
||||||
if(brew.googleId && transferFromGoogle) {
|
|
||||||
beforeNewSave(req.account, brew);
|
|
||||||
|
|
||||||
saved = await newLocalBrew(brew)
|
|
||||||
.catch((err)=>{
|
|
||||||
console.error(err);
|
|
||||||
res.status(500).send(err);
|
|
||||||
});
|
|
||||||
if(!saved) return;
|
|
||||||
|
|
||||||
await deleteGoogleBrew(req.account, `${brew.googleId}${brew.editId}`, res)
|
|
||||||
.catch((err)=>{
|
|
||||||
console.error(err);
|
|
||||||
res.status(err.status || err.response.status).send(err.message || err);
|
|
||||||
});
|
|
||||||
} else if(!brew.googleId && transferToGoogle) {
|
|
||||||
saved = await newGoogleBrew(req.account, brew, res)
|
|
||||||
.catch((err)=>{
|
|
||||||
console.error(err);
|
|
||||||
res.status(err.status || err.response.status).send(err.message || err);
|
|
||||||
});
|
|
||||||
if(!saved) return;
|
|
||||||
|
|
||||||
await deleteLocalBrew(req.account, brew.editId)
|
|
||||||
.catch((err)=>{
|
|
||||||
console.error(err);
|
|
||||||
res.status(err.status).send(err.message);
|
|
||||||
});
|
|
||||||
} else if(brew.googleId) {
|
|
||||||
brew.text = mergeBrewText(brew);
|
|
||||||
|
|
||||||
saved = await GoogleActions.updateGoogleBrew(brew)
|
|
||||||
.catch((err)=>{
|
|
||||||
console.error(err);
|
|
||||||
res.status(err.response?.status || 500).send(err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const dbBrew = await HomebrewModel.get({ editId: req.params.id })
|
|
||||||
.catch((err)=>{
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).send('Error while saving');
|
|
||||||
});
|
|
||||||
|
|
||||||
brew = _.merge(dbBrew, brew);
|
|
||||||
brew.text = mergeBrewText(brew);
|
|
||||||
|
|
||||||
// Compress brew text to binary before saving
|
|
||||||
brew.textBin = zlib.deflateRawSync(brew.text);
|
|
||||||
// Delete the non-binary text field since it's not needed anymore
|
|
||||||
brew.text = undefined;
|
|
||||||
brew.updatedAt = new Date();
|
|
||||||
|
|
||||||
if(req.account) {
|
|
||||||
brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
|
|
||||||
}
|
|
||||||
|
|
||||||
brew.markModified('authors');
|
|
||||||
brew.markModified('systems');
|
|
||||||
|
|
||||||
saved = await brew.save();
|
|
||||||
}
|
|
||||||
if(!saved) return;
|
|
||||||
|
|
||||||
if(!res.headersSent) return res.status(200).send(saved);
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteBrew = async (req, res)=>{
|
|
||||||
if(req.params.id.length > 12) {
|
|
||||||
const deleted = await deleteGoogleBrew(req.account, req.params.id, res)
|
|
||||||
.catch((err)=>{
|
|
||||||
res.status(500).send(err);
|
|
||||||
});
|
|
||||||
if(deleted) return res.status(200).send();
|
|
||||||
} else {
|
|
||||||
const deleted = await deleteLocalBrew(req.account, req.params.id)
|
|
||||||
.catch((err)=>{
|
|
||||||
res.status(err.status).send(err.message);
|
|
||||||
});
|
|
||||||
if(deleted) return res.status(200).send(deleted);
|
|
||||||
return res.status(200).send();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteLocalBrew = async (account, id)=>{
|
const updateGoogleBrew = async (req, res, next)=>{
|
||||||
const brew = await HomebrewModel.findOne({ editId: id });
|
let oAuth2Client;
|
||||||
if(!brew) {
|
|
||||||
throw { status: 404, message: 'Can not find homebrew with that id' };
|
|
||||||
}
|
|
||||||
|
|
||||||
if(account) {
|
try { oAuth2Client = GoogleActions.authCheck(req.account, res); } catch (err) { return res.status(err.status).send(err.message); }
|
||||||
// Remove current user as author
|
|
||||||
brew.authors = _.pull(brew.authors, account.username);
|
|
||||||
brew.markModified('authors');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(brew.authors.length === 0) {
|
const brew = excludePropsFromUpdate(req.body);
|
||||||
// Delete brew if there are no authors left
|
brew.text = mergeBrewText(brew);
|
||||||
await brew.remove()
|
|
||||||
.catch((err)=>{
|
try {
|
||||||
console.error(err);
|
const updatedBrew = await GoogleActions.updateGoogleBrew(oAuth2Client, brew);
|
||||||
throw { status: 500, message: 'Error while removing' };
|
return res.status(200).send(updatedBrew);
|
||||||
});
|
} catch (err) {
|
||||||
} else {
|
return res.status(err.response?.status || 500).send(err);
|
||||||
// Otherwise, save the brew with updated author list
|
|
||||||
return await brew.save()
|
|
||||||
.catch((err)=>{
|
|
||||||
throw { status: 500, message: err };
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteGoogleBrew = async (account, id, res)=>{
|
router.post('/api', newBrew);
|
||||||
const auth = await GoogleActions.authCheck(account, res);
|
router.post('/api/newGoogle/', newGoogleBrew);
|
||||||
await GoogleActions.deleteGoogleBrew(auth, id);
|
router.put('/api/:id', updateBrew);
|
||||||
return true;
|
router.put('/api/update/:id', updateBrew);
|
||||||
};
|
router.put('/api/updateGoogle/:id', updateGoogleBrew);
|
||||||
|
router.delete('/api/:id', deleteBrew);
|
||||||
router.post('/api', asyncHandler(newBrew));
|
router.get('/api/remove/:id', deleteBrew);
|
||||||
router.put('/api/:id', asyncHandler(updateBrew));
|
router.get('/api/removeGoogle/:id', (req, res)=>{GoogleActions.deleteGoogleBrew(req, res, req.params.id);});
|
||||||
router.put('/api/update/:id', asyncHandler(updateBrew));
|
|
||||||
router.delete('/api/:id', asyncHandler(deleteBrew));
|
|
||||||
router.get('/api/remove/:id', asyncHandler(deleteBrew));
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const HomebrewSchema = mongoose.Schema({
|
|||||||
renderer : { type: String, default: '' },
|
renderer : { type: String, default: '' },
|
||||||
authors : [String],
|
authors : [String],
|
||||||
published : { type: Boolean, default: false },
|
published : { type: Boolean, default: false },
|
||||||
thumbnail : { type: String, default: '' },
|
|
||||||
|
|
||||||
createdAt : { type: Date, default: Date.now },
|
createdAt : { type: Date, default: Date.now },
|
||||||
updatedAt : { type: Date, default: Date.now },
|
updatedAt : { type: Date, default: Date.now },
|
||||||
@@ -37,9 +36,9 @@ HomebrewSchema.statics.increaseView = async function(query) {
|
|||||||
return brew;
|
return brew;
|
||||||
};
|
};
|
||||||
|
|
||||||
HomebrewSchema.statics.get = function(query, fields=null){
|
HomebrewSchema.statics.get = function(query){
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
Homebrew.find(query, fields, null, (err, brews)=>{
|
Homebrew.find(query, (err, brews)=>{
|
||||||
if(err || !brews.length) return reject('Can not find brew');
|
if(err || !brews.length) return reject('Can not find brew');
|
||||||
if(!_.isNil(brews[0].textBin)) { // Uncompress zipped text field
|
if(!_.isNil(brews[0].textBin)) { // Uncompress zipped text field
|
||||||
unzipped = zlib.inflateRawSync(brews[0].textBin);
|
unzipped = zlib.inflateRawSync(brews[0].textBin);
|
||||||
@@ -52,13 +51,13 @@ HomebrewSchema.statics.get = function(query, fields=null){
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
HomebrewSchema.statics.getByUser = function(username, allowAccess=false, fields=null){
|
HomebrewSchema.statics.getByUser = function(username, allowAccess=false){
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
const query = { authors: username, published: true };
|
const query = { authors: username, published: true };
|
||||||
if(allowAccess){
|
if(allowAccess){
|
||||||
delete query.published;
|
delete query.published;
|
||||||
}
|
}
|
||||||
Homebrew.find(query, fields).lean().exec((err, brews)=>{ //lean() converts results to JSObjects
|
Homebrew.find(query).lean().exec((err, brews)=>{ //lean() converts results to JSObjects
|
||||||
if(err) return reject('Can not find brew');
|
if(err) return reject('Can not find brew');
|
||||||
return resolve(brews);
|
return resolve(brews);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
const jwt = require('jwt-simple');
|
const jwt = require('jwt-simple');
|
||||||
|
|
||||||
// Load configuration values
|
// Load configuration values
|
||||||
const config = require('./config.js');
|
const config = require('nconf')
|
||||||
|
.argv()
|
||||||
|
.env({ lowerCase: true }) // Load environment variables
|
||||||
|
.file('environment', { file: `config/${process.env.NODE_ENV}.json` })
|
||||||
|
.file('defaults', { file: 'config/default.json' });
|
||||||
|
|
||||||
// Generate an Access Token for the given User ID
|
// Generate an Access Token for the given User ID
|
||||||
const generateAccessToken = (account)=>{
|
const generateAccessToken = (account)=>{
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ if(typeof navigator !== 'undefined'){
|
|||||||
// require('codemirror/addon/edit/trailingspace.js');
|
// require('codemirror/addon/edit/trailingspace.js');
|
||||||
//Active line highlighting
|
//Active line highlighting
|
||||||
// require('codemirror/addon/selection/active-line.js');
|
// require('codemirror/addon/selection/active-line.js');
|
||||||
//Scroll past last line
|
|
||||||
require('codemirror/addon/scroll/scrollpastend.js');
|
|
||||||
//Auto-closing
|
//Auto-closing
|
||||||
//XML code folding is a requirement of the auto-closing tag feature and is not enabled
|
//XML code folding is a requirement of the auto-closing tag feature and is not enabled
|
||||||
require('codemirror/addon/fold/xml-fold.js');
|
require('codemirror/addon/fold/xml-fold.js');
|
||||||
@@ -100,7 +98,6 @@ const CodeEditor = createClass({
|
|||||||
indentWithTabs : true,
|
indentWithTabs : true,
|
||||||
tabSize : 2,
|
tabSize : 2,
|
||||||
historyEventDelay : 250,
|
historyEventDelay : 250,
|
||||||
scrollPastEnd : true,
|
|
||||||
extraKeys : {
|
extraKeys : {
|
||||||
'Ctrl-B' : this.makeBold,
|
'Ctrl-B' : this.makeBold,
|
||||||
'Cmd-B' : this.makeBold,
|
'Cmd-B' : this.makeBold,
|
||||||
|
|||||||
@@ -3,11 +3,6 @@
|
|||||||
@import (less) 'codemirror/addon/search/matchesonscrollbar.css';
|
@import (less) 'codemirror/addon/search/matchesonscrollbar.css';
|
||||||
@import (less) 'codemirror/addon/dialog/dialog.css';
|
@import (less) 'codemirror/addon/dialog/dialog.css';
|
||||||
|
|
||||||
@keyframes sourceMoveAnimation {
|
|
||||||
50% {background-color: red; color: white;}
|
|
||||||
100% {background-color: unset; color: unset;}
|
|
||||||
}
|
|
||||||
|
|
||||||
.codeEditor{
|
.codeEditor{
|
||||||
.CodeMirror-foldmarker {
|
.CodeMirror-foldmarker {
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
@@ -15,11 +10,6 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sourceMoveFlash .CodeMirror-line{
|
|
||||||
animation-name: sourceMoveAnimation;
|
|
||||||
animation-duration: 0.4s;
|
|
||||||
}
|
|
||||||
|
|
||||||
//.cm-tab {
|
//.cm-tab {
|
||||||
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right;
|
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right;
|
||||||
//}
|
//}
|
||||||
@@ -29,4 +19,4 @@
|
|||||||
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAQAgMAAABW5NbuAAAACVBMVEVHcEwAAAAAAAAWawmTAAAAA3RSTlMAPBJ6PMxpAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAFUlEQVQI12NgwACcCQysASAEZGAAACMuAX06aCQUAAAAAElFTkSuQmCC) no-repeat right;
|
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAQAgMAAABW5NbuAAAACVBMVEVHcEwAAAAAAAAWawmTAAAAA3RSTlMAPBJ6PMxpAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAFUlEQVQI12NgwACcCQysASAEZGAAACMuAX06aCQUAAAAAElFTkSuQmCC) no-repeat right;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
@import '../styles/colors';
|
|
||||||
@keyframes glideDropDown {
|
@keyframes glideDropDown {
|
||||||
0% {transform : translate(0px, -100%);
|
0% {transform : translate(0px, -100%);
|
||||||
opacity : 0;
|
opacity : 0;
|
||||||
@@ -50,7 +49,6 @@ nav{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navItem{
|
.navItem{
|
||||||
#backgroundColors;
|
|
||||||
.animate(background-color);
|
.animate(background-color);
|
||||||
padding : 8px 12px;
|
padding : 8px 12px;
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
@@ -60,12 +58,30 @@ nav{
|
|||||||
color : white;
|
color : white;
|
||||||
text-decoration : none;
|
text-decoration : none;
|
||||||
text-transform : uppercase;
|
text-transform : uppercase;
|
||||||
line-height : 13px;
|
|
||||||
i{
|
i{
|
||||||
margin-left : 5px;
|
margin-left : 5px;
|
||||||
font-size : 13px;
|
font-size : 13px;
|
||||||
float : right;
|
|
||||||
}
|
}
|
||||||
|
&.tealLight:hover{ background-color : @tealLight };
|
||||||
|
&.teal:hover{ background-color : @teal };
|
||||||
|
&.greenLight:hover{ background-color : @greenLight };
|
||||||
|
&.green:hover{ background-color : @green };
|
||||||
|
&.blueLight:hover{ background-color : @blueLight };
|
||||||
|
&.blue:hover{ background-color : @blue };
|
||||||
|
&.purpleLight:hover{ background-color : @purpleLight };
|
||||||
|
&.purple:hover{ background-color : @purple };
|
||||||
|
&.steelLight:hover{ background-color : @steelLight };
|
||||||
|
&.steel:hover{ background-color : @steel };
|
||||||
|
&.yellowLight:hover{ background-color : @yellowLight };
|
||||||
|
&.yellow:hover{ background-color : @yellow };
|
||||||
|
&.orangeLight:hover{ background-color : @orangeLight };
|
||||||
|
&.orange:hover{ background-color : @orange };
|
||||||
|
&.redLight:hover{ background-color : @redLight };
|
||||||
|
&.red:hover{ background-color : @red };
|
||||||
|
&.silverLight:hover{ background-color : @silverLight };
|
||||||
|
&.silver:hover{ background-color : @silver };
|
||||||
|
&.greyLight:hover{ background-color : @greyLight };
|
||||||
|
&.grey:hover{ background-color : @grey };
|
||||||
}
|
}
|
||||||
.navSection:last-child .navItem{
|
.navSection:last-child .navItem{
|
||||||
border-left : 1px solid #666;
|
border-left : 1px solid #666;
|
||||||
|
|||||||
@@ -10,77 +10,43 @@ const SplitPane = createClass({
|
|||||||
return {
|
return {
|
||||||
storageKey : 'naturalcrit-pane-split',
|
storageKey : 'naturalcrit-pane-split',
|
||||||
onDragFinish : function(){} //fires when dragging
|
onDragFinish : function(){} //fires when dragging
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState : function() {
|
getInitialState : function() {
|
||||||
return {
|
return {
|
||||||
currentDividerPos : null,
|
size : null,
|
||||||
windowWidth : 0,
|
isDragging : false
|
||||||
isDragging : false,
|
|
||||||
moveSource : false,
|
|
||||||
moveBrew : false,
|
|
||||||
showMoveArrows : true
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount : function() {
|
componentDidMount : function() {
|
||||||
const dividerPos = window.localStorage.getItem(this.props.storageKey);
|
const paneSize = window.localStorage.getItem(this.props.storageKey);
|
||||||
if(dividerPos){
|
if(paneSize){
|
||||||
this.setState({
|
this.setState({
|
||||||
currentDividerPos : this.limitPosition(dividerPos, 0.1*(window.innerWidth-13), 0.9*(window.innerWidth-13)),
|
size : paneSize
|
||||||
userSetDividerPos : dividerPos,
|
|
||||||
windowWidth : window.innerWidth
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
currentDividerPos : window.innerWidth / 2,
|
|
||||||
userSetDividerPos : window.innerWidth / 2
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.addEventListener('resize', this.handleWindowResize);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount : function() {
|
|
||||||
window.removeEventListener('resize', this.handleWindowResize);
|
|
||||||
},
|
|
||||||
|
|
||||||
handleWindowResize : function() {
|
|
||||||
// Allow divider to increase in size to last user-set position
|
|
||||||
// Limit current position to between 10% and 90% of visible space
|
|
||||||
const newLoc = this.limitPosition(this.state.userSetDividerPos, 0.1*(window.innerWidth-13), 0.9*(window.innerWidth-13));
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
currentDividerPos : newLoc,
|
|
||||||
windowWidth : window.innerWidth
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
limitPosition : function(x, min = 1, max = window.innerWidth - 13) {
|
|
||||||
const result = Math.round(Math.min(max, Math.max(min, x)));
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleUp : function(){
|
handleUp : function(){
|
||||||
if(this.state.isDragging){
|
if(this.state.isDragging){
|
||||||
this.props.onDragFinish(this.state.currentDividerPos);
|
this.props.onDragFinish(this.state.size);
|
||||||
window.localStorage.setItem(this.props.storageKey, this.state.currentDividerPos);
|
window.localStorage.setItem(this.props.storageKey, this.state.size);
|
||||||
}
|
}
|
||||||
this.setState({ isDragging: false });
|
this.setState({ isDragging: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDown : function(){
|
handleDown : function(){
|
||||||
this.setState({ isDragging: true });
|
this.setState({ isDragging: true });
|
||||||
//this.unFocus()
|
//this.unFocus()
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMove : function(e){
|
handleMove : function(e){
|
||||||
if(!this.state.isDragging) return;
|
if(!this.state.isDragging) return;
|
||||||
|
|
||||||
const newSize = this.limitPosition(e.pageX);
|
const minWidth = 1;
|
||||||
|
const maxWidth = window.innerWidth - 13;
|
||||||
|
const newSize = Math.min(maxWidth, Math.max(minWidth, e.pageX));
|
||||||
this.setState({
|
this.setState({
|
||||||
currentDividerPos : newSize,
|
size : newSize
|
||||||
userSetDividerPos : newSize
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
@@ -91,58 +57,20 @@ const SplitPane = createClass({
|
|||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
|
|
||||||
setMoveArrows : function(newState) {
|
|
||||||
if(this.state.showMoveArrows != newState){
|
|
||||||
this.setState({
|
|
||||||
showMoveArrows : newState
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
renderMoveArrows : function(){
|
|
||||||
if(this.state.showMoveArrows) {
|
|
||||||
return <>
|
|
||||||
<div className='arrow left'
|
|
||||||
style={{ left: this.state.currentDividerPos-4 }}
|
|
||||||
onClick={()=>this.setState({ moveSource: !this.state.moveSource })} >
|
|
||||||
<i className='fas fa-arrow-left' />
|
|
||||||
</div>
|
|
||||||
<div className='arrow right'
|
|
||||||
style={{ left: this.state.currentDividerPos-4 }}
|
|
||||||
onClick={()=>this.setState({ moveBrew: !this.state.moveBrew })} >
|
|
||||||
<i className='fas fa-arrow-right' />
|
|
||||||
</div>
|
|
||||||
</>;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
renderDivider : function(){
|
renderDivider : function(){
|
||||||
return <>
|
return <div className='divider' onMouseDown={this.handleDown} >
|
||||||
{this.renderMoveArrows()}
|
<div className='dots'>
|
||||||
<div className='divider' onMouseDown={this.handleDown} >
|
<i className='fas fa-circle' />
|
||||||
<div className='dots'>
|
<i className='fas fa-circle' />
|
||||||
<i className='fas fa-circle' />
|
<i className='fas fa-circle' />
|
||||||
<i className='fas fa-circle' />
|
|
||||||
<i className='fas fa-circle' />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div className='splitPane' onMouseMove={this.handleMove} onMouseUp={this.handleUp}>
|
return <div className='splitPane' onMouseMove={this.handleMove} onMouseUp={this.handleUp}>
|
||||||
<Pane
|
<Pane ref='pane1' width={this.state.size}>{this.props.children[0]}</Pane>
|
||||||
ref='pane1'
|
|
||||||
width={this.state.currentDividerPos}
|
|
||||||
>
|
|
||||||
{React.cloneElement(this.props.children[0], {
|
|
||||||
moveBrew : this.state.moveBrew,
|
|
||||||
moveSource : this.state.moveSource,
|
|
||||||
setMoveArrows : this.setMoveArrows
|
|
||||||
})}
|
|
||||||
</Pane>
|
|
||||||
{this.renderDivider()}
|
{this.renderDivider()}
|
||||||
<Pane ref='pane2' isDragging={this.state.isDragging}>{this.props.children[1]}</Pane>
|
<Pane ref='pane2' isDragging={this.state.isDragging}>{this.props.children[1]}</Pane>
|
||||||
</div>;
|
</div>;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
.divider{
|
.divider{
|
||||||
display : table;
|
display : table;
|
||||||
height : 100%;
|
height : 100%;
|
||||||
width : 15px;
|
width : 12px;
|
||||||
cursor : ew-resize;
|
cursor : ew-resize;
|
||||||
background-color : #bbb;
|
background-color : #bbb;
|
||||||
text-align : center;
|
text-align : center;
|
||||||
@@ -32,28 +32,4 @@
|
|||||||
background-color: #999;
|
background-color: #999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.arrow{
|
|
||||||
position : absolute;
|
|
||||||
width : 25px;
|
|
||||||
height : 25px;
|
|
||||||
border : 2px solid #bbb;
|
|
||||||
border-radius : 15px;
|
|
||||||
text-align : center;
|
|
||||||
font-size : 1.2em;
|
|
||||||
cursor : pointer;
|
|
||||||
background-color : #ddd;
|
|
||||||
z-index : 999;
|
|
||||||
box-shadow : 0 4px 5px #0000007f;
|
|
||||||
&.left{
|
|
||||||
.tooltipLeft('Jump to location in Editor');
|
|
||||||
top : 30px;
|
|
||||||
}
|
|
||||||
&.right{
|
|
||||||
.tooltipRight('Jump to location in Preview');
|
|
||||||
top : 60px;
|
|
||||||
}
|
|
||||||
&:hover{
|
|
||||||
background-color: #666;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,27 +20,4 @@
|
|||||||
@silverLight : #ECF0F1;
|
@silverLight : #ECF0F1;
|
||||||
@silver : #BDC3C7;
|
@silver : #BDC3C7;
|
||||||
@greyLight : #95A5A6;
|
@greyLight : #95A5A6;
|
||||||
@grey : #7F8C8D;
|
@grey : #7F8C8D;
|
||||||
|
|
||||||
#backgroundColors {
|
|
||||||
&.tealLight:hover{ background-color : @tealLight };
|
|
||||||
&.teal:hover{ background-color : @teal };
|
|
||||||
&.greenLight:hover{ background-color : @greenLight };
|
|
||||||
&.green:hover{ background-color : @green };
|
|
||||||
&.blueLight:hover{ background-color : @blueLight };
|
|
||||||
&.blue:hover{ background-color : @blue };
|
|
||||||
&.purpleLight:hover{ background-color : @purpleLight };
|
|
||||||
&.purple:hover{ background-color : @purple };
|
|
||||||
&.steelLight:hover{ background-color : @steelLight };
|
|
||||||
&.steel:hover{ background-color : @steel };
|
|
||||||
&.yellowLight:hover{ background-color : @yellowLight };
|
|
||||||
&.yellow:hover{ background-color : @yellow };
|
|
||||||
&.orangeLight:hover{ background-color : @orangeLight };
|
|
||||||
&.orange:hover{ background-color : @orange };
|
|
||||||
&.redLight:hover{ background-color : @redLight };
|
|
||||||
&.red:hover{ background-color : @red };
|
|
||||||
&.silverLight:hover{ background-color : @silverLight };
|
|
||||||
&.silver:hover{ background-color : @silver };
|
|
||||||
&.greyLight:hover{ background-color : @greyLight };
|
|
||||||
&.grey:hover{ background-color : @grey };
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,9 @@ describe('Tests for static pages', ()=>{
|
|||||||
return app.get('/faq').expect(200);
|
return app.get('/faq').expect(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('robots.txt works', ()=>{
|
// FIXME: robots.txt file can't be properly loaded under testing environment,
|
||||||
|
// most likely due to __dirname being different from what is expected
|
||||||
|
it.skip('robots.txt works', ()=>{
|
||||||
return app.get('/robots.txt').expect(200);
|
return app.get('/robots.txt').expect(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -545,6 +545,7 @@ body {
|
|||||||
-webkit-column-break-after : always;
|
-webkit-column-break-after : always;
|
||||||
break-after : always;
|
break-after : always;
|
||||||
-moz-column-break-after : always;
|
-moz-column-break-after : always;
|
||||||
|
break-before : column;
|
||||||
}
|
}
|
||||||
//Avoid breaking up
|
//Avoid breaking up
|
||||||
blockquote,table{
|
blockquote,table{
|
||||||
@@ -619,28 +620,25 @@ body {
|
|||||||
border-image-width : 47px;
|
border-image-width : 47px;
|
||||||
}
|
}
|
||||||
&.decoration {
|
&.decoration {
|
||||||
position:relative;
|
transform-style : preserve-3d;
|
||||||
}
|
}
|
||||||
&.decoration::before {
|
&.decoration::before {
|
||||||
content :'';
|
content :'';
|
||||||
position : absolute;
|
position : absolute;
|
||||||
background-image : @classTableDecoration,
|
background-image : @classTableDecoration;
|
||||||
@classTableDecoration;
|
background-size : contain;
|
||||||
background-size : contain, contain;
|
background-repeat : space;
|
||||||
background-repeat : no-repeat, no-repeat;
|
width : 7.75cm;
|
||||||
background-position : top, bottom;
|
height : calc(100% + 3.3cm);
|
||||||
width : 7.75cm;
|
top : 50%;
|
||||||
height : calc(100% + 3.3cm);
|
left : 50%;
|
||||||
top : 50%;
|
transform : translateY(-50%) translateX(-50%) translateZ(-1px);
|
||||||
left : 50%;
|
filter : drop-shadow(0px 0px 1px #C8C5C080)
|
||||||
transform : translateY(-50%) translateX(-50%);
|
|
||||||
filter : drop-shadow(0px 0px 1px #C8C5C080);
|
|
||||||
z-index : -1;
|
|
||||||
}
|
}
|
||||||
&.decoration.wide::before {
|
&.decoration.wide::before {
|
||||||
width : calc(100% + 3.3cm);
|
width : calc(100% + 3.3cm);
|
||||||
height : 7.75cm;
|
height : 7.75cm;
|
||||||
background-position : left, right;
|
top : calc(50% + 0.4cm);
|
||||||
}
|
}
|
||||||
h5 + table{
|
h5 + table{
|
||||||
margin-top : 0.2cm;
|
margin-top : 0.2cm;
|
||||||
@@ -658,7 +656,7 @@ body {
|
|||||||
margin-bottom : 0.3cm;
|
margin-bottom : 0.3cm;
|
||||||
}
|
}
|
||||||
a{
|
a{
|
||||||
display : inline;
|
display : table;
|
||||||
color : inherit;
|
color : inherit;
|
||||||
text-decoration : none;
|
text-decoration : none;
|
||||||
&:hover{
|
&:hover{
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg id="Layer_3" data-name="Layer 3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 350.028 390.552"><defs><style>.cls-1{opacity:0.9;}.cls-2{fill:#001013;}.cls-3{fill:#fff;}.cls-4{fill:#aa2a29;}</style></defs><title>Discord of Many Things blank</title><g class="cls-1"><path d="M100.991,82.743c-1.649,3.324-3.395,5.768-4.1,8.482-1.49,5.753-3.44,11.644-3.455,17.482q-.332,125.259-.141,250.519c.007,20.122,12.708,36.368,31.407,40.239a38.328,38.328,0,0,0,7.722.761q103.611,0,207.222-.088h6.314c-3.256-11.462-9.664-34.015-9.664-34.015l2.431,2.023s41.561,37.755,62.33,56.6c2.489,2.26,3.694,4.462,3.593,7.885-.241,8.186-.078,16.383-.078,25.492-6.333-5.527-11.928-10.35-17.457-15.247-9.586-8.493-19.2-16.957-28.644-25.6a10.032,10.032,0,0,0-7.39-2.774q-117.228-.1-234.457-.334c-20.632-.031-33.959-9.189-41.021-28.578-.852-2.339-.783-5.091-.784-7.653q-.057-116.5-.031-233.007V119.145C74.791,102.517,84.2,89.068,100.991,82.743Z" transform="translate(-74.79 -67.573)"/></g><path class="cls-2" d="M338.234,371.589s5.556,19.924,8.513,30.53h-5.075c-69.335,0-138.67-.1-208,.074-16.925.043-35.116-9.515-40.505-33.247a26.538,26.538,0,0,1-.379-5.827q-.027-128.172.025-256.344c.021-19.276,15.226-36.749,34.427-38.688a82.669,82.669,0,0,1,8.279-.447q123.288-.034,246.578-.067c13.265-.016,24.7,3.79,33.278,14.235a39.273,39.273,0,0,1,9.447,25.5q-.015,167.477-.012,334.955c0,1.245-.1,2.49-.2,4.645-4.075-3.565-7.6-6.552-11.018-9.655q-35.236-31.992-70.44-64.017c-1.2-1.091-3.713-3.147-3.713-3.147l-2-1.775Z" transform="translate(-74.79 -67.573)"/><path class="cls-3" d="M419.838,435.934c-7.848-6.892-15.026-12.977-21.961-19.329q-28.235-25.86-56.253-51.954c-2.314-2.157-4.59-3.247-7.356-1.784-3.036,1.607-2.77,4.676-2.022,7.359,2.286,8.2,4.817,16.338,7.24,24.5a17.108,17.108,0,0,1,.294,1.851c-1.486.084-2.872.233-4.258.233-67.363.012-134.726-.155-202.088.123-18.267.075-32.955-13.095-34.769-29.353a92.257,92.257,0,0,1-.886-10.108Q97.7,233.488,97.793,109.5c.013-10.518,3.19-20.063,11.156-27.471a31.92,31.92,0,0,1,20.439-8.917c1.948-.109,3.9-.181,5.852-.181q123.5-.014,247-.063c9.957-.012,18.894,2.145,26.329,9.1,7.956,7.441,11.177,16.934,11.214,27.457.142,40.84.057,81.681.057,122.522V435.934Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M311.029,170.975c-11.8,45.005-23.315,88.959-35.123,134.016l-97.168-98.883Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M380.8,265.712l-95.97,40.316c11.438-43.808,22.639-86.709,33.839-129.609l1.08-.272Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M165.3,322.955c2.91-36.463,5.761-72.179,8.709-109.116l94.711,96.472Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M223.458,107.926l83.127,55.063L178.71,196.919Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M366.285,281.366l-72.5,73.414c-3.524-13.182-6.849-25.617-10.306-38.549Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M274.874,318.478c3.445,12.8,6.765,25.143,10.376,38.559l-98.635-26.556.032-1.153Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M374.888,241.261l-51.71-75.57,26.8-21.529,25.831,96.619Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M165.492,207.523c-2.39,30.748-4.736,60.942-7.083,91.135l-1.063.159c-8.5-31.936-17-63.872-25.705-96.581Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M317.039,159.316l-68.251-45.24.307-.794,93.794,25.212Z" transform="translate(-74.79 -67.573)"/><path class="cls-4" d="M136.517,193.952,203.5,125.03l1.086.832L167.794,198.9Z" transform="translate(-74.79 -67.573)"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -77,32 +77,3 @@
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cover Page */
|
|
||||||
@font-face {
|
|
||||||
font-family: NodestoCapsCondensed;
|
|
||||||
src: url('../fonts/5e/Nodesto Caps Condensed.woff2');
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: NodestoCapsCondensed;
|
|
||||||
src: url('../fonts/5e/Nodesto Caps Condensed Bold.woff2');
|
|
||||||
font-weight: bold;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: NodestoCapsCondensed;
|
|
||||||
src: url('../fonts/5e/Nodesto Caps Condensed Italic.woff2');
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: NodestoCapsCondensed;
|
|
||||||
src: url('../fonts/5e/Nodesto Caps Condensed Bold Italic.woff2');
|
|
||||||
font-weight: bold;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user