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

Compare commits

..

386 Commits

Author SHA1 Message Date
Scott Tolksdorf
20b719d0de Added in a function to sanatize script tags specifically 2018-12-03 09:55:49 +00:00
Scott Tolksdorf
8b04cc9269 Adding some more text to the default issue title to guide peopel to add an issue title 2018-11-27 10:38:29 +00:00
Marius
96466211c7 Make imgur link https in order to display image
Newer browsers warn and/or do not display content that gets loaded via HTTP if site is visited via HTTPS.
2018-11-26 20:13:25 -05:00
Kurtis Miller
34741291c7 Fix ESLint errors 2018-11-26 20:12:59 -05:00
Kurtis Miller
fcb0cd8ee7 Reset to previous commit 2018-11-26 20:12:59 -05:00
Kurtis Miller
aafac16af2 Add bold/italic shortcuts, reposition renderer warning 2018-11-26 20:12:59 -05:00
Trevor Buckner
911d1d4f9c Hide duplicate scrollbar in brewRenderer 2018-11-13 15:24:46 -05:00
Trevor Buckner
2cd7b44e12 Merge branch 'PRODUCTION' into master 2018-11-11 04:02:12 -05:00
Trevor Buckner
bfccd1d9e4 Wrap the text in the "source" page.
See #332.
2018-11-11 03:10:27 -05:00
Trevor Buckner
bf1bf6c191 Added spaces for lint... 2018-11-08 16:11:10 -05:00
Trevor Buckner
cc5cb677a1 Found the lint-friendly way to do it. Just needed to pass along the event data. 2018-11-08 16:11:10 -05:00
Trevor Buckner
2dcd7101f3 Fix metadata not working. Some earlier linting caused the handleFieldChange and handleSystem functions to not have access to event data. Returning these to their pre-lint state for now, but there might be a more lint-friendly way to do this later. 2018-11-08 16:11:10 -05:00
Trevor Buckner
f4e7e46a04 Added spaces for lint... 2018-11-08 16:04:14 -05:00
Trevor Buckner
8b3b7cb5aa Found the lint-friendly way to do it. Just needed to pass along the event data. 2018-11-08 16:04:14 -05:00
Trevor Buckner
77081b39b4 Fix metadata not working. Some earlier linting caused the handleFieldChange and handleSystem functions to not have access to event data. Returning these to their pre-lint state for now, but there might be a more lint-friendly way to do this later. 2018-11-08 16:04:14 -05:00
Trevor Buckner
a06236e3ff Fix regression with updated Pico-Router
This variable name changed with the v2.0.0 of Pico-Router and it wasn't changed here. This was causing every page to display a  `<div class="homePage page">` rather than the appropriate `editPage` or `sharePage`. It just wasn't immediately noticeable since `homePage` and `editPage` are almost identical. The problem is clearly visible on `sharePage` however.

`homebrew.jsx` was set to always render a defaultUrl of ` ` which creates a `<div class="homePage page">` by default, overwriting the expected `<div>` on for the current url.
2018-11-07 16:11:18 -05:00
Rae Che
c8585775be Change circleci mongo version to one that still exists 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
439cdfa1ea upgrading to mongoose v5 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
4c36f254c4 Removing picofluc for now 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
b6815593fd adding bithoundrc and updating pico-router 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
84054d1aae Updating some packages 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
6cd6b3c1c6 Upping version 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
907dbe4416 Updating to user create-react-class 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
47429d804a Upping the node ver on circleci 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
1d54ab49e6 Updating superagent 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
f634c451ff Adding in the missing repository field 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
778c0ca0b1 Updating build scripts and libraries 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
f4985b68ca Updating build scripts and libraries 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
c8875cff94 lint 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
40f1d4c790 Updating navbar link to go to the new subreddit 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
7818b6db46 Adding mongo image to the circleci config 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
4163e95938 Updating contributing and issue guides, added new verify npm task 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
fed0536673 Moving babelrc into package 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
a4b92af351 Adding in test case runner 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
4584b83c60 adding a circleCI task 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
c57ca0b27f Adding circleCI and eslint 2018-11-07 16:00:24 -05:00
Scott Tolksdorf
c04cd23213 Adding circleCI 2018-11-07 16:00:24 -05:00
Trevor Buckner
140f064786 Re-enable Box Shadows in PDF
Box shadows have been fixed in Chrome. No reason to hide them anymore.
2018-11-07 16:00:24 -05:00
Scott Tolksdorf
643f6f933d Fixing issue#413 class feature duping entire brew 2018-11-07 16:00:24 -05:00
Trevor Buckner
24aec1c649 Fixed typo "is" -> "in" 2018-11-07 15:15:07 -05:00
sprigunn
8caae18a12 Update README.md
Typos and additional license to sync up with http://homebrewery.naturalcrit.com.
2018-11-07 15:15:07 -05:00
Trevor Buckner
a1140f75d8 Fix border-image bug on PDFs
I think this might be caused by a new bug in Chrome or something since it seems to have popped up in GMBinder as well in the last couple weeks. See #683

Anyway, the error only occurs on the Class Table and Descriptive Text Box, which are also the only ones to use `border-image-repeat: round`. I changed it to `border-image-repeat: stretch` which solves the graphical issue and doesn't affect the appearance otherwise in this particular case.
2018-11-07 14:57:52 -05:00
Rae Che
3532d75365 s/let/const/ to satisfy ESLint 2018-08-24 10:12:53 -04:00
Rae2che5
ea81bb5ebc Add missing volume declaration. 2018-08-22 01:44:48 -07:00
Schemen
8d217f8785 Update according to change request 2018-08-22 01:44:48 -07:00
Schemen
d35db1f702 Add dockerization and example compose file 2018-08-22 01:44:48 -07:00
Rae Che
f6b058f3c9 brewRenderer: Capture event properties while still in event loop.
React [pools events](https://github.com/facebook/react/issues/2850),
which means that once the lambda runs later on the properties we want
to read will be null. Instead, we capture the properties in the event
loop.
2018-08-20 14:14:52 -04:00
Rae Che
5ab7c29b9d Change circleci mongo version to one that still exists 2018-08-20 13:20:05 -04:00
Rae Che
c5ecb9d57d ESLint reformatting 2018-05-31 10:53:07 -04:00
Rae Che
d0c473878a BrewSearch: Remove stale piece of React state 2018-05-31 10:53:07 -04:00
Rae Che
796df9a1ac EditPage: Remove stale bit of React state 2018-05-31 10:53:07 -04:00
Rae Che
9e8e403195 HomebrewAdmin: Remove stale piece of React state 2018-05-31 10:53:07 -04:00
Rae Che
a369871a06 ESLint reformatting 2018-05-31 10:53:07 -04:00
Rae Che
f2f45f3657 RenderWarnings: Remove dead code 2018-05-31 10:53:07 -04:00
Rae Che
e86ce5cf06 PrintPage: Fix potentially inconsistent React state update 2018-05-31 10:53:07 -04:00
Rae Che
8d73ff6833 BrewLookup: Mark links as noreferrer 2018-05-31 10:53:07 -04:00
Rae Che
c4397d34f8 BrewItem: Mark links as noreferrer 2018-05-31 10:53:07 -04:00
Rae Che
66c0c96a4f EditPage: Mark link as noreferrer 2018-05-31 10:53:07 -04:00
Rae Che
838b64c589 EditPage: Simplify hasChanges.
In particular, remove unreachable `return` statement.
2018-05-31 10:53:07 -04:00
Rae Che
730dde730c MetadataEditor: Mark link as noreferrer 2018-05-31 10:53:07 -04:00
Rae Che
d867aa7ce1 EditPage: Consistent trySave on handle[Metadata|Text]change
Previously, one of these happened in React's post-state-update callback,
while the other happened directly. They now both use the callback.
2018-05-31 10:53:07 -04:00
Rae Che
761597e71f EditPage: Fix potentially inconsistent React state updates 2018-05-31 10:53:07 -04:00
Rae Che
4bde5fcbf8 HomebrewAdmin: Mark links as noreferrer. 2018-05-31 10:53:07 -04:00
Rae Che
ff0aa56ddc HomebrewAdmin: Remove direct React state mutation. 2018-05-31 10:53:07 -04:00
Rae Che
74f92f3e44 Use noreferrer in recent-brew links. 2018-05-31 10:53:07 -04:00
Rae Che
84285f7359 Remove redundant expression. 2018-05-31 10:53:07 -04:00
Rae Che
ec0de7a408 BrewRenderer: Remove redundant errors state property.
The errors are in fact tracked in `this.props`, not `this.state`.
2018-05-31 10:53:07 -04:00
Rae Che
9ea99236ff Omit redundant property definition in brew renderer 2018-05-31 10:53:07 -04:00
Rae Che
f806328e75 Omit redundant property in eslintrc 2018-05-31 10:53:07 -04:00
Rae Che
15ac397b63 Fix inconsistent React state update.
Flagged by lgtm.com (as js/react/inconsistent-state-update).
2018-05-31 10:53:07 -04:00
Rae Che
b8105eb147 Config: Read MongoDB URL from config files too. 2018-05-29 11:04:57 -04:00
Trevor Buckner
31cbd9ef40 Fix regression with updated Pico-Router
This variable name changed with the v2.0.0 of Pico-Router and it wasn't changed here. This was causing every page to display a  `<div class="homePage page">` rather than the appropriate `editPage` or `sharePage`. It just wasn't immediately noticeable since `homePage` and `editPage` are almost identical. The problem is clearly visible on `sharePage` however.

`homebrew.jsx` was set to always render a defaultUrl of ` ` which creates a `<div class="homePage page">` by default, overwriting the expected `<div>` on for the current url.
2018-05-23 17:41:50 +01:00
Trevor Buckner
eaab6de691 Fix border-image bug on PDFs
I think this might be caused by a new bug in Chrome or something since it seems to have popped up in GMBinder as well in the last couple weeks. See #683

Anyway, the error only occurs on the Class Table and Descriptive Text Box, which are also the only ones to use `border-image-repeat: round`. I changed it to `border-image-repeat: stretch` which solves the graphical issue and doesn't affect the appearance otherwise in this particular case.
2018-05-22 10:01:03 +01:00
Trevor Buckner
d417c76c56 Remove unused event triggers
Removed `onMouseOver` and `onMouseOut` since they are no longer needed to trigger `will-change`
2018-05-14 08:30:19 +01:00
Trevor Buckner
2f15cc5611 Lint 2018-05-14 08:30:19 +01:00
Trevor Buckner
eb08172fb1 Move will-change to stylesheet
This makes `will-change: transform` permanent in the brewRenderer stylesheet rather than trying to load and unload it programatically.
2018-05-14 08:30:19 +01:00
Trevor Buckner
0cc87a4f0f Lint Fixes 2? 2018-05-14 08:30:19 +01:00
Trevor Buckner
004dc79eb2 Lint fixes 2018-05-14 08:30:19 +01:00
Trevor Buckner
a8a70c2d70 Unified spacing 2018-05-14 08:30:19 +01:00
Trevor Buckner
825c259fba Optimize for smooth scrolling of BrewRenderer
The will-change property allows the browser to optimize for smoother animations. This completely eliminates the scrolling stutter.
2018-05-14 08:30:19 +01:00
Rae2che5
cbbb7292d9 Revert "Fix duplicated text from Class Feature snippet"
This reverts commit 9519a0b4e4.
2018-05-11 20:44:53 +01:00
Trevor Buckner
9519a0b4e4 Fix duplicated text from Class Feature snippet
When adding the Class Feature snippet, all curent text in the document is inserted in place of the randomly generated class name, creating several duplicates of the document and generally creating a mess.  See #413 which was closed but the issue was never fixed.

Most of the snippet code generators do not have any input arguments in the `module.exports` function, so they don't have this issue. However, Table of Contents needs to parse the text in the brew, so it is passed a copy of the brew document. Unfortunately, Class Feature (classfeature.gen.js) also has an input parameter for when it is used as part of the Full Class snippet.  Thus, the unintended consequence occurs in snippetbar.jsx in the `execute` function.

This fix simply adds a check to the execute function and only passes in the brew as an argument if the clicked snipped actually is the Table of Contents. Some restructuring might later reveal a cleaner way to do this rather than an awkward special case check like this.
2018-05-11 10:20:18 +01:00
Eric Scheid
9dd16b6dd5 add page-break-inside to support Firefox, the laggard 2018-05-10 14:36:24 -04:00
Eric Scheid
d693301c37 Fix property name break-inside 2018-05-10 14:36:24 -04:00
Rae Che
fd5d142c16 Fix calculation of currently-viewed page.
Previously, this relied on a hard-coded constant determining the
height of a page. However, that's unnecessary -- we know the scroll
height of the window and the number of pages, so we can compute it.
2018-05-10 14:35:03 -04:00
Trevor Buckner
ee63d2d857 Fix duplicate table headers
Fixes a common issue. See #318.
2018-05-10 18:26:46 +01:00
Vincent Durmont
7c3946fb03 Some typos 2018-05-10 13:11:40 -04:00
Trevor Buckner
3e69e8c1aa Revert "Merge pull request #1 from calculuschild/Fix-Duplicated-Table-Headers"
This reverts commit 1a0bc1952c, reversing
changes made to 4f4ef908e0.
2018-05-08 21:33:34 -04:00
Trevor Buckner
1a0bc1952c Merge pull request #1 from calculuschild/Fix-Duplicated-Table-Headers
Fix Duplicated Table Header
2018-05-08 12:45:02 -04:00
Trevor Buckner
7e2c3381ae Fix Duplicated Table Header
Fixes a pretty common issue. See #318.
2018-05-08 12:42:11 -04:00
Trevor Buckner
4f4ef908e0 Merge branch 'master' of https://github.com/calculuschild/homebrewery 2018-05-08 12:39:50 -04:00
Trevor Buckner
3fe2360d92 Revert "Fix duplicated table headers"
This reverts commit 13a2a7efd2.
2018-05-08 12:36:30 -04:00
Trevor Buckner
13a2a7efd2 Fix duplicated table headers
Fixes a pretty common issue. See #318.
2018-05-08 12:33:36 -04:00
Trevor Buckner
073fb73bde Wrap the text in the "source" page.
See #332.
2018-05-07 10:56:23 +01:00
Trevor Buckner
847615ef8e Wrap the text in the "source" page.
See #332.
2018-04-17 21:03:50 -04:00
Scott Tolksdorf
3583c2e776 upgrading to mongoose v5 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
2a753ccc7c Removing picofluc for now 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
55c529473a adding bithoundrc and updating pico-router 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
164f646e08 Updating some packages 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
6f4962926c Upping version 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
f18a181e2e Updating to user create-react-class 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
c4bff6afa0 Upping the node ver on circleci 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
63e8a0d9b7 Updating superagent 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
ce3fda683b Adding in the missing repository field 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
9594b73b0d Updating build scripts and libraries 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
78ad4bea09 Updating build scripts and libraries 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
ed1b5252be lint 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
bf27250990 Updating navbar link to go to the new subreddit 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
bab11d692e Adding mongo image to the circleci config 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
3350b04f64 Updating contributing and issue guides, added new verify npm task 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
5ebba25183 Moving babelrc into package 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
8f77ac9e56 Adding in test case runner 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
3f728e7993 adding a circleCI task 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
3f22572f98 Adding circleCI and eslint 2018-04-09 00:12:56 -04:00
Scott Tolksdorf
a52f628fdf Adding circleCI 2018-04-09 00:12:56 -04:00
Trevor Buckner
fe63133d7c Re-enable Box Shadows in PDF
Box shadows have been fixed in Chrome. No reason to hide them anymore.
2018-04-08 23:23:49 -04:00
Scott Tolksdorf
3247cab214 Fixing issue#413 class feature duping entire brew 2017-06-04 16:07:49 -04:00
Scott Tolksdorf
b68c6a4ad2 Added ability to hide render wanring notification 2017-04-22 12:09:18 -04:00
Scott Tolksdorf
6e0f042b42 Adding quick fix for PPR getting out of sync 2017-03-03 19:25:56 -05:00
Scott Tolksdorf
c47d492ed3 fix 2017-02-18 14:48:45 -05:00
Scott Tolksdorf
18852932e8 Added new delete brew option on user page 2017-02-18 14:46:14 -05:00
Scott Tolksdorf
cc8e874ad1 Disabling zoom check, since it does not play well with many browsers 2017-01-21 20:38:35 -05:00
Scott Tolksdorf
8b148b81b8 Merge branch 'v2.7' 2017-01-19 12:43:48 -05:00
Scott Tolksdorf
063d701a0e Updating the changelog and welcome msg 2017-01-19 12:39:13 -05:00
Scott Tolksdorf
296b066ed3 Added a brew lookup for admin page 2017-01-19 12:28:00 -05:00
Scott Tolksdorf
9fe6fd979b Adding in line highlight for new pages 2017-01-19 12:10:19 -05:00
Scott Tolksdorf
70346ffce7 Fixed saving authors and systems to brews 2017-01-19 12:06:14 -05:00
Scott Tolksdorf
c417c1aa0c Hiding the editor snapping for now 2017-01-19 11:50:01 -05:00
Scott Tolksdorf
5e04e5dc99 Code to brew page jumping working 2017-01-17 23:32:34 -05:00
Scott Tolksdorf
6544d63b23 Updated vitreum, fixed events in render warnings 2017-01-17 00:39:28 -05:00
Scott Tolksdorf
5bfa195dc7 added listner for zoom event 2017-01-15 11:38:22 -05:00
Scott Tolksdorf
9b936f42f3 Added tooltip to metadata editor and upped the version of font awesome 2017-01-14 14:35:36 -08:00
Scott Tolksdorf
5fe7c7a6d8 renamed render warnings and now built into the brewrenderer 2017-01-14 14:21:51 -08:00
Scott Tolksdorf
6e86d9c123 Added a quick build task and created the warnings component 2017-01-14 13:53:09 -08:00
Scott Tolksdorf
306e4f024c Adding the meta editor to home page 2017-01-14 13:34:20 -08:00
Scott Tolksdorf
a2c6940be4 version working again 2017-01-14 13:32:34 -08:00
Scott Tolksdorf
75f83427e0 Added version to model 2017-01-14 13:30:23 -08:00
Scott Tolksdorf
4be9f4a74a Adding in dep for new babel preset 2017-01-14 13:17:41 -08:00
Scott Tolksdorf
9a9e0cc5bc Removing ref to the todo list 2016-12-26 13:43:32 -05:00
Scott Tolksdorf
62e4997fa9 emoved a ton of unsued files 2016-12-26 13:43:18 -05:00
Scott Tolksdorf
b45ec32e44 Removing the need to have codemirror in shared 2016-12-26 13:29:11 -05:00
Scott Tolksdorf
9fd7586726 Fixed renderer crashing with malformed html on load 2016-12-25 23:44:24 -05:00
Scott Tolksdorf
75f0a9f755 Fixed black boxes on print to pdf 2016-12-25 23:14:04 -05:00
Scott Tolksdorf
a35d684773 Changed icon and fixed 249 2016-12-25 23:09:22 -05:00
Scott Tolksdorf
9b80f17564 Lots of doc improvements 2016-12-25 22:07:23 -05:00
Scott Tolksdorf
90a6ac4ef8 removing the architecuter files 2016-12-25 21:46:59 -05:00
Scott Tolksdorf
bd6ba1e497 Removing uneeded files 2016-12-25 21:46:13 -05:00
Scott Tolksdorf
56048ab936 vitreum 4 is looking stable 2016-12-25 21:44:27 -05:00
Scott Tolksdorf
1ec0b2fa91 updating todo 2016-12-25 21:01:12 -05:00
Scott Tolksdorf
fe4a05dc25 Fixed the class table issue 2016-12-16 22:59:44 -05:00
Scott Tolksdorf
1f1bd669fe Added additional protection against debounce saving 2016-12-12 10:28:37 -05:00
Scott Tolksdorf
63aee2dedf Merge branch 'v2.6' 2016-12-03 16:28:07 -05:00
Scott Tolksdorf
e5ffb7c629 Greatly improved the user page UI 2016-12-03 16:27:15 -05:00
Scott Tolksdorf
be783e5f6b Added a table of contents snippet 2016-12-03 15:47:20 -05:00
Scott Tolksdorf
d96ac0f3ca Adding breakavoid to list elements 2016-12-03 14:56:31 -05:00
Scott Tolksdorf
ce5596c489 Making the user page a bit prettier 2016-12-03 14:54:11 -05:00
Scott Tolksdorf
9285e53e55 Added conditional partial page rendering 2016-12-03 14:49:00 -05:00
Scott Tolksdorf
bec417a325 Changed the meta editor icon 2016-12-03 14:02:28 -05:00
Scott Tolksdorf
1eeb1127b1 Added report back to edit 2016-12-03 13:59:18 -05:00
Scott Tolksdorf
8e6fccc969 Added account nav to newpage and added split table snippet 2016-12-01 10:06:23 -05:00
Scott Tolksdorf
a634b76117 Fixed a bug with saving while not logged in 2016-11-27 18:55:50 -05:00
Scott Tolksdorf
30942785d1 Fixed the User page 2016-11-27 13:45:38 -05:00
Scott Tolksdorf
21d3c5bfc8 Fixed a capitalization error 2016-11-25 00:58:28 -05:00
Scott Tolksdorf
7f639a0824 Merge branch 'accounts' 2016-11-25 00:29:46 -05:00
Scott Tolksdorf
a0ca45ce1c Added new account nav item 2016-11-25 00:28:48 -05:00
Scott Tolksdorf
4e5cd914f7 User page now running properly 2016-11-24 23:35:10 -05:00
Scott Tolksdorf
2d6b89c769 Updating changelog 2016-11-24 22:37:34 -05:00
Scott Tolksdorf
6af9dd9325 Added in a brew item component 2016-11-24 00:07:04 -05:00
Scott Tolksdorf
9e14872f06 Stubbed out a userpage 2016-11-23 23:59:57 -05:00
Scott Tolksdorf
750f5c1330 Added in middleware for retriving brews by a user 2016-11-23 23:41:39 -05:00
Scott Tolksdorf
1db24d07bd Adding in the needed libs 2016-11-23 23:00:28 -05:00
Scott Tolksdorf
f4f96253c2 Moved deleting a brew into the emtadata editor 2016-11-23 15:01:46 -05:00
Scott Tolksdorf
97cf2d2ce7 Updating changelog and version 2016-11-23 14:48:54 -05:00
Scott Tolksdorf
e61bf22788 Added in metadata editor 2016-11-23 14:47:28 -05:00
Scott Tolksdorf
ccdb6a3cbd Removing refernces to ver from pages 2016-11-14 23:09:26 -05:00
Scott Tolksdorf
d400c37b6d Updated style to navbar 2016-11-14 23:03:58 -05:00
Scott Tolksdorf
2f2a1c5146 Control s and p now save and print on editor pages 2016-11-14 22:40:37 -05:00
Scott Tolksdorf
8b3f9ac76a Cleaned up the server file and added methodfs and statics to the model 2016-11-14 22:30:28 -05:00
Scott Tolksdorf
6672dff938 Print page can now load from local storage 2016-11-14 21:31:01 -05:00
Scott Tolksdorf
d7463ec28e Navbar now using global scope 2016-11-14 20:15:29 -05:00
Scott Tolksdorf
4dce90ab41 Cleaning up the server file 2016-11-14 20:14:08 -05:00
Scott Tolksdorf
5f6f7ec691 Removing save warning from new page 2016-11-14 19:45:02 -05:00
Scott Tolksdorf
582deb7bf7 Updating todo 2016-11-14 19:39:25 -05:00
Scott Tolksdorf
8c4a6221e2 Fixing spelling mistake 2016-11-10 10:54:00 -05:00
Scott Tolksdorf
58c67d7d4d Update README.md 2016-11-07 19:14:12 -05:00
Scott Tolksdorf
9fe52145e6 Merge branch 'htmlValidate' 2016-11-07 19:10:53 -05:00
Scott Tolksdorf
b671161044 Updating changelog 2016-11-07 19:10:38 -05:00
Scott Tolksdorf
a439c418ef Updating welcome msg and issue template 2016-11-07 19:02:43 -05:00
Scott Tolksdorf
b8effb1ed1 Updated todo 2016-11-07 18:45:37 -05:00
Scott Tolksdorf
e576e6d971 Added QoL, where if errors are present, we run the checker on text input to give quicker feedback 2016-09-24 10:25:10 -04:00
Scott Tolksdorf
9f05556bc5 Error bar added to edit page 2016-09-24 10:25:10 -04:00
Scott Tolksdorf
2a0c06cd3d New error bar made 2016-09-24 10:25:10 -04:00
Scott Tolksdorf
dd1264d2e6 New html validator is working 2016-09-24 10:25:10 -04:00
Scott Tolksdorf
c49321d590 Creating new validator 2016-09-24 10:25:10 -04:00
Scott Tolksdorf
cd2337ff2c Experimenting with validation more 2016-09-24 10:24:38 -04:00
Scott Tolksdorf
9eb26a95f3 IMproved validator logic 2016-09-24 10:24:38 -04:00
Scott Tolksdorf
c7ccf6747c Updating project version 2016-09-24 10:24:38 -04:00
Scott Tolksdorf
9a96eebdb1 Adding my own markdown-html validator, still needs line numbers though 2016-09-24 10:24:01 -04:00
Scott Tolksdorf
54542a8ec1 Merge pull request #203 from lasseborly/minorDocumentationChanges
Minor documentation changes
2016-09-19 18:55:08 -04:00
Lasse Borly
efddfd31ee added the required changes before merge 2016-09-19 23:10:56 +02:00
Lasse Borly
0690216222 Corrected the license 2016-09-18 03:55:51 +02:00
Lasse Borly
9e54fe26d9 corrrecting small readme mistakes 2016-09-18 03:53:06 +02:00
Lasse Borly
01e4e11ef7 got rid of the global dependence on gulp 2016-09-18 03:51:20 +02:00
Scott Tolksdorf
7dc39e962b Merge pull request #202 from lasseborly/missingGulpDependencies
added missing dependencies
2016-09-17 21:25:41 -04:00
Lasse Borly
9adf28171e added missing dependencies 2016-09-18 03:20:22 +02:00
Scott Tolksdorf
152194aba8 Changing the print button to say get PDF. Should be more clear to users 2016-09-14 09:53:27 -04:00
Scott Tolksdorf
a107d59d72 Fixing state and props on navbar 2016-09-14 09:53:27 -04:00
Scott Tolksdorf
e6be1ae12f Updating to allow code folding 2016-08-31 13:33:01 -04:00
Scott Tolksdorf
460585f9c9 Admin page link quickfix 2016-08-20 19:58:33 -04:00
Scott Tolksdorf
143c006298 Merge branch 'various' 2016-08-20 13:44:11 -04:00
Scott Tolksdorf
43ec212be9 Fixed a bad route in the admin page 2016-08-20 13:40:32 -04:00
Scott Tolksdorf
78426135c6 Note blocks now don't overlap titles 2016-08-20 13:33:15 -04:00
Scott Tolksdorf
b134e11a86 Fixed a unclick bug with the splitpane 2016-08-20 13:29:28 -04:00
Scott Tolksdorf
888d3faa4c Editor and renderer redraw when you resize the browser 2016-08-20 13:26:48 -04:00
Scott Tolksdorf
ef8784ccf2 Homebrewery will now try and insert a better title for you if you dont provide one 2016-08-20 13:20:32 -04:00
Scott Tolksdorf
0a7b538216 Added in the new coverpage snippet 2016-08-20 13:02:52 -04:00
Scott Tolksdorf
019383ebdd Improved the html parsing slightly 2016-08-20 12:44:39 -04:00
Scott Tolksdorf
90c695c005 Visitng a deleted brew will now remove it from your recent list 2016-08-20 12:33:11 -04:00
Scott Tolksdorf
6b337b5d69 Added in a much better error page 2016-08-20 12:23:24 -04:00
Scott Tolksdorf
62d70022e7 Package version is now loaded into the navbar 2016-08-20 12:02:48 -04:00
Scott Tolksdorf
cd454e82ef Updating the homepage a bit 2016-08-20 11:50:22 -04:00
Scott Tolksdorf
8a7e441724 Adding license file and changing welcome message extension 2016-08-20 11:43:27 -04:00
Scott
1482501574 Update changelog.md 2016-08-17 13:33:57 -04:00
Scott Tolksdorf
f22fd73162 trying to force backgroudn graphics 2016-08-09 13:37:35 -04:00
Scott Tolksdorf
91c7f45d33 Converting raw mongoose objects to json 2016-08-09 13:32:46 -04:00
Scott Tolksdorf
34b21703e1 Maing staging work again 2016-08-09 13:28:45 -04:00
Scott Tolksdorf
73e561beba Fixed a security issue on share pages 2016-08-09 12:53:47 -04:00
Scott Tolksdorf
388ae933f8 rmeoving the top api call, as it was never finished and opened a security issue. 2016-08-06 21:08:37 -06:00
Scott Tolksdorf
33fd991276 ADding in stlying and snippet for a descriptive text box 2016-07-29 01:26:20 -04:00
Scott Tolksdorf
e31cb003eb Updating the new server creds 2016-07-21 19:10:21 -04:00
Scott Tolksdorf
46581cfcf5 Hot fix to test prod 2016-07-21 18:25:04 -04:00
Scott Tolksdorf
073b547f96 Added a hybrid navitem for both recently edited and viewed brews 2016-07-07 09:43:24 -04:00
Scott Tolksdorf
3ff736b440 Adding a non-chrome warning 2016-06-19 19:31:54 -04:00
Scott Tolksdorf
ead975b605 Adding in page ids to allow for hyperlinking 2016-06-10 12:16:46 -04:00
Scott Tolksdorf
cd97b22067 Fixing auto-incrmetning page numbers with partial page rendering 2016-06-09 08:03:54 -04:00
Scott Tolksdorf
e38850f807 Created new wrapper for my markdown parser, added it to the print page 2016-06-07 09:50:50 -04:00
Scott Tolksdorf
8df4dc56b2 Merge branch 'blockTweaks' 2016-06-05 13:50:55 -04:00
Scott Tolksdorf
235664ec88 updating the standalone css file 2016-06-05 13:49:21 -04:00
Scott Tolksdorf
3e796501e2 Fied lists in stat blocks 2016-06-05 13:47:59 -04:00
Scott Tolksdorf
0d25a972ba Added in new auto-incrementing snippet 2016-06-05 13:09:37 -04:00
Scott Tolksdorf
5969e45087 Updated the class tbale snippets 2016-06-05 12:55:29 -04:00
Scott Tolksdorf
f058814040 Adding in a new classTable block 2016-06-05 12:49:55 -04:00
Scott Tolksdorf
038c89fc20 Updating welcome tet 2016-06-04 18:58:10 -04:00
Scott Tolksdorf
d9bf164010 Updating welcome tet 2016-06-04 18:37:06 -04:00
Scott Tolksdorf
39d5d5c458 Updating more routes, looking good 2016-06-04 18:34:48 -04:00
Scott Tolksdorf
d2a9b3f274 Removing the ability for the changelog to get into the recent brews 2016-06-04 18:30:26 -04:00
Scott Tolksdorf
7ca4e8ffa6 Swapped over all urls and refs to old url scheme 2016-06-04 18:29:25 -04:00
Scott Tolksdorf
60092f404c Switching over project to just be the homebrewery 2016-06-04 17:51:30 -04:00
Scott Tolksdorf
c50de28900 Adding in the extra wide block 2016-05-31 19:47:13 -04:00
Scott Tolksdorf
6611bc9eff Merge branch 'v2.1' 2016-05-29 13:46:47 -04:00
Scott Tolksdorf
802103ff27 Paragrapghs now indent after lists 2016-05-29 13:45:02 -04:00
Scott Tolksdorf
9950c747da Updating the standalone file 2016-05-29 13:31:04 -04:00
Scott Tolksdorf
2b2b6b2793 Cleaning up the brewrender 2016-05-29 13:26:34 -04:00
Scott Tolksdorf
6474825ffb Last tweaks 2016-05-29 13:19:21 -04:00
Scott Tolksdorf
7eb47d7db0 Updated welcome text for v2.1 2016-05-29 12:58:44 -04:00
Scott Tolksdorf
b8c55d72a1 updating changelog and bumping the remembered value to 8 items 2016-05-29 12:53:36 -04:00
Scott Tolksdorf
87af0e8cb7 Recently viewed and edited seem to be working great 2016-05-29 12:50:18 -04:00
Scott Tolksdorf
63dcbfa388 Updating changelog 2016-05-29 11:35:54 -04:00
Scott Tolksdorf
8a7bffce5d Cleaning up the merge 2016-05-29 11:24:26 -04:00
Scott Tolksdorf
715f2f41bb Merge branch 'divRendering' into v2.1 2016-05-29 11:23:27 -04:00
Scott Tolksdorf
b33ef939ed Split the spell gen into a spell and spell list gen 2016-05-29 11:23:03 -04:00
Scott Tolksdorf
00bf12ecb7 Spelllist is rendering nicely 2016-05-29 11:22:30 -04:00
Scott Tolksdorf
c993ae9cf5 Woh, it is working 2016-05-29 11:22:30 -04:00
Scott Tolksdorf
626cba6062 Newlines 2016-05-28 09:41:05 -04:00
Scott Tolksdorf
14b7d60856 Adding in mac support for print hijack 2016-05-27 09:26:45 -04:00
Scott Tolksdorf
5a1041cbb3 styling for the new save current button done 2016-05-27 09:26:40 -04:00
Scott Tolksdorf
56bb0e0ad8 Ctrl p is now hijacked on the edit and share page to auto open to the brews print page 2016-05-27 09:25:38 -04:00
Scott
dce3f224c7 Better issue template and better print pdf instructions 2016-05-27 09:14:30 -04:00
Scott Tolksdorf
01e040d1ab Adding note to the welcome message to try Chrome fro print to PDF 2016-05-26 23:05:30 -04:00
Scott Tolksdorf
fa138499af Ability score improvements in the generators now follow the proper progressions 2016-05-25 09:53:45 -04:00
Scott Tolksdorf
7cc70149da Table generators now follow the proper prof bonus from the phb 2016-05-24 21:50:55 -04:00
Scott Tolksdorf
2ed9395e29 Wrapping up the fix 2016-05-24 21:35:03 -04:00
Scott
53529d14eb Fixed on a4 wide monster stat blocks go single column 2016-05-24 09:02:01 -04:00
Scott Tolksdorf
7501342e85 Updating the version and changelog 2016-05-19 08:52:01 -04:00
Scott Tolksdorf
68fc0f95d1 Save button now will display an error box with a custom link to an github issue 2016-05-19 08:49:55 -04:00
Scott Tolksdorf
52ff2e41e6 new error ahndler nearly done 2016-05-19 08:35:37 -04:00
Scott Tolksdorf
e7f1083edb Upping the express bodyPRasrserjson limit to 25mb 2016-05-19 08:21:26 -04:00
Scott Tolksdorf
6209fcd5cb Brew content will now not server render jsut incase it has malformed html, so it wont break the page 2016-05-18 00:20:07 -04:00
Scott Tolksdorf
fc3587d6cb Adding a search to the admin panel 2016-05-17 22:48:06 -04:00
Scott Tolksdorf
5f55a59042 Updating the standalone phb css 2016-05-16 21:23:34 -04:00
Scott Tolksdorf
0612fc63e6 Chagne the help out icon to a heart that glows red 2016-05-16 21:17:02 -04:00
Scott Tolksdorf
23cd7e7516 Merge branch 'v2' 2016-05-16 20:59:40 -04:00
Scott Tolksdorf
81ea2c838e Blending the background color of the snippet bar and the divider 2016-05-16 20:47:13 -04:00
Scott Tolksdorf
d9015c399c Trying to add specific routing to fix GA being blocked 2016-05-15 17:13:43 -04:00
Scott Tolksdorf
96a59780c2 Adding patreon link in changelogs 2016-05-14 17:15:39 -04:00
Scott Tolksdorf
eef826f8d8 Adding patreon link in nav 2016-05-14 17:11:32 -04:00
Scott Tolksdorf
8c29be5df5 updating the welcome message 2016-05-14 16:36:51 -04:00
Scott Tolksdorf
a1b52d79f9 Updated changelog 2016-05-14 16:05:57 -04:00
Scott Tolksdorf
56987e7b60 Print dialog now auto opens on print page 2016-05-14 15:29:50 -04:00
Scott Tolksdorf
451bbfc915 Tweaking the a4 page height 2016-05-14 15:17:34 -04:00
Scott Tolksdorf
a81967884d Fixing mutliline lists 2016-05-14 15:09:19 -04:00
Scott Tolksdorf
801bde04c5 Added palceholder text for the brew title 2016-05-14 14:59:21 -04:00
Scott Tolksdorf
c084cb2d8b Styling the snippet groups a bit better 2016-05-14 14:55:27 -04:00
Scott Tolksdorf
641ad747d3 Embedded the new border-image assets 2016-05-14 14:45:48 -04:00
Scott Tolksdorf
cd280eb8f0 Winged border on note blocks working 2016-05-14 14:37:07 -04:00
Scott Tolksdorf
5537d974ff Fixed titles saving 2016-05-14 13:59:21 -04:00
Scott Tolksdorf
c4c09f0a69 Added print rules and fixing the newer border images 2016-05-14 13:40:31 -04:00
Scott Tolksdorf
9c1fd5b13a Adding both the share and edit ids as unique indexes, should speed up DB query time 2016-05-14 13:15:46 -04:00
Scott Tolksdorf
c1d7443c87 Adding a source route instead of jsut opening a new window 2016-05-14 13:08:27 -04:00
Scott Tolksdorf
b464de69e3 Main page is fixed, figured out svgs, and cleaned up the core styles 2016-05-14 12:09:08 -04:00
Scott Tolksdorf
ca377a2861 Fixing main page, moving around styles 2016-05-14 11:49:39 -04:00
Scott Tolksdorf
f29073e5ca Snippet icon changes 2016-05-14 10:22:18 -04:00
Scott Tolksdorf
634c1a617c Converted the monster block to use border iamges 2016-05-10 23:51:45 -04:00
Scott Tolksdorf
6f6f5649d4 Snippets done 2016-05-10 22:29:00 -04:00
Scott Tolksdorf
c9bfd08bb3 Removing unneeded code 2016-05-10 21:45:58 -04:00
Scott Tolksdorf
c07c9911ec todo update 2016-05-10 20:33:47 -04:00
Scott Tolksdorf
eb4117b35b Save button is functional 2016-05-10 00:50:17 -04:00
Scott Tolksdorf
743bcb0c74 getting the debounced saving working 2016-05-10 00:38:38 -04:00
Scott Tolksdorf
ed7decb42b Adding new navitems and finishing the edit and share page 2016-05-09 16:54:32 -04:00
Scott Tolksdorf
d5b8c60317 Added in an editable title navitem 2016-05-09 14:00:12 -04:00
Scott Tolksdorf
15ad171c2d Added in new page, however edit page is still broken 2016-05-09 13:17:17 -04:00
Scott Tolksdorf
eca3ada8eb Updated gulpfile with fixed proejctmodule path 2016-05-09 11:01:02 -04:00
Scott Tolksdorf
1bd85e80ee Styled the page info 2016-05-09 10:57:23 -04:00
Scott Tolksdorf
30e6bb28ad Creating thew new brew renderer 2016-05-09 09:35:43 -04:00
Scott Tolksdorf
62654102b8 Changed project structure to have the root page into main and subbed out the pages into their own folder 2016-05-06 15:59:18 -04:00
Scott Tolksdorf
34a93a6151 Fixing navbar font pathing 2016-05-06 15:35:37 -04:00
Scott Tolksdorf
62470f2958 Styled the divider 2016-05-06 14:58:39 -04:00
Scott Tolksdorf
12e1059071 Annnd forgot the phb styles 2016-05-06 14:35:27 -04:00
Scott Tolksdorf
413358feaa And forgot about the less files 2016-05-06 14:33:34 -04:00
Scott Tolksdorf
6a02e3d0cf Annnd back 2016-05-06 14:30:00 -04:00
Scott Tolksdorf
cf8bcd2bb4 yay for waindows pathing 2016-05-06 14:29:44 -04:00
Scott Tolksdorf
8aef39a81e more pathing 2016-05-06 14:25:53 -04:00
Scott Tolksdorf
a92adc0e53 Trying to fix asset pathing 2016-05-06 14:19:44 -04:00
Scott Tolksdorf
7c8fd42619 Updating pathing to the naturalcrit share folder 2016-05-06 14:04:58 -04:00
Scott Tolksdorf
ad02f99ebe Editor pane looks finished, injecting snippet text is workign and snippet group structure done 2016-05-06 13:59:41 -04:00
Scott Tolksdorf
c418ea5b42 Updated font awesome and sketching out the snippet bar 2016-05-05 10:03:51 -04:00
Scott Tolksdorf
f38f76b7c4 'Removing 2016-05-05 08:49:34 -04:00
Scott Tolksdorf
4139a8ee12 UPdating the homebrew editor with new snippet bar 2016-05-05 08:36:33 -04:00
Scott Tolksdorf
133dd7c144 Trying out a reddit share button, looks promising 2016-05-04 15:25:27 -04:00
Scott Tolksdorf
1db6553365 Added cursor activity to editor, removed uneeded languages 2016-05-04 14:05:37 -04:00
Scott Tolksdorf
582602740f Moved codemirror in the shared dir, new codeeditor seems to be working 2016-05-04 13:28:19 -04:00
Scott Tolksdorf
5ba8489a42 Code cleanup 2016-05-04 02:32:12 -04:00
Scott Tolksdorf
4b482a8f0b Adding version number to the navbar, probably will remove 2016-05-04 02:26:13 -04:00
Scott Tolksdorf
1ce0f00b62 Split pane scrolling is FINALLY working 2016-05-04 02:13:11 -04:00
Scott Tolksdorf
75fb606097 Built a new pane split component 2016-05-04 01:19:33 -04:00
Scott Tolksdorf
e6a747210e New navbar is done for the homepage, looking really good 2016-05-03 23:47:55 -04:00
Scott Tolksdorf
1949a5cca5 updating react and lodash to newest versions 2016-05-03 21:00:51 -04:00
Scott Tolksdorf
7f14870732 Moving old combat manager code into respective folders 2016-05-03 19:47:06 -04:00
Scott Tolksdorf
ead50af34b Adding in the toto 2016-05-03 17:37:10 -04:00
Scott
543ab39844 Update README.md 2016-04-21 14:46:48 -04:00
Scott Tolksdorf
5b96fc03b6 updating changelog 2016-04-20 01:32:59 -04:00
Scott Tolksdorf
558b9881d5 Merge branch 'admin' 2016-04-20 01:30:15 -04:00
Scott Tolksdorf
acf7a174f5 updating changelog 2016-04-20 01:29:36 -04:00
Scott Tolksdorf
f35950c2c4 added the search api with pagnination, and added a remove invalid brew endpoint to the admin 2016-04-20 01:29:35 -04:00
Scott Tolksdorf
8688b99bdf Spliting the homebrew server and api files 2016-04-20 01:29:35 -04:00
Scott Tolksdorf
4294f81f30 Removing old pdf junk 2016-04-20 01:29:34 -04:00
Scott Tolksdorf
3af6d8763e Removing the bottom margin off of nested lists 2016-04-20 01:29:13 -04:00
Scott
bfa0567aad Merge pull request #82 from kkragenbrink/nested-lists
Fix for Nested Lists Not Working
2016-04-20 01:27:17 -04:00
Kevin Kragenbrink
27c42caa4d Update phb.style.less 2016-04-19 03:53:59 -07:00
Scott Tolksdorf
207aa87253 Made the page contianer update state based on page index rather than scroll valuable, should greatly reduce re-renders. 2016-04-06 11:31:11 -04:00
Scott Tolksdorf
6f4d71083c Merge branch 'v1_4' 2016-04-06 00:44:08 -04:00
Scott Tolksdorf
e988257c87 updating the changelog and welcome text 2016-04-06 00:43:15 -04:00
Scott Tolksdorf
00dbd549f3 Changin font sizes to cm to give a more consistent zoom expereince 2016-04-06 00:25:02 -04:00
Scott Tolksdorf
c93c6b13c4 Page container is now doign partial rendering, need to clean up the stlying though 2016-04-06 00:15:15 -04:00
Scott
90d46f5c48 Merge pull request #67 from jendave/master
Add Dockerfile
2016-03-20 00:11:28 -04:00
David Hudson
d2bcaecce9 Add Dockerfile 2016-03-19 14:40:52 -07:00
Scott
4964dda3a6 Update issue_template.md 2016-03-03 08:46:30 -05:00
Scott Tolksdorf
0379bf1720 Adding sub and sup support 2016-02-29 20:25:26 -05:00
Scott Tolksdorf
d2424d839a Added in A4 letter size button and removed changelog button from the sare page 2016-02-29 20:20:26 -05:00
Scott
62448043c4 updating changelog 2016-02-20 12:14:35 -05:00
Scott
23d118382b Adding a issue template 2016-02-20 12:13:39 -05:00
Scott
f511bdf050 Fixed h1 headers not goign full width 2016-02-20 11:40:15 -05:00
Scott
256e62095c Quick fix to an incredibly large payload size on the admin page 2016-02-19 22:09:19 -05:00
Scott
0a8c489132 Removing ref to the combat manager 2016-02-19 22:02:15 -05:00
Scott
f14786c602 updating the standalone style 2016-02-19 21:54:29 -05:00
Scott
482839731c Merge branch 'v1.3' 2016-02-19 21:38:56 -05:00
Scott
47d5cecd31 Added more to the changelog 2016-02-19 21:37:32 -05:00
Scott
441bc0c004 Spelling Mistakes 2016-02-19 21:37:30 -05:00
Scott
267b88b225 Added a chrome detection tip to the status bar and updated the welcome text 2016-02-19 21:37:28 -05:00
Scott
8d61a21fa7 got the changelog page working, yayyyyyyyyyy 2016-02-19 21:37:25 -05:00
Scott
ac8579ccc9 Thin class tables and wide moster stat blocks are added 2016-02-19 21:37:23 -05:00
Scott
47fd832a32 added clear old button to the admin page 2016-02-19 21:37:21 -05:00
Scott
30dab729bb Added delete button to the edit page 2016-02-19 21:37:20 -05:00
Scott
fd871aa04a admin panel should be good 2016-02-19 21:37:18 -05:00
Scott
a1b8d4e8ce trying to improve the admin view 2016-02-19 21:37:16 -05:00
Scott
2231dc3684 Added @page css rule to auto turn off margins in Chrome when printing 2016-02-19 21:37:14 -05:00
Scott Tolksdorf
c8b3a0f183 Added a snippet for half class table gen 2016-02-19 21:37:12 -05:00
Scott Tolksdorf
69f8cdb402 Improving table spacing slightly 2016-02-19 21:37:11 -05:00
Scott Tolksdorf
fe806b0636 Improved spacing for bold text, thanks @nickpunt 2016-02-19 21:37:09 -05:00
Scott Tolksdorf
273a1a1b00 Fixed ordered lists not having numbers 2016-02-19 21:37:07 -05:00
Scott Tolksdorf
9b84913c8f Improved first letter rendering for firefox 2016-02-19 21:37:06 -05:00
Scott Tolksdorf
de3502a419 Changed snippet text to ink friendly 2016-02-19 21:37:04 -05:00
Scott Tolksdorf
d9c20cebfe First attempt at using a double hr to indicate full width elements 2016-02-19 21:37:02 -05:00
Scott Tolksdorf
7bab7f42c4 Increasing the padding at the bottom of the page for better fits 2016-02-19 21:37:00 -05:00
Scott
df98beb0e5 Merge pull request #26 from jendave/master
Ignore IntelliJ files. Fix typo in Welcome text
2016-01-21 10:12:15 -05:00
David Hudson
533c09670f Ignore IntelliJ files. Fix typo in Welcome text 2016-01-17 16:16:44 -08:00
169 changed files with 14747 additions and 9479 deletions

7
.bithoundrc Normal file
View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"unused-ignores": [
"react-dom"
]
}
}

33
.circleci/config.yml Normal file
View File

@@ -0,0 +1,33 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
- image: circleci/node:8.9
- image: circleci/mongo:3.4-jessie
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# run tests!
- run: npm run circleci

6
.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
node_modules
npm-debug.log
.git
Dockerfile
docker-compose.yml
tests

77
.eslintrc.js Normal file
View File

@@ -0,0 +1,77 @@
module.exports = {
root: true,
parserOptions : {
ecmaVersion : 9,
sourceType : 'module',
ecmaFeatures : {
jsx : true
}
},
env : {
browser : true,
},
plugins : ['react'],
rules : {
/** Errors **/
'camelcase' : ['error', { properties: 'never' }],
'func-style' : ['error', 'expression', { allowArrowFunctions: true }],
'no-array-constructor' : 'error',
'no-iterator' : 'error',
'no-nested-ternary' : 'error',
'no-new-object' : 'error',
'no-proto' : 'error',
'react/jsx-no-bind' : ['error', { allowArrowFunctions: true }],
'react/jsx-uses-react' : 'error',
'react/prefer-es6-class' : ['error', 'never'],
/** Warnings **/
'max-lines' : ['warn', {
max : 200,
skipComments : true,
skipBlankLines : true,
}],
'max-depth' : ['warn', { max: 4 }],
'max-params' : ['warn', { max: 4 }],
'no-restricted-syntax' : ['warn', 'ClassDeclaration', 'SwitchStatement'],
'no-unused-vars' : ['warn', {
vars : 'all',
args : 'none',
varsIgnorePattern : 'config|_|cx|createClass'
}],
'react/jsx-uses-vars' : 'warn',
/** Fixable **/
'arrow-parens' : ['warn', 'always'],
'brace-style' : ['warn', '1tbs', { allowSingleLine: true }],
'jsx-quotes' : ['warn', 'prefer-single'],
'no-var' : 'warn',
'prefer-const' : 'warn',
'prefer-template' : 'warn',
'quotes' : ['warn', 'single', { 'allowTemplateLiterals': true } ],
'semi' : ['warn', 'always'],
/** Whitespace **/
'array-bracket-spacing' : ['warn', 'never'],
'arrow-spacing' : ['warn', { before: false, after: false }],
'comma-spacing' : ['warn', { before: false, after: true }],
'indent' : ['warn', 'tab'],
'keyword-spacing' : ['warn', {
before : true,
after : true,
overrides : {
if : { 'before': false, 'after': false }
}
}],
'key-spacing' : ['warn', {
multiLine : { beforeColon: true, afterColon: true, align: 'colon' },
singleLine : { beforeColon: false, afterColon: true }
}],
'linebreak-style' : ['warn', 'unix'],
'no-trailing-spaces' : 'warn',
'no-whitespace-before-property' : 'warn',
'object-curly-spacing' : ['warn', 'always'],
'react/jsx-indent-props' : ['warn', 'tab'],
'space-in-parens' : ['warn', 'never'],
'template-curly-spacing' : ['warn', 'never'],
}
};

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
package-lock.json binary

28
.github/issue_template.md vendored Normal file
View File

@@ -0,0 +1,28 @@
<!-- CLICK "Preview" FOR INSTRUCTIONS IN A MORE READABLE FORMAT -->
## Before you submit
- Support questions are better asked on the subreddit [r/homebrewery](https://www.reddit.com/r/homebrewery/)
- Read the [contributing guidelines](https://github.com/stolksdorf/homebrewery/blob/master/contributing.md).
- If it's an issue, please make sure it's reproducible
- Ensure the issue isn't already reported.
*Delete the above section and the instructions in the sections below before submitting*
## Description
If this is a *feature request*, explain why it should be added. Specific use-cases are best.
For *bug reports*, please provide as much *relevant* info as possible.
**Share Link** :
or
**Brew code to reproduce** : <details><summary>Click to expand</summary><code><pre>
PASTE BREW CODE HERE
</pre></code></details>

24
.gitignore vendored
View File

@@ -1,14 +1,10 @@
# Logs
logs
*.log
#Ignore our built files
build/*
architecture.json
# Ignore sensitive stuff
/config/*
!/config/default.json
node_modules
storage
node_modules
storage
.idea
*.swp
*.log
build/*
config/local.*
todo.md

14
Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM node:8
# Create app directory
WORKDIR /usr/src/app
# Bundle app source
COPY . .
ENV NODE_ENV=docker
RUN yarn
EXPOSE 8000
CMD [ "yarn", "start" ]

View File

@@ -1,22 +1,35 @@
# NaturalCrit
A tool suite for DMs to use for D&D
### Getting started
1. Make sure you have [node](https://nodejs.org/en/)
1. Clone down the repo
1. In your terminal, head to the repo
1. Run `npm install` to get all the dependacies
2. Run `npm install -g gulp` to install the gulp build tool
1. Run `gulp fresh`, this will compile and build all the needed libraries (this only has to be done once, unless you add more libs)
1. Run `gulp` to run the project locally. Should be accessible at `localhost:8000`
2. Any changes to files within the proejct will be detected and the propject will automatically re-build
**Notes:** If you'd like to create and edit homebrews, you'll need to have MongoDB installed and running.
Have fun!
### changelog
You can check out the changelog [here](https://github.com/stolksdorf/NaturalCrit/blob/master/changelog.md)
# The Homebrewery
The Homebrewery is a tool for making authentic looking [D&D content](http://dnd.wizards.com/products/tabletop-games/rpg-products/rpg_playershandbook) using only [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet). Check it out [here](http://homebrewery.naturalcrit.com).
### issues, suggestions, bugs
If you run into any issues using The Homebrewery, please submit an issue [here](/issues).
### local dev
The Homebrewery is open source, so feel free to clone it, tinker with it, or run your own local version.
#### pre-reqs
1. install [node](https://nodejs.org/en/)
1. install [mongodb](https://www.mongodb.com/)
#### getting started
1. clone it
1. `npm install`
1. `npm build`
1. `npm start`
#### standalone PHB stylesheet
If you just want the stylesheet that is generated to make pages look like they are from the Player's Handbook, you will find it [here](https://github.com/stolksdorf/homebrewery/blob/master/phb.standalone.css).
If you are developing locally and would like to generate your own, follow the above steps and then run `npm run phb`.
### changelog
You can check out the changelog [here](https://github.com/stolksdorf/homebrewery/blob/master/changelog.md).
### license
This project is licensed under [MIT](./license). Which means you are free to use The Homebrewery in any way that you want, except for claiming that you made it yourself.
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 images or resources used.

View File

@@ -1,21 +1,261 @@
## changelog
#### Sunday, 17/01/2016
* Added a printer friendly snippet that injects some CSS to remove backbrounds and images
* Adjusted the styling specific to spell blocks to give it tighter spacing
* Added a changelog! How meta!
#### Thursday, 14/01/2016
* Added view source to see the markdown that made the page
* Added print view
* Fixed API issues that were causing the server to crash
* Increased padding on table cells
* Raw html now shows in view source
#### Wednesday, 3/01/2016
* Added `phb.standalone.css` plus a build system for creating it
* Added page numbers and footer text
* Page accent now flips each page
# changelog
### Saturday, 22/04/217 - v2.7.4
- Give ability to hide the render warning notification
### Friday, 03/03/2017 - v2.7.3
- Increasing the range on the Partial Page Rendering for a quick-fix for it getting out of sync on long brews.
### Saturday, 18/02/2017 - v2.7.2
- Adding ability to delete a brew from the user page, incase the user creates a brew that makes the edit page unrender-able. (re:309)
## BIG NEWS
With the next major release of Homebrewery, v3.0.0, this tool *will no longer support raw HTML input for brew code*. Most issues and errors users are having are because of this feature and it's become too taxing to help and fix these issues.
All brews made previous to the release of v3.0.0 will still render normally.
### Thursday, 19/01/2017 - v2.7.0
- Fixed saving multiple authors and multiple systems on brew metadata (thanks u/PalaNolho re:282)
- Adding in line highlight for new pages
- Added in a simple brew lookup for admin
### Saturday, 14/01/2017 - v2.7.0
- Added a new Render Warning overlay. It detects situations where the brew may not be rendering correctly (wrong browser, browser is zoomed in...) and let's the user know
### Sunday, 25/12/2016 - v2.7.0
- Switching over to using Vitreum v4
- Removed gulp, all tasks are run through npm scripts
- Updating docs for local dev
- Removing support for Docker. I have never used it, nor will I ever test for it, so I don't want to continue to explictly support it on this repo. Feel free to make a fork and make it docker-able though :)
- Changed icon for the metadata
- Made links useable in footer (thanks u/Dustfinger1 re:249)
- Added print media queries to remove box shadow on print (thanks u/dmmagic re: 246)
- Fixed realtime renderer not functioning if loaded with malformed html on load (thanks u/RattiganIV re:247)
- Removed a lot of unused files in shared
- vitreum v4 now lets me use codemirror as a pure node dependacy
### Saturday, 03/12/2016 - v2.6.0
- Added report back to the edit page
- Changed metaeditor icon
- Added a button to quickly share your brew to reddit :)
- Disabled Partial Page Rendering unless your brew hits 75 pages or longer
- The brew renderer will now try and use your first page to judge the page size of each of your brews. This allows you now to set landscape and other weird sizes and everthing should work fine :)
- UI on the user page improved (thanks u/PalaNolho)
- Fixed lists not breaking across columns (thanks u/tyson-nw)
- Added a table of contents snippet (thanks u/tullisar)
- Added a multicolumn snippet
### Thursday, 01/12/2016
- Added in a snippet for a split table
- Added an account nav item to new page
### Sunday, 27/11/2016 - v2.5.1
- Fixed the column rendering on the new user page. Really should have tested that better
- Added a hover tooltip to fully read the brew description
- Made the brew items take up only 25% allowing you to view more per row.
### Wednesday, 23/11/2016 - v2.5.0
- Metadata can now be added to brews
- Added a metadata editor onto the edit and new pages
- Moved deleting a brew into the metadata editor
- Added in account middleware
- Can now search for brews by a specific author
- Editing a brew in anyway while logged in will now add you to the list of authors
- Added a new user page to see others published brews, as well as all of your own brews.
- Added a new nav item for accessing your profile and logging in
### Monday, 14/11/2016
- Updated snippet bar style
- You can now print from a new page without saving
- Added the ability to use ctrl+p and ctrl+s to print and save respectively.
### Monday, 07/11/2016
- Added final touches to the html validator and updating the rest of the branch
- If anyone finds issues with the new HTML validator, please let me know. I hope this will bring a more consistent feel to Homebrewery rendering.
### Friday, 09/09/2016 - v2.4.0
- Adding in a HTML validator that will display warnings whenever you save. This should stop a lot of the issues generated with pages not showing up.
### Saturday, 20/08/2016 - v2.3.0
- Added in a license file
- Updated the welcome text
- Added in a much better Error page
- If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!)
- Improved parsing of embedded html text in brews. (Thanks u/com-charizard!)
- Added in a new coverpage snippet
- Homebrewery will now try and onsert a good title for your brew if you don't provide one
- Homebrewery now re-renders properly when you zoom
- Fixed the noteblock overlapping into titles (thanks u/dsompura!)
- Fixed a bad search route in the admin panel (thanks u/SnappyTom!)
### Friday, 29/07/2016 - v2.2.7
- Adding in descriptive note blocks. (Thanks calculuschild!)
### Thursday, 07/07/2016 - v2.2.6
- Added a new nav item on the homepage for accessing both recently viewed and edited brews (thanks [ChosenSeraph!](https://github.com/stolksdorf/homebrewery/issues/147))
### Friday, 10/06/2016 - v2.2.4
- Added an id to each rendered page
- Allows adding in hyperlinks to specific pages
- Even works after you print to pdf!
### Tuesday, 07/06/2016 - v2.2.2
- Fixed bug with new markdown lexer and aprser not working on print page
### Sunday, 05/06/2016 - v2.2.1
- Adding in a new Class table div block. The old Class table block used weird stacking of HTML elements, resulting is difficult to control behaviour and poor interactiosn with the rest of the page. This new block is much easier to style and work with.
- Added in a new wide table snippet
- Added in a new auto-incremeting page number snippet (thakns u/Ryrok!)
- Lists in monster stat blocks should be fixed now
### Saturday, 04/06/2016 - v2.2.0
- MIgrating The Homebrewery over to hombrewery.naturalcrit.com. It know runs on it's own server, with it's own repo separate from the other tools I'm working on. Makes updating and deploying much easier.
\page
### Sunday, 29/05/2016 - v2.1.0
- Finally added a syntax for doing spell lists. A bit in-depth about why this took so long. Essentially I'm running out of syntax to use in stardard Markdown. There are too many unique elements in the PHB-style to be mapped. I solved this earlier by stacking certain elements together (eg. an `<hr>` before a `blockquote` turns it into moster state block), but those are getting unweildly. I would like to simply wrap these in `div`s with classes, but unfortunately Markdown stops processing when within HTML blocks. To get around this I wrote my own override to the Markdown parser and lexer to process Markdown within a simple div class wrapper. This should open the door for more unique syntaxes in the future. Big step!
- Override Ctrl+P (and cmd+P) to launch to the print page. Many people try to just print either the editing or share page to get a PDF. While this dones;t make much sense, I do get a ton of issues about it. So now if you try to do this, it'll just bring you imediately to the print page. Everybody wins!
- The onboarding flow has also been confusing a few users (Homepage -> new -> save -> edit page). If you edit the Homepage text now, a Call to Action to save your work will pop-up.
- Added a 'Recently Edited' and 'Recently Viewed' nav item to the edit and share page respectively. Each will remember the last 8 items you edited or viewed and when you viewed it. Makes use of the new title attribute of brews to easy navigatation.
- Paragraphs now indent properly after lists (thanks u/slitjen!)
### Friday, 27/05/2016 - v2.0.6
- Updated the issue template for (hopefully) better reporting
- Added suggestion to use chrome while PDF printing
### Wednesday, 25/05/2016 -v2.0.5
- The class table generators have the proper ability score improvement progression.
### Tuesday, 24/05/2016 - v2.0.4
- Fixed extra wide monster stat blocks sometimes only being one column
- The class table generators now follow the proper progression from the PHB (thakns u/IrishBandit)
### Thursday, 19/05/2016 - v2.0.2
- No longer server-side pre-render brews, just incase the user entered invalid HTML, it might crahsh the server
- Bumped up the allowed entity size for extra-large brew (Thanks for reporting it dickboner93)
- Added a little error box when a save fails with a custom link to reporting the issue on github.
\page
### Saturday, 14/05/2016 - v2.0.0 (finally!)
I've been working on v2 for a *very* long time. I want to thank you guys for being paitent.
It started rather small, but as more and more features were added, I decided to just wait until everything was polished.
Massive changelog incoming:
#### Brews
- New flow for creating new brews. Before creating a new brew would immedaitely create a brew in the database and let you edit it. Many people would create a new brew just to experiment and close it, which lead to many "abandoned brews" (see the Under the hood section below). This started eating up a ton of database space. You now have to manually save a new brew for the first time, however Homebrewery will store anything you don't have saved in local storage, just in case your browser crashes or whatever, it will load that up when you go back to `/homebrew/new`
- Black blocking edges around notes and stat blocks when printing to PDFs have been fixed
- Borders sometimes not showing up in the second column have been fixed
- All pseudo-element borders have been replaced with reliable border images.
- Chrome can finally print to PDF as good as Chrome Canary! Updating instructions.
- Added a little page number box.
- Added in a new editable Brew Title. This will be shown in the navbar on share pages, and will default to the file name when you save as PDF. All exsisting brews will be defaulted with an empty title.
- Mutliline lists render better now
- Firefox rendering has been slithgly improved. Firefox and Chrome render things **slightly** differently, over the course of a brew, these little changes add up and lead to very noticable rendering differences between the browsers. I'm trying my best to get Firefox rendering better, but it's a difficult problem.
- A bunch of you have wanted to donate to me. I am super flattered by that. I created a [patreon page](https://www.patreon.com/stolksdorf). If you feel like helping out, head here :)
#### Under the Hood Stuff
- Setup a proper staging environment. Will be using this for tests, and hopefully getting the community to help me test future versions
- Server-side prerendering now much faster
- Regular weekly database back-ups. Your brews are safe!
- Database is now uniquely indexed on both editId and shareId, page loads/saving should be much faster
- Improved Admin console. This helps me answer people's questions about issues with their brews
- Added a whole querying/pagniation API that I can use for stats and answering questions
- Clearing out "Abandoned" brews (smaller than a tweet and haven't been viewed for a week). These account for nearly a third of all stored brews.
#### Interface
- Added in a whole new editor with syntax highlighting for markdown
- Built a splitpane! Remembers where you left the split in between sessions
- Re-organized the snippets into a hierarchical groups. Should be much easier to find what you need
- Partial page rendering is working. The Homebrewery will now only load the viewable pages, and any page with `<style>` tags on them. If you are working on a large brew you should notice *significant* performance improvements
- Edit page saving interface has been improved significantly. Auto-saves after 3 seconds on inactivity, now allows user to save at anytime. Will stop the tab from closing witha pop-up if there are unsaved changes.
- Navbar and overall style has been improved and spacing made more consistent
- Elements under the hood are way more organized and should behaviour much more reliably in many sizes.
- Source now opens to it's own route `/source/:sharedId` instead of just a window. Now easier to share, and won't be blocked by some browsers.
- Print page now auto-opens print dialog. If you want to share your print page link, just remove the `?dialog=true` parameter and it won't open the dialog.
\page
### Wednesday, 20/04/2016
- A lot of admin improvements. Pagninated brew table
- Added a searching and removing abandoned brew api endpoints (turns out about 40% of brews are shorter that a tweet!).
- Fixed the require cache being cleared. Pages should render a bit faster now.
- Pulled in `kkragenbrink`s fix for nested lists, Thanks!
### Wednesday, 06/04/2016 - v1.4
* Pages will now partially render. This should greatly speed up *very* large homebrews. The Homebreery will figure out which page you should be looking at and render that page, the page before, and the page after.
* Zooming should be fixed. I've changed the font size units to be cm, which match the units of the page. Zooming in and out now look much better.
### Monday, 29/02/2016 - v1.3.1
* Removng the changelog button from the Share page
* Added a A4 page size snippet (thanks guppy42!)
* Added support for `<sup>` and `<sub>` tags (thanks crashinworld14!)
### Saturday, 20/02/2016
* Fixed h1 headers not going full width (thanks McToomin27)
* Added a github issue template
## v1.3.0
### Friday, 19/02/2016
* Improved the admin panel
* Added ability to clear away old empty brews
* Added delete button to the edit page
* Added a dynamically updating changelog page! Nifty!
* Added stlying for wide monster stat blocks and single column class tables
* Added snippets for wide monster stat blocks and single column class tables
### Tuesday, 16/02/2016
* Paragraphs right after tables now indent (thanks LikeAJi6!)
* Added a `@page` css rule to auto turn off margins when printing
* Added a `page-break` property on each `.phb` page to properly page the pages up when exporting (thanks Jokefury!)
* Improved first character rendering on Firefox
* Improved table spacing a bit
* Changed padding at page bottom for better fit and clipping of elements
* Improved spacing for bold text (thanks nickpunt!)
## v1.2.0
### Sunday, 17/01/2016
* Added a printer friendly snippet that injects some CSS to remove backbrounds and images
* Adjusted the styling specific to spell blocks to give it tighter spacing
* Added a changelog! How meta!
## v1.1.0
### Thursday, 14/01/2016
* Added view source to see the markdown that made the page
* Added print view
* Fixed API issues that were causing the server to crash
* Increased padding on table cells
* Raw html now shows in view source
## v1.0.0 - Release
### Wednesday, 3/01/2016
* Added `phb.standalone.css` plus a build system for creating it
* Added page numbers and footer text
* Page accent now flips each page

View File

@@ -1,21 +1,21 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
var HomebrewAdmin = require('./homebrewAdmin/homebrewAdmin.jsx');
const HomebrewAdmin = require('./homebrewAdmin/homebrewAdmin.jsx');
var Admin = React.createClass({
getDefaultProps: function() {
const Admin = createClass({
getDefaultProps : function() {
return {
url : "",
admin_key : "",
url : '',
admin_key : '',
homebrews : [],
};
},
render : function(){
var self = this;
return(
return (
<div className='admin'>
<header>
@@ -27,8 +27,6 @@ var Admin = React.createClass({
<div className='container'>
<a target="_blank" href='https://www.google.com/analytics/web/?hl=en#report/defaultid/a72212009w109843310p114529111/'>Link to Google Analytics</a>
<HomebrewAdmin homebrews={this.props.homebrews} admin_key={this.props.admin_key} />
</div>

View File

@@ -1,39 +1,39 @@
@import 'naturalCrit/styles/reset.less';
@import 'naturalCrit/styles/elements.less';
@import 'naturalCrit/styles/animations.less';
@import 'naturalCrit/styles/colors.less';
@import 'naturalCrit/styles/tooltip.less';
@import 'font-awesome/css/font-awesome.css';
html,body, #reactContainer, .naturalCrit{
min-height : 100%;
}
@sidebarWidth : 250px;
body{
background-color : #eee;
font-family : 'Open Sans', sans-serif;
color : #4b5055;
font-weight : 100;
text-rendering : optimizeLegibility;
margin : 0;
padding : 0;
height : 100%;
}
.admin{
header{
background-color : @red;
font-size: 2em;
padding : 20px 0px;
color : white;
margin-bottom: 30px;
i{
margin-right: 30px;
}
}
@import 'naturalcrit/styles/reset.less';
@import 'naturalcrit/styles/elements.less';
@import 'naturalcrit/styles/animations.less';
@import 'naturalcrit/styles/colors.less';
@import 'naturalcrit/styles/tooltip.less';
@import 'font-awesome/css/font-awesome.css';
html,body, #reactContainer, .naturalCrit{
min-height : 100%;
}
@sidebarWidth : 250px;
body{
background-color : #eee;
font-family : 'Open Sans', sans-serif;
color : #4b5055;
font-weight : 100;
text-rendering : optimizeLegibility;
margin : 0;
padding : 0;
height : 100%;
}
.admin{
header{
background-color : @red;
font-size: 2em;
padding : 20px 0px;
color : white;
margin-bottom: 30px;
i{
margin-right: 30px;
}
}
}

View File

@@ -0,0 +1,68 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const Moment = require('moment');
const BrewLookup = createClass({
getDefaultProps : function() {
return {
adminKey : '',
};
},
getInitialState : function() {
return {
query : '',
resultBrew : null,
searching : false
};
},
handleChange : function(e){
this.setState({
query : e.target.value
});
},
lookup : function(){
this.setState({ searching: true });
request.get(`/admin/lookup/${this.state.query}`)
.query({ admin_key: this.props.adminKey })
.end((err, res)=>{
this.setState({
searching : false,
resultBrew : (err ? null : res.body)
});
});
},
renderFoundBrew : function(){
if(this.state.searching) return <div className='searching'><i className='fa fa-spin fa-spinner' /></div>;
if(!this.state.resultBrew) return <div className='noBrew'>No brew found.</div>;
const brew = this.state.resultBrew;
return <div className='brewRow'>
<div>{brew.title}</div>
<div>{brew.authors.join(', ')}</div>
<div><a href={`/edit/${brew.editId}`} target='_blank' rel='noopener noreferrer'>/edit/{brew.editId}</a></div>
<div><a href={`/share/${brew.shareId}`} target='_blank' rel='noopener noreferrer'>/share/{brew.shareId}</a></div>
<div>{Moment(brew.updatedAt).fromNow()}</div>
<div>{brew.views}</div>
</div>;
},
render : function(){
return <div className='brewLookup'>
<h1>Brew Lookup</h1>
<input type='text' value={this.state.query} onChange={this.handleChange} placeholder='edit or share id...' />
<button onClick={this.lookup}><i className='fa fa-search'/></button>
{this.renderFoundBrew()}
</div>;
}
});
module.exports = BrewLookup;

View File

@@ -0,0 +1,8 @@
.brewLookup{
height : 200px;
input{
height : 33px;
padding : 0px 10px;
margin-bottom: 20px;
}
}

View File

@@ -0,0 +1,66 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const BrewSearch = createClass({
getDefaultProps : function() {
return {
admin_key : ''
};
},
getInitialState : function() {
return {
searchTerm : '',
brew : null,
};
},
search : function(){
request.get(`/homebrew/api/search?id=${this.state.searchTerm}`)
.query({
admin_key : this.props.admin_key,
})
.end((err, res)=>{
console.log(err, res, res.body.brews[0]);
this.setState({
brew : res.body.brews[0],
});
});
},
handleChange : function(e){
this.setState({
searchTerm : e.target.value
});
},
handleSearchClick : function(){
this.search();
},
renderBrew : function(){
if(!this.state.brew) return null;
return <div className='brew'>
<div>Edit id : {this.state.brew.editId}</div>
<div>Share id : {this.state.brew.shareId}</div>
</div>;
},
render : function(){
return <div className='search'>
<input type='text' value={this.state.searchTerm} onChange={this.handleChange} />
<button onClick={this.handleSearchClick}>Search</button>
{this.renderBrew()}
</div>;
},
});
module.exports = BrewSearch;

View File

@@ -1,64 +1,169 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
var Moment = require('moment')
const Moment = require('moment');
var HomebrewAdmin = React.createClass({
getDefaultProps: function() {
const BrewLookup = require('./brewLookup/brewLookup.jsx');
const HomebrewAdmin = createClass({
getDefaultProps : function() {
return {
homebrews : [],
admin_key : ''
};
},
renderBrews : function(){
return _.map(this.props.homebrews, (brew)=>{
return <tr className={cx('brewRow', {'isEmpty' : brew.text == ""})} key={brew.sharedId}>
getInitialState : function() {
return {
page : 0,
count : 20,
brewCache : {},
total : 0,
};
},
<td>{brew.editId}</td>
<td>{brew.shareId}</td>
fetchBrews : function(page){
request.get('/api/search')
.query({
admin_key : this.props.admin_key,
count : this.state.count,
page : page
})
.end((err, res)=>{
if(err || !res.body || !res.body.brews) return;
const newCache = _.extend({}, this.state.brewCache);
newCache[page] = res.body.brews;
this.setState({
brewCache : newCache,
total : res.body.total,
count : res.body.count
});
});
},
componentDidMount : function() {
this.fetchBrews(this.state.page);
},
changePageTo : function(page){
if(!this.state.brewCache[page]){
this.fetchBrews(page);
}
this.setState({
page : page
});
},
clearInvalidBrews : function(){
request.get('/api/invalid')
.query({ admin_key: this.props.admin_key })
.end((err, res)=>{
if(!confirm(`This will remove ${res.body.count} brews. Are you sure?`)) return;
request.get('/api/invalid')
.query({ admin_key: this.props.admin_key, do_it: true })
.end((err, res)=>{
alert('Done!');
});
});
},
deleteBrew : function(brewId){
if(!confirm(`Are you sure you want to delete '${brewId}'?`)) return;
request.get(`/api/remove/${brewId}`)
.query({ admin_key: this.props.admin_key })
.end(function(err, res){
window.location.reload();
});
},
handlePageChange : function(dir){
this.changePageTo(this.state.page + dir);
},
renderPagnination : function(){
let outOf;
if(this.state.total){
outOf = `${this.state.page} / ${Math.round(this.state.total/this.state.count)}`;
}
return <div className='pagnination'>
<i className='fa fa-chevron-left' onClick={()=>this.handlePageChange(-1)}/>
{outOf}
<i className='fa fa-chevron-right' onClick={()=>this.handlePageChange(1)}/>
</div>;
},
renderBrews : function(){
const brews = this.state.brewCache[this.state.page] || _.times(this.state.count);
return _.map(brews, (brew)=>{
return <tr className={cx('brewRow', { 'isEmpty': brew.text == 'false' })} key={brew.shareId || brew}>
<td><a href={`/edit/${brew.editId}`} target='_blank' rel='noopener noreferrer'>{brew.editId}</a></td>
<td><a href={`/share/${brew.shareId}`} target='_blank' rel='noopener noreferrer'>{brew.shareId}</a></td>
<td>{Moment(brew.createdAt).fromNow()}</td>
<td>{Moment(brew.updatedAt).fromNow()}</td>
<td>{Moment(brew.lastViewed).fromNow()}</td>
<td>{brew.views}</td>
<td className='preview'>
<a target="_blank" href={'/homebrew/share/' + brew.shareId}>view</a>
<div className='content'>
{brew.text.slice(0, 500)}
<td>
<div className='deleteButton' onClick={()=>this.deleteBrew(brew.editId)}>
<i className='fa fa-trash' />
</div>
</td>
<td><a href={'/homebrew/remove/' + brew.editId +'?admin_key=' + this.props.admin_key}><i className='fa fa-trash' /></a></td>
</tr>
</tr>;
});
},
})
renderBrewTable : function(){
return <div className='brewTable'>
<table>
<thead>
<tr>
<th>Edit Id</th>
<th>Share Id</th>
<th>Created At</th>
<th>Last Updated</th>
<th>Last Viewed</th>
<th>Views</th>
</tr>
</thead>
<tbody>
{this.renderBrews()}
</tbody>
</table>
</div>;
},
render : function(){
var self = this;
return(
<div className='homebrewAdmin'>
<h2>Homebrews - {this.props.homebrews.length}</h2>
<table>
<thead>
<tr>
<th>Edit Id</th>
<th>Share Id</th>
<th>Created At</th>
<th>Last Updated</th>
<th>Last Viewed</th>
<th>Number of Views</th>
<th>Preview</th>
</tr>
</thead>
<tbody>
{this.renderBrews()}
</tbody>
</table>
</div>
);
return <div className='homebrewAdmin'>
<BrewLookup adminKey={this.props.admin_key} />
{/*
<h2>
Homebrews - {this.state.total}
</h2>
{this.renderPagnination()}
{this.renderBrewTable()}
<button className='clearOldButton' onClick={this.clearInvalidBrews}>
Clear Old
</button>
<BrewSearch admin_key={this.props.admin_key} />
*/}
</div>;
}
});

View File

@@ -1,44 +1,53 @@
.homebrewAdmin{
table{
overflow-y : scroll;
max-height : 800px;
th{
padding : 10px;
font-weight : 800;
}
tr:nth-child(even){
background-color : fade(@green, 10%);
}
tr.isEmpty{
background-color : fade(@red, 30%);
}
td{
min-width : 100px;
padding : 10px;
text-align : center;
&.preview{
position : relative;
&:hover{
.content{
display : block;
}
}
.content{
position : absolute;
display : none;
top : 100%;
left : 0px;
z-index : 1000;
max-height : 500px;
width : 300px;
padding : 30px;
background-color : white;
font-family : monospace;
text-align : left;
pointer-events : none;
}
}
}
}
.homebrewAdmin{
margin-bottom: 80px;
.brewTable{
table{
th{
padding : 10px;
font-weight : 800;
}
tr:nth-child(even){
background-color : fade(@green, 10%);
}
tr.isEmpty{
background-color : fade(@red, 30%);
}
td{
min-width : 100px;
padding : 10px;
text-align : center;
&.preview{
position : relative;
&:hover{
.content{
display : block;
}
}
.content{
position : absolute;
display : none;
top : 100%;
left : 0px;
z-index : 1000;
max-height : 500px;
width : 300px;
padding : 30px;
background-color : white;
font-family : monospace;
text-align : left;
pointer-events : none;
}
}
}
}
}
.deleteButton{
cursor: pointer;
}
button.clearOldButton{
float : right;
}
}

View File

@@ -0,0 +1,148 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Markdown = require('naturalcrit/markdown.js');
const ErrorBar = require('./errorBar/errorBar.jsx');
//TODO: move to the brew renderer
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
const PAGE_HEIGHT = 1056;
const PPR_THRESHOLD = 50;
const BrewRenderer = createClass({
getDefaultProps : function() {
return {
text : '',
errors : []
};
},
getInitialState : function() {
const pages = this.props.text.split('\\page');
return {
viewablePageNumber : 0,
height : 0,
isMounted : false,
pages : pages,
usePPR : pages.length >= PPR_THRESHOLD,
};
},
height : 0,
lastRender : <div></div>,
componentDidMount : function() {
this.updateSize();
window.addEventListener('resize', this.updateSize);
},
componentWillUnmount : function() {
window.removeEventListener('resize', this.updateSize);
},
componentWillReceiveProps : function(nextProps) {
const pages = nextProps.text.split('\\page');
this.setState({
pages : pages,
usePPR : pages.length >= PPR_THRESHOLD
});
},
updateSize : function() {
this.setState({
height : this.refs.main.parentNode.clientHeight,
isMounted : true
});
},
handleScroll : function(e){
const target = e.target;
this.setState((prevState)=>({
viewablePageNumber : Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length)
}));
},
shouldRender : function(pageText, index){
if(!this.state.isMounted) return false;
const viewIndex = this.state.viewablePageNumber;
if(index == viewIndex - 3) return true;
if(index == viewIndex - 2) return true;
if(index == viewIndex - 1) return true;
if(index == viewIndex) return true;
if(index == viewIndex + 1) return true;
if(index == viewIndex + 2) return true;
if(index == viewIndex + 3) return true;
//Check for style tages
if(pageText.indexOf('<style>') !== -1) return true;
return false;
},
renderPageInfo : function(){
return <div className='pageInfo'>
{this.state.viewablePageNumber + 1} / {this.state.pages.length}
</div>;
},
renderPPRmsg : function(){
if(!this.state.usePPR) return;
return <div className='ppr_msg'>
Partial Page Renderer enabled, because your brew is so large. May effect rendering.
</div>;
},
renderDummyPage : function(index){
return <div className='phb' id={`p${index + 1}`} key={index}>
<i className='fa fa-spinner fa-spin' />
</div>;
},
renderPage : function(pageText, index){
return <div className='phb' id={`p${index + 1}`} dangerouslySetInnerHTML={{ __html: Markdown.render(pageText) }} key={index} />;
},
renderPages : function(){
if(this.state.usePPR){
return _.map(this.state.pages, (page, index)=>{
if(this.shouldRender(page, index)){
return this.renderPage(page, index);
} else {
return this.renderDummyPage(index);
}
});
}
if(this.props.errors && this.props.errors.length) return this.lastRender;
this.lastRender = _.map(this.state.pages, (page, index)=>{
return this.renderPage(page, index);
});
return this.lastRender;
},
render : function(){
return (
<React.Fragment>
<div className='brewRenderer'
onScroll={this.handleScroll}
ref='main'
style={{ height: this.state.height }}>
<ErrorBar errors={this.props.errors} />
<RenderWarnings />
<div className='pages' ref='pages'>
{this.renderPages()}
</div>
</div>;
{this.renderPageInfo()}
{this.renderPPRmsg()}
</React.Fragment>
);
}
});
module.exports = BrewRenderer;

View File

@@ -0,0 +1,40 @@
@import (less) './client/homebrew/phbStyle/phb.style.less';
.pane{
position : relative;
}
.brewRenderer{
will-change : transform;
overflow-y : scroll;
.pages{
margin : 30px 0px;
&>.phb{
margin-right : auto;
margin-bottom : 30px;
margin-left : auto;
box-shadow : 1px 4px 14px #000;
}
}
}
.pageInfo{
position : absolute;
right : 17px;
bottom : 0;
z-index : 1000;
padding : 8px 10px;
background-color : #333;
font-size : 10px;
font-weight : 800;
color : white;
}
.ppr_msg{
position : absolute;
left : 0px;
bottom : 0;
z-index : 1000;
padding : 8px 10px;
background-color : #333;
font-size : 10px;
font-weight : 800;
color : white;
}

View File

@@ -0,0 +1,74 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const ErrorBar = createClass({
getDefaultProps : function() {
return {
errors : []
};
},
hasOpenError : false,
hasCloseError : false,
hasMatchError : false,
renderErrors : function(){
this.hasOpenError = false;
this.hasCloseError = false;
this.hasMatchError = false;
const errors = _.map(this.props.errors, (err, idx)=>{
if(err.id == 'OPEN') this.hasOpenError = true;
if(err.id == 'CLOSE') this.hasCloseError = true;
if(err.id == 'MISMATCH') this.hasMatchError = true;
return <li key={idx}>
Line {err.line} : {err.text}, '{err.type}' tag
</li>;
});
return <ul>{errors}</ul>;
},
renderProtip : function(){
const msg = [];
if(this.hasOpenError){
msg.push(<div>
An unmatched opening tag means there's an opened tag that isn't closed, you need to close a tag, like this {'</div>'}. Make sure to match types!
</div>);
}
if(this.hasCloseError){
msg.push(<div>
An unmatched closing tag means you closed a tag without opening it. Either remove it, you check to where you think you opened it.
</div>);
}
if(this.hasMatchError){
msg.push(<div>
A type mismatch means you closed a tag, but the last open tag was a different type.
</div>);
}
return <div className='protips'>
<h4>Protips!</h4>
{msg}
</div>;
},
render : function(){
if(!this.props.errors.length) return null;
return <div className='errorBar'>
<i className='fa fa-exclamation-triangle' />
<h3> There are HTML errors in your markup</h3>
<small>If these aren't fixed your brew will not render properly when you print it to PDF or share it</small>
{this.renderErrors()}
<hr />
{this.renderProtip()}
</div>;
}
});
module.exports = ErrorBar;

View File

@@ -0,0 +1,60 @@
.errorBar{
position : absolute;
z-index : 10000;
box-sizing : border-box;
width : 100%;
margin-right : 13px;
padding : 20px;
padding-bottom : 10px;
padding-left : 100px;
background-color : @red;
color : white;
i{
position : absolute;
left : 30px;
opacity : 0.8;
font-size : 3em;
}
h3{
font-size : 1.1em;
font-weight : 800;
}
ul{
margin-top : 15px;
font-size : 0.8em;
list-style-position : inside;
list-style-type : disc;
li{
line-height : 1.6em;
}
}
hr{
box-sizing : border-box;
height : 2px;
width : 150%;
margin-top : 25px;
margin-bottom : 15px;
margin-left : -100px;
background-color : darken(@red, 8%);
border : none;
}
small{
font-size: 0.6em;
opacity: 0.7;
}
.protips{
margin-left : -80px;
font-size : 0.6em;
&>div{
margin-bottom : 10px;
line-height : 1.2em;
}
h4{
opacity : 0.8;
font-weight : 800;
line-height : 1.5em;
text-transform : uppercase;
}
}
}

View File

@@ -1,86 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Statusbar = require('../statusbar/statusbar.jsx');
var PageContainer = require('../pageContainer/pageContainer.jsx');
var Editor = require('../editor/editor.jsx');
var FullClassGen = require('../editor/snippets/fullclass.gen.js');
var request = require("superagent");
var SAVE_TIMEOUT = 3000;
var EditPage = React.createClass({
getDefaultProps: function() {
return {
id : null,
entry : {
text : "",
shareId : null,
editId : null,
createdAt : null,
updatedAt : null,
}
};
},
getInitialState: function() {
return {
text: this.props.entry.text,
pending : false,
lastUpdated : this.props.entry.updatedAt
};
},
componentDidMount: function() {
var self = this;
window.onbeforeunload = function(){
if(!self.state.pending) return;
return "You have unsaved changes!";
}
},
handleTextChange : function(text){
this.setState({
text : text,
pending : true
});
this.save();
},
save : _.debounce(function(){
request
.put('/homebrew/update/' + this.props.id)
.send({text : this.state.text})
.end((err, res) => {
this.setState({
pending : false,
lastUpdated : res.body.updatedAt
})
})
}, SAVE_TIMEOUT),
render : function(){
return <div className='editPage'>
<Statusbar
editId={this.props.entry.editId}
shareId={this.props.entry.shareId}
printId={this.props.entry.shareId}
lastUpdated={this.state.lastUpdated}
isPending={this.state.pending} />
<div className='paneSplit'>
<div className='leftPane'>
<Editor text={this.state.text} onChange={this.handleTextChange} />
</div>
<div className='rightPane'>
<PageContainer text={this.state.text} />
</div>
</div>
</div>
}
});
module.exports = EditPage;

View File

@@ -1,5 +0,0 @@
.editPage{
}

View File

@@ -1,53 +1,137 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var SnippetIcons = require('./snippets/snippets.js');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx');
const SnippetBar = require('./snippetbar/snippetbar.jsx');
const MetadataEditor = require('./metadataEditor/metadataEditor.jsx');
var Editor = React.createClass({
getDefaultProps: function() {
const splice = function(str, index, inject){
return str.slice(0, index) + inject + str.slice(index);
};
const SNIPPETBAR_HEIGHT = 25;
const Editor = createClass({
getDefaultProps : function() {
return {
text : "",
onChange : function(){}
value : '',
onChange : ()=>{},
metadata : {},
onMetadataChange : ()=>{},
};
},
componentDidMount: function() {
this.refs.textarea.focus();
getInitialState : function() {
return {
showMetadataEditor : false
};
},
cursorPosition : {
line : 0,
ch : 0
},
handleTextChange : function(e){
this.props.onChange(e.target.value);
componentDidMount : function() {
this.updateEditorSize();
this.highlightPageLines();
window.addEventListener('resize', this.updateEditorSize);
},
componentWillUnmount : function() {
window.removeEventListener('resize', this.updateEditorSize);
},
iconClick : function(snippetFn){
var curPos = this.refs.textarea.selectionStart;
this.props.onChange(this.props.text.slice(0, curPos) +
snippetFn() +
this.props.text.slice(curPos + 1));
updateEditorSize : function() {
let paneHeight = this.refs.main.parentNode.clientHeight;
paneHeight -= SNIPPETBAR_HEIGHT + 1;
this.refs.codeEditor.codeMirror.setSize(null, paneHeight);
},
renderTemplateIcons : function(){
return _.map(SnippetIcons, (t) => {
return <div className='icon' key={t.icon}
onClick={this.iconClick.bind(this, t.snippet)}
data-tooltip={t.tooltip}>
<i className={'fa ' + t.icon} />
</div>;
})
handleTextChange : function(text){
this.props.onChange(text);
},
handleCursorActivty : function(curpos){
this.cursorPosition = curpos;
},
handleInject : function(injectText){
const lines = this.props.value.split('\n');
lines[this.cursorPosition.line] = splice(lines[this.cursorPosition.line], this.cursorPosition.ch, injectText);
this.handleTextChange(lines.join('\n'));
this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length);
},
handgleToggle : function(){
this.setState({
showMetadataEditor : !this.state.showMetadataEditor
});
},
getCurrentPage : function(){
const lines = this.props.value.split('\n').slice(0, this.cursorPosition.line + 1);
return _.reduce(lines, (r, line)=>{
if(line.indexOf('\\page') !== -1) r++;
return r;
}, 1);
},
highlightPageLines : function(){
if(!this.refs.codeEditor) return;
const codeMirror = this.refs.codeEditor.codeMirror;
const lineNumbers = _.reduce(this.props.value.split('\n'), (r, line, lineNumber)=>{
if(line.indexOf('\\page') !== -1){
codeMirror.addLineClass(lineNumber, 'background', 'pageLine');
r.push(lineNumber);
}
return r;
}, []);
return lineNumbers;
},
brewJump : function(){
const currentPage = this.getCurrentPage();
window.location.hash = `p${currentPage}`;
},
//Called when there are changes to the editor's dimensions
update : function(){
this.refs.codeEditor.updateSize();
},
renderMetadataEditor : function(){
if(!this.state.showMetadataEditor) return;
return <MetadataEditor
metadata={this.props.metadata}
onChange={this.props.onMetadataChange}
/>;
},
render : function(){
var self = this;
return(
<div className='editor'>
<div className='textIcons'>
{this.renderTemplateIcons()}
this.highlightPageLines();
return (
<div className='editor' ref='main'>
<SnippetBar
brew={this.props.value}
onInject={this.handleInject}
onToggle={this.handgleToggle}
showmeta={this.state.showMetadataEditor} />
{this.renderMetadataEditor()}
<CodeEditor
ref='codeEditor'
wrap={true}
language='gfm'
value={this.props.value}
onChange={this.handleTextChange}
onCursorActivity={this.handleCursorActivty} />
{/*
<div className='brewJump' onClick={this.brewJump}>
<i className='fa fa-arrow-right' />
</div>
<textarea
ref='textarea'
value={this.props.text}
onChange={this.handleTextChange} />
*/}
</div>
);
}
@@ -55,3 +139,8 @@ var Editor = React.createClass({
module.exports = Editor;

View File

@@ -1,40 +1,29 @@
.editor{
position : relative;
height : 100%;
min-height : 100%;
width : 100%;
display: flex;
flex-direction: column;
.textIcons{
display : inline-block;
vertical-align : top;
.icon{
display : inline-block;
height : 30px;
width : 30px;
cursor : pointer;
font-size : 1.5em;
line-height : 30px;
text-align : center;
&:nth-child(8n + 1){ background-color: @blue; }
&:nth-child(8n + 2){ background-color: @orange; }
&:nth-child(8n + 3){ background-color: @teal; }
&:nth-child(8n + 4){ background-color: @red; }
&:nth-child(8n + 5){ background-color: @purple; }
&:nth-child(8n + 6){ background-color: @silver; }
&:nth-child(8n + 7){ background-color: @yellow; }
&:nth-child(8n + 8){ background-color: @green; }
}
}
textarea{
box-sizing : border-box;
resize : none;
overflow-y : scroll;
height : 100%;
width : 100%;
padding : 10px;
border : none;
outline: none;
}
.editor{
position : relative;
width : 100%;
.codeEditor{
height : 100%;
.pageLine{
background-color : fade(#333, 15%);
border-bottom : #333 solid 1px;
}
}
.brewJump{
position: absolute;
background-color: @teal;
cursor: pointer;
width : 30px;
height : 30px;
display : flex;
align-items : center;
bottom : 20px;
right : 20px;
z-index: 1000000;
justify-content:center;
.tooltipLeft("Jump to brew page");
}
}

View File

@@ -0,0 +1,176 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
const MetadataEditor = createClass({
getDefaultProps : function() {
return {
metadata : {
editId : null,
title : '',
description : '',
tags : '',
published : false,
authors : [],
systems : []
},
onChange : ()=>{}
};
},
handleFieldChange : function(name, e){
this.props.onChange(_.merge({}, this.props.metadata, {
[name] : e.target.value
}));
},
handleSystem : function(system, e){
if(e.target.checked){
this.props.metadata.systems.push(system);
} else {
this.props.metadata.systems = _.without(this.props.metadata.systems, system);
}
this.props.onChange(this.props.metadata);
},
handlePublish : function(val){
this.props.onChange(_.merge({}, this.props.metadata, {
published : val
}));
},
handleDelete : function(){
if(!confirm('are you sure you want to delete this brew?')) return;
if(!confirm('are you REALLY sure? You will not be able to recover it')) return;
request.get(`/api/remove/${this.props.metadata.editId}`)
.send()
.end(function(err, res){
window.location.href = '/';
});
},
getRedditLink : function(){
const meta = this.props.metadata;
const title = `${meta.title} [${meta.systems.join(' ')}]`;
const text = `Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
**[Homebrewery Link](http://homebrewery.naturalcrit.com/share/${meta.shareId})**`;
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title)}&text=${encodeURIComponent(text)}`;
},
renderSystems : function(){
return _.map(SYSTEMS, (val)=>{
return <label key={val}>
<input
type='checkbox'
checked={_.includes(this.props.metadata.systems, val)}
onChange={(e)=>this.handleSystem(val, e)} />
{val}
</label>;
});
},
renderPublish : function(){
if(this.props.metadata.published){
return <button className='unpublish' onClick={()=>this.handlePublish(false)}>
<i className='fa fa-ban' /> unpublish
</button>;
} else {
return <button className='publish' onClick={()=>this.handlePublish(true)}>
<i className='fa fa-globe' /> publish
</button>;
}
},
renderDelete : function(){
if(!this.props.metadata.editId) return;
return <div className='field delete'>
<label>delete</label>
<div className='value'>
<button className='publish' onClick={this.handleDelete}>
<i className='fa fa-trash' /> delete brew
</button>
</div>
</div>;
},
renderAuthors : function(){
let text = 'None.';
if(this.props.metadata.authors.length){
text = this.props.metadata.authors.join(', ');
}
return <div className='field authors'>
<label>authors</label>
<div className='value'>
{text}
</div>
</div>;
},
renderShareToReddit : function(){
if(!this.props.metadata.shareId) return;
return <div className='field reddit'>
<label>reddit</label>
<div className='value'>
<a href={this.getRedditLink()} target='_blank' rel='noopener noreferrer'>
<button className='publish'>
<i className='fa fa-reddit-alien' /> share to reddit
</button>
</a>
</div>
</div>;
},
render : function(){
return <div className='metadataEditor'>
<div className='field title'>
<label>title</label>
<input type='text' className='value'
value={this.props.metadata.title}
onChange={(e)=>this.handleFieldChange('title', e)} />
</div>
<div className='field description'>
<label>description</label>
<textarea value={this.props.metadata.description} className='value'
onChange={(e)=>this.handleFieldChange('description', e)} />
</div>
{/*}
<div className='field tags'>
<label>tags</label>
<textarea value={this.props.metadata.tags}
onChange={(e)=>this.handleFieldChange('tags', e)} />
</div>
*/}
<div className='field systems'>
<label>systems</label>
<div className='value'>
{this.renderSystems()}
</div>
</div>
{this.renderAuthors()}
<div className='field publish'>
<label>publish</label>
<div className='value'>
{this.renderPublish()}
<small>Published homebrews will be publicly viewable and searchable (eventually...)</small>
</div>
</div>
{this.renderShareToReddit()}
{this.renderDelete()}
</div>;
}
});
module.exports = MetadataEditor;

View File

@@ -0,0 +1,79 @@
.metadataEditor{
position : absolute;
z-index : 10000;
box-sizing : border-box;
width : 100%;
padding : 25px;
background-color : #999;
.field{
display : flex;
width : 100%;
margin-bottom : 10px;
&>label{
display : inline-block;
vertical-align : top;
width : 80px;
font-size : 0.7em;
font-weight : 800;
line-height : 1.8em;
text-transform : uppercase;
flex-grow : 0;
}
&>.value{
flex-grow : 1;
}
}
.description.field textarea.value{
resize : none;
height : 5em;
font-family : 'Open Sans', sans-serif;
font-size : 0.8em;
}
.systems.field .value{
label{
vertical-align : middle;
margin-right : 15px;
cursor : pointer;
font-size : 0.7em;
font-weight : 800;
user-select : none;
}
input{
vertical-align : middle;
cursor : pointer;
}
}
.publish.field .value{
position : relative;
margin-bottom: 15px;
button.publish{
.button(@blueLight);
}
button.unpublish{
.button(@silver);
}
small{
position : absolute;
bottom : -15px;
left : 0px;
font-size : 0.6em;
font-style : italic;
}
}
.delete.field .value{
button{
.button(@red);
}
}
.reddit.field .value{
button{
.button(@purple);
}
}
.authors.field .value{
font-size: 0.8em;
line-height : 1.5em;
}
}

View File

@@ -0,0 +1,95 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Snippets = require('./snippets/snippets.js');
const execute = function(val, brew){
if(_.isFunction(val)) return val(brew);
return val;
};
const Snippetbar = createClass({
getDefaultProps : function() {
return {
brew : '',
onInject : ()=>{},
onToggle : ()=>{},
showmeta : false
};
},
handleSnippetClick : function(injectedText){
this.props.onInject(injectedText);
},
renderSnippetGroups : function(){
return _.map(Snippets, (snippetGroup)=>{
return <SnippetGroup
brew={this.props.brew}
groupName={snippetGroup.groupName}
icon={snippetGroup.icon}
snippets={snippetGroup.snippets}
key={snippetGroup.groupName}
onSnippetClick={this.handleSnippetClick}
/>;
});
},
render : function(){
return <div className='snippetBar'>
{this.renderSnippetGroups()}
<div className={cx('toggleMeta', { selected: this.props.showmeta })}
onClick={this.props.onToggle}>
<i className='fa fa-bars' />
</div>
</div>;
}
});
module.exports = Snippetbar;
const SnippetGroup = createClass({
getDefaultProps : function() {
return {
brew : '',
groupName : '',
icon : 'fa-rocket',
snippets : [],
onSnippetClick : function(){},
};
},
handleSnippetClick : function(snippet){
this.props.onSnippetClick(execute(snippet.gen, this.props.brew));
},
renderSnippets : function(){
return _.map(this.props.snippets, (snippet)=>{
return <div className='snippet' key={snippet.name} onClick={()=>this.handleSnippetClick(snippet)}>
<i className={`fa fa-fw ${snippet.icon}`} />
{snippet.name}
</div>;
});
},
render : function(){
return <div className='snippetGroup'>
<div className='text'>
<i className={`fa fa-fw ${this.props.icon}`} />
<span className='groupName'>{this.props.groupName}</span>
</div>
<div className='dropdown'>
{this.renderSnippets()}
</div>
</div>;
},
});

View File

@@ -0,0 +1,73 @@
.snippetBar{
@height : 25px;
position : relative;
height : @height;
background-color : #ddd;
.toggleMeta{
position : absolute;
top : 0px;
right : 0px;
height : @height;
width : @height;
cursor : pointer;
line-height : @height;
text-align : center;
.tooltipLeft("Edit Brew Metadata");
&:hover, &.selected{
background-color : #999;
}
}
.snippetGroup{
display : inline-block;
height : @height;
padding : 0px 5px;
cursor : pointer;
font-size : 0.6em;
font-weight : 800;
line-height : @height;
text-transform : uppercase;
border-right : 1px solid black;
i{
vertical-align : middle;
margin-right : 3px;
font-size : 1.2em;
}
&:hover, &.selected{
background-color : #999;
}
.text{
line-height : @height;
.groupName{
font-size : 10px;
}
}
&:hover{
.dropdown{
visibility : visible;
}
}
.dropdown{
position : absolute;
top : 100%;
visibility : hidden;
z-index : 1000;
margin-left : -5px;
padding : 0px;
background-color : #ddd;
.snippet{
.animate(background-color);
padding : 5px;
cursor : pointer;
font-size : 10px;
i{
margin-right : 8px;
font-size : 13px;
}
&:hover{
background-color : #999;
}
}
}
}
}

View File

@@ -0,0 +1,42 @@
const _ = require('lodash');
module.exports = function(classname){
classname = _.sample(['archivist', 'fancyman', 'linguist', 'fletcher',
'notary', 'berserker-typist', 'fishmongerer', 'manicurist', 'haberdasher', 'concierge']);
classname = classname.toLowerCase();
const hitDie = _.sample([4, 6, 8, 10, 12]);
const abilityList = ['Strength', 'Dexerity', 'Constitution', 'Wisdom', 'Charisma', 'Intelligence'];
const skillList = ['Acrobatics ', 'Animal Handling', 'Arcana', 'Athletics', 'Deception', 'History', 'Insight', 'Intimidation', 'Investigation', 'Medicine', 'Nature', 'Perception', 'Performance', 'Persuasion', 'Religion', 'Sleight of Hand', 'Stealth', 'Survival'];
return [
'## Class Features',
`As a ${classname}, you gain the following class features`,
'#### Hit Points',
'___',
`- **Hit Dice:** 1d${hitDie} per ${classname} level`,
`- **Hit Points at 1st Level:** ${hitDie} + your Constitution modifier`,
`- **Hit Points at Higher Levels:** 1d${hitDie} (or ${hitDie/2 + 1}) + your Constitution modifier per ${classname} level after 1st`,
'',
'#### Proficiencies',
'___',
`- **Armor:** ${_.sampleSize(['Light armor', 'Medium armor', 'Heavy armor', 'Shields'], _.random(0, 3)).join(', ') || 'None'}`,
`- **Weapons:** ${_.sampleSize(['Squeegee', 'Rubber Chicken', 'Simple weapons', 'Martial weapons'], _.random(0, 2)).join(', ') || 'None'}`,
`- **Tools:** ${_.sampleSize(['Artian\'s tools', 'one musical instrument', 'Thieve\'s tools'], _.random(0, 2)).join(', ') || 'None'}`,
'',
'___',
`- **Saving Throws:** ${_.sampleSize(abilityList, 2).join(', ')}`,
`- **Skills:** Choose two from ${_.sampleSize(skillList, _.random(4, 6)).join(', ')}`,
'',
'#### Equipment',
'You start with the following equipment, in addition to the equipment granted by your background:',
'- *(a)* a martial weapon and a shield or *(b)* two martial weapons',
'- *(a)* five javelins or *(b)* any simple melee weapon',
`- ${_.sample(['10 lint fluffs', '1 button', 'a cherished lost sock'])}`,
'\n\n\n'
].join('\n');
};

View File

@@ -0,0 +1,114 @@
const _ = require('lodash');
const features = [
'Astrological Botany',
'Astrological Chemistry',
'Biochemical Sorcery',
'Civil Alchemy',
'Consecrated Biochemistry',
'Demonic Anthropology',
'Divinatory Mineralogy',
'Genetic Banishing',
'Hermetic Geography',
'Immunological Incantations',
'Nuclear Illusionism',
'Ritual Astronomy',
'Seismological Divination',
'Spiritual Biochemistry',
'Statistical Occultism',
'Police Necromancer',
'Sixgun Poisoner',
'Pharmaceutical Gunslinger',
'Infernal Banker',
'Spell Analyst',
'Gunslinger Corruptor',
'Torque Interfacer',
'Exo Interfacer',
'Gunpowder Torturer',
'Orbital Gravedigger',
'Phased Linguist',
'Mathematical Pharmacist',
'Plasma Outlaw',
'Malefic Chemist',
'Police Cultist'
];
const classnames = ['Archivist', 'Fancyman', 'Linguist', 'Fletcher',
'Notary', 'Berserker-Typist', 'Fishmongerer', 'Manicurist', 'Haberdasher', 'Concierge'];
const levels = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th'];
const profBonus = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6];
const getFeature = (level)=>{
let res = [];
if(_.includes([4, 6, 8, 12, 14, 16, 19], level+1)){
res = ['Ability Score Improvement'];
}
res = _.union(res, _.sampleSize(features, _.sample([0, 1, 1, 1, 1, 1])));
if(!res.length) return '─';
return res.join(', ');
};
module.exports = {
full : function(){
const classname = _.sample(classnames);
const maxes = [4, 3, 3, 3, 3, 2, 2, 1, 1];
const drawSlots = function(Slots){
let slots = Number(Slots);
return _.times(9, function(i){
const max = maxes[i];
if(slots < 1) return '—';
const res = _.min([max, slots]);
slots -= res;
return res;
}).join(' | ');
};
let cantrips = 3;
let spells = 1;
let slots = 2;
return `<div class='classTable wide'>\n##### The ${classname}\n` +
`| Level | Proficiency Bonus | Features | Cantrips Known | Spells Known | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |\n`+
`|:---:|:---:|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n${
_.map(levels, function(levelName, level){
const res = [
levelName,
`+${profBonus[level]}`,
getFeature(level),
cantrips,
spells,
drawSlots(slots)
].join(' | ');
cantrips += _.random(0, 1);
spells += _.random(0, 1);
slots += _.random(0, 2);
return `| ${res} |`;
}).join('\n')}\n</div>\n\n`;
},
half : function(){
const classname = _.sample(classnames);
let featureScore = 1;
return `<div class='classTable'>\n##### The ${classname}\n` +
`| Level | Proficiency Bonus | Features | ${_.sample(features)}|\n` +
`|:---:|:---:|:---|:---:|\n${
_.map(levels, function(levelName, level){
const res = [
levelName,
`+${profBonus[level]}`,
getFeature(level),
`+${featureScore}`
].join(' | ');
featureScore += _.random(0, 1);
return `| ${res} |`;
}).join('\n')}\n</div>\n\n`;
}
};

View File

@@ -0,0 +1,117 @@
const _ = require('lodash');
const titles = [
'The Burning Gallows',
'The Ring of Nenlast',
'Below the Blind Tavern',
'Below the Hungering River',
'Before Bahamut\'s Land',
'The Cruel Grave from Within',
'The Strength of Trade Road',
'Through The Raven Queen\'s Worlds',
'Within the Settlement',
'The Crown from Within',
'The Merchant Within the Battlefield',
'Ioun\'s Fading Traveler',
'The Legion Ingredient',
'The Explorer Lure',
'Before the Charming Badlands',
'The Living Dead Above the Fearful Cage',
'Vecna\'s Hidden Sage',
'Bahamut\'s Demonspawn',
'Across Gruumsh\'s Elemental Chaos',
'The Blade of Orcus',
'Beyond Revenge',
'Brain of Insanity',
'Breed Battle!, A New Beginning',
'Evil Lake, A New Beginning',
'Invasion of the Gigantic Cat, Part II',
'Kraken War 2020',
'The Body Whisperers',
'The Diabolical Tales of the Ape-Women',
'The Doctor Immortal',
'The Doctor from Heaven',
'The Graveyard',
'Azure Core',
'Core Battle',
'Core of Heaven: The Guardian of Amazement',
'Deadly Amazement III',
'Dry Chaos IX',
'Gate Thunder',
'Guardian: Skies of the Dark Wizard',
'Lute of Eternity',
'Mercury\'s Planet: Brave Evolution',
'Ruby of Atlantis: The Quake of Peace',
'Sky of Zelda: The Thunder of Force',
'Vyse\'s Skies',
'White Greatness III',
'Yellow Divinity',
'Zidane\'s Ghost'
];
const subtitles = [
'In an ominous universe, a botanist opposes terrorism.',
'In a demon-haunted city, in an age of lies and hate, a physicist tries to find an ancient treasure and battles a mob of aliens.',
'In a land of corruption, two cyberneticists and a dungeon delver search for freedom.',
'In an evil empire of horror, two rangers battle the forces of hell.',
'In a lost city, in an age of sorcery, a librarian quests for revenge.',
'In a universe of illusions and danger, three time travellers and an adventurer search for justice.',
'In a forgotten universe of barbarism, in an era of terror and mysticism, a virtual reality programmer and a spy try to find vengance and battle crime.',
'In a universe of demons, in an era of insanity and ghosts, three bodyguards and a bodyguard try to find vengance.',
'In a kingdom of corruption and battle, seven artificial intelligences try to save the last living fertile woman.',
'In a universe of virutal reality and agony, in an age of ghosts and ghosts, a fortune-teller and a wanderer try to avert the apocalypse.',
'In a crime-infested kingdom, three martial artists quest for the truth and oppose evil.',
'In a terrifying universe of lost souls, in an era of lost souls, eight dancers fight evil.',
'In a galaxy of confusion and insanity, three martial artists and a duke battle a mob of psychics.',
'In an amazing kingdom, a wizard and a secretary hope to prevent the destruction of mankind.',
'In a kingdom of deception, a reporter searches for fame.',
'In a hellish empire, a swordswoman and a duke try to find the ultimate weapon and battle a conspiracy.',
'In an evil galaxy of illusion, in a time of technology and misery, seven psychiatrists battle crime.',
'In a dark city of confusion, three swordswomen and a singer battle lawlessness.',
'In an ominous empire, in an age of hate, two philosophers and a student try to find justice and battle a mob of mages intent on stealing the souls of the innocent.',
'In a kingdom of panic, six adventurers oppose lawlessness.',
'In a land of dreams and hopelessness, three hackers and a cyborg search for justice.',
'On a planet of mysticism, three travelers and a fire fighter quest for the ultimate weapon and oppose evil.',
'In a wicked universe, five seers fight lawlessness.',
'In a kingdom of death, in an era of illusion and blood, four colonists search for fame.',
'In an amazing kingdom, in an age of sorcery and lost souls, eight space pirates quest for freedom.',
'In a cursed empire, five inventors oppose terrorism.',
'On a crime-ridden planet of conspiracy, a watchman and an artificial intelligence try to find love and oppose lawlessness.',
'In a forgotten land, a reporter and a spy try to stop the apocalypse.',
'In a forbidden land of prophecy, a scientist and an archivist oppose a cabal of barbarians intent on stealing the souls of the innocent.',
'On an infernal world of illusion, a grave robber and a watchman try to find revenge and combat a syndicate of mages intent on stealing the source of all magic.',
'In a galaxy of dark magic, four fighters seek freedom.',
'In an empire of deception, six tomb-robbers quest for the ultimate weapon and combat an army of raiders.',
'In a kingdom of corruption and lost souls, in an age of panic, eight planetologists oppose evil.',
'In a galaxy of misery and hopelessness, in a time of agony and pain, five planetologists search for vengance.',
'In a universe of technology and insanity, in a time of sorcery, a computer techician quests for hope.',
'On a planet of dark magic and barbarism, in an age of horror and blasphemy, seven librarians search for fame.',
'In an empire of dark magic, in a time of blood and illusions, four monks try to find the ultimate weapon and combat terrorism.',
'In a forgotten empire of dark magic, six kings try to prevent the destruction of mankind.',
'In a galaxy of dark magic and horror, in an age of hopelessness, four marines and an outlaw combat evil.',
'In a mysterious city of illusion, in an age of computerization, a witch-hunter tries to find the ultimate weapon and opposes an evil corporation.',
'In a damned kingdom of technology, a virtual reality programmer and a fighter seek fame.',
'In a hellish kingdom, in an age of blasphemy and blasphemy, an astrologer searches for fame.',
'In a damned world of devils, an alien and a ranger quest for love and oppose a syndicate of demons.',
'In a cursed galaxy, in a time of pain, seven librarians hope to avert the apocalypse.',
'In a crime-infested galaxy, in an era of hopelessness and panic, three champions and a grave robber try to solve the ultimate crime.'
];
module.exports = ()=>{
return `<style>
.phb#p1{ text-align:center; }
.phb#p1:after{ display:none; }
</style>
<div style='margin-top:450px;'></div>
# ${_.sample(titles)}
<div style='margin-top:25px'></div>
<div class='wide'>
##### ${_.sample(subtitles)}
</div>
\\page`;
};

View File

@@ -0,0 +1,43 @@
const _ = require('lodash');
const ClassFeatureGen = require('./classfeature.gen.js');
const ClassTableGen = require('./classtable.gen.js');
module.exports = function(){
const classname = _.sample(['Archivist', 'Fancyman', 'Linguist', 'Fletcher',
'Notary', 'Berserker-Typist', 'Fishmongerer', 'Manicurist', 'Haberdasher', 'Concierge']);
const image = _.sample(_.map([
'http://orig01.deviantart.net/4682/f/2007/099/f/c/bard_stick_figure_by_wrpigeek.png',
'http://img07.deviantart.net/a3c9/i/2007/099/3/a/archer_stick_figure_by_wrpigeek.png',
'http://pre04.deviantart.net/d596/th/pre/f/2007/099/5/2/adventurer_stick_figure_by_wrpigeek.png',
'http://img13.deviantart.net/d501/i/2007/099/d/4/black_mage_stick_figure_by_wrpigeek.png',
'http://img09.deviantart.net/5cf3/i/2007/099/d/d/dark_knight_stick_figure_by_wrpigeek.png',
'http://pre01.deviantart.net/7a34/th/pre/f/2007/099/6/3/monk_stick_figure_by_wrpigeek.png',
'http://img11.deviantart.net/5dcc/i/2007/099/d/1/mystic_knight_stick_figure_by_wrpigeek.png',
'http://pre08.deviantart.net/ad45/th/pre/f/2007/099/a/0/thief_stick_figure_by_wrpigeek.png',
], function(url){
return `<img src = '${url}' style='max-width:8cm;max-height:25cm' />`;
}));
return `${[
image,
'',
'```',
'```',
'<div style=\'margin-top:240px\'></div>\n\n',
`## ${classname}`,
'Cool intro stuff will go here',
'\\page',
ClassTableGen(classname),
ClassFeatureGen(classname),
].join('\n')}\n\n\n`;
};

View File

@@ -0,0 +1,91 @@
const _ = require('lodash');
const spellNames = [
'Astral Rite of Acne',
'Create Acne',
'Cursed Ramen Erruption',
'Dark Chant of the Dentists',
'Erruption of Immaturity',
'Flaming Disc of Inconvenience',
'Heal Bad Hygene',
'Heavenly Transfiguration of the Cream Devil',
'Hellish Cage of Mucus',
'Irritate Peanut Butter Fairy',
'Luminous Erruption of Tea',
'Mystic Spell of the Poser',
'Sorcerous Enchantment of the Chimneysweep',
'Steak Sauce Ray',
'Talk to Groupie',
'Astonishing Chant of Chocolate',
'Astounding Pasta Puddle',
'Ball of Annoyance',
'Cage of Yarn',
'Control Noodles Elemental',
'Create Nervousness',
'Cure Baldness',
'Cursed Ritual of Bad Hair',
'Dispell Piles in Dentist',
'Eliminate Florists',
'Illusionary Transfiguration of the Babysitter',
'Necromantic Armor of Salad Dressing',
'Occult Transfiguration of Foot Fetish',
'Protection from Mucus Giant',
'Tinsel Blast',
'Alchemical Evocation of the Goths',
'Call Fangirl',
'Divine Spell of Crossdressing',
'Dominate Ramen Giant',
'Eliminate Vindictiveness in Gym Teacher',
'Extra-Planar Spell of Irritation',
'Induce Whining in Babysitter',
'Invoke Complaining',
'Magical Enchantment of Arrogance',
'Occult Globe of Salad Dressing',
'Overwhelming Enchantment of the Chocolate Fairy',
'Sorcerous Dandruff Globe',
'Spiritual Invocation of the Costumers',
'Ultimate Rite of the Confetti Angel',
'Ultimate Ritual of Mouthwash',
];
module.exports = {
spellList : function(){
const levels = ['Cantrips (0 Level)', '2nd Level', '3rd Level', '4th Level', '5th Level', '6th Level', '7th Level', '8th Level', '9th Level'];
const content = _.map(levels, (level)=>{
const spells = _.map(_.sampleSize(spellNames, _.random(5, 15)), (spell)=>{
return `- ${spell}`;
}).join('\n');
return `##### ${level} \n${spells} \n`;
}).join('\n');
return `<div class='spellList'>\n${content}\n</div>`;
},
spell : function(){
const level = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th'];
const spellSchools = ['abjuration', 'conjuration', 'divination', 'enchantment', 'evocation', 'illusion', 'necromancy', 'transmutation'];
let components = _.sampleSize(['V', 'S', 'M'], _.random(1, 3)).join(', ');
if(components.indexOf('M') !== -1){
components += ` (${_.sampleSize(['a small doll', 'a crushed button worth at least 1cp', 'discarded gum wrapper'], _.random(1, 3)).join(', ')})`;
}
return [
`#### ${_.sample(spellNames)}`,
`*${_.sample(level)}-level ${_.sample(spellSchools)}*`,
'___',
'- **Casting Time:** 1 action',
`- **Range:** ${_.sample(['Self', 'Touch', '30 feet', '60 feet'])}`,
`- **Components:** ${components}`,
`- **Duration:** ${_.sample(['Until dispelled', '1 round', 'Instantaneous', 'Concentration, up to 10 minutes', '1 hour'])}`,
'',
'A flame, equivalent in brightness to a torch, springs from from an object that you touch. ',
'The effect look like a regular flame, but it creates no heat and doesn\'t use oxygen. ',
'A *continual flame* can be covered or hidden but not smothered or quenched.',
'\n\n\n'
].join('\n');
}
};

View File

@@ -0,0 +1,196 @@
const _ = require('lodash');
const genList = function(list, max){
return _.sampleSize(list, _.random(0, max)).join(', ') || 'None';
};
const getMonsterName = function(){
return _.sample([
'All-devouring Baseball Imp',
'All-devouring Gumdrop Wraith',
'Chocolate Hydra',
'Devouring Peacock',
'Economy-sized Colossus of the Lemonade Stand',
'Ghost Pigeon',
'Gibbering Duck',
'Sparklemuffin Peacock Spider',
'Gum Elemental',
'Illiterate Construct of the Candy Store',
'Ineffable Chihuahua',
'Irritating Death Hamster',
'Irritating Gold Mouse',
'Juggernaut Snail',
'Juggernaut of the Sock Drawer',
'Koala of the Cosmos',
'Mad Koala of the West',
'Milk Djinni of the Lemonade Stand',
'Mind Ferret',
'Mystic Salt Spider',
'Necrotic Halitosis Angel',
'Pinstriped Famine Sheep',
'Ritalin Leech',
'Shocker Kangaroo',
'Stellar Tennis Juggernaut',
'Wailing Quail of the Sun',
'Angel Pigeon',
'Anime Sphinx',
'Bored Avalanche Sheep of the Wasteland',
'Devouring Nougat Sphinx of the Sock Drawer',
'Djinni of the Footlocker',
'Ectoplasmic Jazz Devil',
'Flatuent Angel',
'Gelatinous Duck of the Dream-Lands',
'Gelatinous Mouse',
'Golem of the Footlocker',
'Lich Wombat',
'Mechanical Sloth of the Past',
'Milkshake Succubus',
'Puffy Bone Peacock of the East',
'Rainbow Manatee',
'Rune Parrot',
'Sand Cow',
'Sinister Vanilla Dragon',
'Snail of the North',
'Spider of the Sewer',
'Stellar Sawdust Leech',
'Storm Anteater of Hell',
'Stupid Spirit of the Brewery',
'Time Kangaroo',
'Tomb Poodle',
]);
};
const getType = function(){
return `${_.sample(['Tiny', 'Small', 'Medium', 'Large', 'Gargantuan', 'Stupidly vast'])} ${_.sample(['beast', 'fiend', 'annoyance', 'guy', 'cutie'])}`;
};
const getAlignment = function(){
return _.sample([
'annoying evil',
'chaotic gossipy',
'chaotic sloppy',
'depressed neutral',
'lawful bogus',
'lawful coy',
'manic-depressive evil',
'narrow-minded neutral',
'neutral annoying',
'neutral ignorant',
'oedpipal neutral',
'silly neutral',
'unoriginal neutral',
'weird neutral',
'wordy evil',
'unaligned'
]);
};
const getStats = function(){
return `>|${_.times(6, function(){
const num = _.random(1, 20);
const mod = Math.ceil(num/2 - 5);
return `${num} (${mod >= 0 ? `+${mod}` : mod})`;
}).join('|')}|`;
};
const genAbilities = function(){
return _.sample([
'> ***Pack Tactics.*** These guys work together. Like super well, you don\'t even know.',
'> ***False Appearance. *** While the armor reamin motionless, it is indistinguishable from a normal suit of armor.',
]);
};
const genAction = function(){
const name = _.sample([
'Abdominal Drop',
'Airplane Hammer',
'Atomic Death Throw',
'Bulldog Rake',
'Corkscrew Strike',
'Crossed Splash',
'Crossface Suplex',
'DDT Powerbomb',
'Dual Cobra Wristlock',
'Dual Throw',
'Elbow Hold',
'Gory Body Sweep',
'Heel Jawbreaker',
'Jumping Driver',
'Open Chin Choke',
'Scorpion Flurry',
'Somersault Stump Fists',
'Suffering Wringer',
'Super Hip Submission',
'Super Spin',
'Team Elbow',
'Team Foot',
'Tilt-a-whirl Chin Sleeper',
'Tilt-a-whirl Eye Takedown',
'Turnbuckle Roll'
]);
return `> ***${name}.*** *Melee Weapon Attack:* +4 to hit, reach 5ft., one target. *Hit* 5 (1d6 + 2) `;
};
module.exports = {
full : function(){
return `${[
'___',
'___',
`> ## ${getMonsterName()}`,
`>*${getType()}, ${getAlignment()}*`,
'> ___',
`> - **Armor Class** ${_.random(10, 20)}`,
`> - **Hit Points** ${_.random(1, 150)}(1d4 + 5)`,
`> - **Speed** ${_.random(0, 50)}ft.`,
'>___',
'>|STR|DEX|CON|INT|WIS|CHA|',
'>|:---:|:---:|:---:|:---:|:---:|:---:|',
getStats(),
'>___',
`> - **Condition Immunities** ${genList(['groggy', 'swagged', 'weak-kneed', 'buzzed', 'groovy', 'melancholy', 'drunk'], 3)}`,
`> - **Senses** passive Perception ${_.random(3, 20)}`,
`> - **Languages** ${genList(['Common', 'Pottymouth', 'Gibberish', 'Latin', 'Jive'], 2)}`,
`> - **Challenge** ${_.random(0, 15)} (${_.random(10, 10000)} XP)`,
'> ___',
_.times(_.random(3, 6), function(){
return genAbilities();
}).join('\n>\n'),
'> ### Actions',
_.times(_.random(4, 6), function(){
return genAction();
}).join('\n>\n'),
].join('\n')}\n\n\n`;
},
half : function(){
return `${[
'___',
`> ## ${getMonsterName()}`,
`>*${getType()}, ${getAlignment()}*`,
'> ___',
`> - **Armor Class** ${_.random(10, 20)}`,
`> - **Hit Points** ${_.random(1, 150)}(1d4 + 5)`,
`> - **Speed** ${_.random(0, 50)}ft.`,
'>___',
'>|STR|DEX|CON|INT|WIS|CHA|',
'>|:---:|:---:|:---:|:---:|:---:|:---:|',
getStats(),
'>___',
`> - **Condition Immunities** ${genList(['groggy', 'swagged', 'weak-kneed', 'buzzed', 'groovy', 'melancholy', 'drunk'], 3)}`,
`> - **Senses** passive Perception ${_.random(3, 20)}`,
`> - **Languages** ${genList(['Common', 'Pottymouth', 'Gibberish', 'Latin', 'Jive'], 2)}`,
`> - **Challenge** ${_.random(0, 15)} (${_.random(10, 10000)} XP)`,
'> ___',
_.times(_.random(0, 2), function(){
return genAbilities();
}).join('\n>\n'),
'> ### Actions',
_.times(_.random(1, 2), function(){
return genAction();
}).join('\n>\n'),
].join('\n')}\n\n\n`;
}
};

View File

@@ -0,0 +1,268 @@
/* eslint-disable max-lines */
const MagicGen = require('./magic.gen.js');
const ClassTableGen = require('./classtable.gen.js');
const MonsterBlockGen = require('./monsterblock.gen.js');
const ClassFeatureGen = require('./classfeature.gen.js');
const CoverPageGen = require('./coverpage.gen.js');
const TableOfContentsGen = require('./tableOfContents.gen.js');
module.exports = [
{
groupName : 'Editor',
icon : 'fa-pencil',
snippets : [
{
name : 'Column Break',
icon : 'fa-columns',
gen : '```\n```\n\n'
},
{
name : 'New Page',
icon : 'fa-file-text',
gen : '\\page\n\n'
},
{
name : 'Vertical Spacing',
icon : 'fa-arrows-v',
gen : '<div style=\'margin-top:140px\'></div>\n\n'
},
{
name : 'Wide Block',
icon : 'fa-arrows-h',
gen : '<div class=\'wide\'>\nEverything in here will be extra wide. Tables, text, everything! Beware though, CSS columns can behave a bit weird sometimes.\n</div>\n'
},
{
name : 'Image',
icon : 'fa-image',
gen : [
'<img ',
' src=\'https://s-media-cache-ak0.pinimg.com/736x/4a/81/79/4a8179462cfdf39054a418efd4cb743e.jpg\' ',
' style=\'width:325px\' />',
'Credit: Kyounghwan Kim'
].join('\n')
},
{
name : 'Background Image',
icon : 'fa-tree',
gen : [
'<img ',
' src=\'http://i.imgur.com/hMna6G0.png\' ',
' style=\'position:absolute; top:50px; right:30px; width:280px\' />'
].join('\n')
},
{
name : 'Page Number',
icon : 'fa-bookmark',
gen : '<div class=\'pageNumber\'>1</div>\n<div class=\'footnote\'>PART 1 | FANCINESS</div>\n\n'
},
{
name : 'Auto-incrementing Page Number',
icon : 'fa-sort-numeric-asc',
gen : '<div class=\'pageNumber auto\'></div>\n'
},
{
name : 'Link to page',
icon : 'fa-link',
gen : '[Click here](#p3) to go to page 3\n'
},
{
name : 'Table of Contents',
icon : 'fa-book',
gen : TableOfContentsGen
},
]
},
/************************* PHB ********************/
{
groupName : 'PHB',
icon : 'fa-book',
snippets : [
{
name : 'Spell',
icon : 'fa-magic',
gen : MagicGen.spell,
},
{
name : 'Spell List',
icon : 'fa-list',
gen : MagicGen.spellList,
},
{
name : 'Class Feature',
icon : 'fa-trophy',
gen : ClassFeatureGen,
},
{
name : 'Note',
icon : 'fa-sticky-note',
gen : function(){
return [
'> ##### Time to Drop Knowledge',
'> Use notes to point out some interesting information. ',
'> ',
'> **Tables and lists** both work within a note.'
].join('\n');
},
},
{
name : 'Descriptive Text Box',
icon : 'fa-sticky-note-o',
gen : function(){
return [
'<div class=\'descriptive\'>',
'##### Time to Drop Knowledge',
'Use notes to point out some interesting information. ',
'',
'**Tables and lists** both work within a note.',
'</div>'
].join('\n');
},
},
{
name : 'Monster Stat Block',
icon : 'fa-bug',
gen : MonsterBlockGen.half,
},
{
name : 'Wide Monster Stat Block',
icon : 'fa-paw',
gen : MonsterBlockGen.full,
},
{
name : 'Cover Page',
icon : 'fa-file-word-o',
gen : CoverPageGen,
},
]
},
/********************* TABLES *********************/
{
groupName : 'Tables',
icon : 'fa-table',
snippets : [
{
name : 'Class Table',
icon : 'fa-table',
gen : ClassTableGen.full,
},
{
name : 'Half Class Table',
icon : 'fa-list-alt',
gen : ClassTableGen.half,
},
{
name : 'Table',
icon : 'fa-th-list',
gen : function(){
return [
'##### Cookie Tastiness',
'| Tastiness | Cookie Type |',
'|:----:|:-------------|',
'| -5 | Raisin |',
'| 8th | Chocolate Chip |',
'| 11th | 2 or lower |',
'| 14th | 3 or lower |',
'| 17th | 4 or lower |\n\n',
].join('\n');
},
},
{
name : 'Wide Table',
icon : 'fa-list',
gen : function(){
return [
'<div class=\'wide\'>',
'##### Cookie Tastiness',
'| Tastiness | Cookie Type |',
'|:----:|:-------------|',
'| -5 | Raisin |',
'| 8th | Chocolate Chip |',
'| 11th | 2 or lower |',
'| 14th | 3 or lower |',
'| 17th | 4 or lower |',
'</div>\n\n'
].join('\n');
},
},
{
name : 'Split Table',
icon : 'fa-th-large',
gen : function(){
return [
'<div style=\'column-count:2\'>',
'| d10 | Damage Type |',
'|:---:|:------------|',
'| 1 | Acid |',
'| 2 | Cold |',
'| 3 | Fire |',
'| 4 | Force |',
'| 5 | Lightning |',
'',
'```',
'```',
'',
'| d10 | Damage Type |',
'|:---:|:------------|',
'| 6 | Necrotic |',
'| 7 | Poison |',
'| 8 | Psychic |',
'| 9 | Radiant |',
'| 10 | Thunder |',
'</div>\n\n',
].join('\n');
},
}
]
},
/**************** PRINT *************/
{
groupName : 'Print',
icon : 'fa-print',
snippets : [
{
name : 'A4 PageSize',
icon : 'fa-file-o',
gen : ['<style>',
' .phb{',
' width : 210mm;',
' height : 296.8mm;',
' }',
'</style>'
].join('\n')
},
{
name : 'Ink Friendly',
icon : 'fa-tint',
gen : ['<style>',
' .phb{ background : white;}',
' .phb img{ display : none;}',
' .phb hr+blockquote{background : white;}',
'</style>',
''
].join('\n')
},
]
},
];

View File

@@ -0,0 +1,72 @@
const _ = require('lodash');
const getTOC = (pages)=>{
const add1 = (title, page)=>{
res.push({
title : title,
page : page + 1,
children : []
});
};
const add2 = (title, page)=>{
if(!_.last(res)) add1('', page);
_.last(res).children.push({
title : title,
page : page + 1,
children : []
});
};
const add3 = (title, page)=>{
if(!_.last(res)) add1('', page);
if(!_.last(_.last(res).children)) add2('', page);
_.last(_.last(res).children).children.push({
title : title,
page : page + 1,
children : []
});
};
const res = [];
_.each(pages, (page, pageNum)=>{
const lines = page.split('\n');
_.each(lines, (line)=>{
if(_.startsWith(line, '# ')){
const title = line.replace('# ', '');
add1(title, pageNum);
}
if(_.startsWith(line, '## ')){
const title = line.replace('## ', '');
add2(title, pageNum);
}
if(_.startsWith(line, '### ')){
const title = line.replace('### ', '');
add3(title, pageNum);
}
});
});
return res;
};
module.exports = function(brew){
const pages = brew.split('\\page');
const TOC = getTOC(pages);
const markdown = _.reduce(TOC, (r, g1, idx1)=>{
r.push(`- **[${idx1 + 1} ${g1.title}](#p${g1.page})**`);
if(g1.children.length){
_.each(g1.children, (g2, idx2)=>{
r.push(` - [${idx1 + 1}.${idx2 + 1} ${g2.title}](#p${g2.page})`);
if(g2.children.length){
_.each(g2.children, (g3, idx3)=>{
r.push(` - [${idx1 + 1}.${idx2 + 1}.${idx3 + 1} ${g3.title}](#p${g3.page})`);
});
}
});
}
return r;
}, []).join('\n');
return `<div class='toc'>
##### Table Of Contents
${markdown}
</div>\n`;
};

View File

@@ -1,42 +0,0 @@
var _ = require('lodash');
module.exports = function(classname){
classname = classname || _.sample(['archivist', 'fancyman', 'linguist', 'fletcher',
'notary', 'berserker-typist', 'fishmongerer', 'manicurist', 'haberdasher', 'concierge'])
classname = classname.toLowerCase();
var hitDie = _.sample([4, 6, 8, 10, 12]);
var abilityList = ["Strength", "Dexerity", "Constitution", "Wisdom", "Charisma", "Intelligence"];
var skillList = ["Acrobatics ", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"];
return [
"## Class Features",
"As a " + classname + ", you gain the following class features",
"#### Hit Points",
"___",
"- **Hit Dice:** 1d" + hitDie + " per " + classname + " level",
"- **Hit Points at 1st Level:** " + hitDie + " + your Constituion modifier",
"- **Hit Points at Higher Levels:** 1d" + hitDie + " (or " + (hitDie/2 + 1) + ") + your Constituion modifier per " + classname + " level after 1st",
"",
"#### Proficiencies",
"___",
"- **Armor:** " + (_.sample(["Light armor", "Medium armor", "Heavy armor", "Shields"], _.random(0,3)).join(', ') || "None"),
"- **Weapons:** " + (_.sample(["Squeegee", "Rubber Chicken", "Simple weapons", "Martial weapons"], _.random(0,2)).join(', ') || "None"),
"- **Tools:** " + (_.sample(["Artian's tools", "one musical instrument", "Thieve's tools"], _.random(0,2)).join(', ') || "None"),
"",
"___",
"- **Saving Throws:** " + (_.sample(abilityList, 2).join(', ')),
"- **Skills:** Choose two from " + (_.sample(skillList, _.random(4, 6)).join(', ')),
"",
"#### Equipment",
"You start with the following equipment, in addition to the equipment granted by your background:",
"- *(a)* a martial weapon and a shield or *(b)* two martial weapons",
"- *(a)* five javelins or *(b)* any simple melee weapon",
"- " + (_.sample(["10 lint fluffs", "1 button", "a cherished lost sock"])),
"\n\n\n"
].join('\n');
}

View File

@@ -1,79 +0,0 @@
var _ = require('lodash');
module.exports = function(classname){
classname = classname || _.sample(['Archivist', 'Fancyman', 'Linguist', 'Fletcher',
'Notary', 'Berserker-Typist', 'Fishmongerer', 'Manicurist', 'Haberdasher', 'Concierge'])
var features = [
"Astrological Botany",
"Astrological Chemistry",
"Biochemical Sorcery",
"Civil Alchemy",
"Consecrated Biochemistry",
"Demonic Anthropology",
"Divinatory Mineralogy",
"Genetic Banishing",
"Hermetic Geography",
"Immunological Incantations",
"Nuclear Illusionism",
"Ritual Astronomy",
"Seismological Divination",
"Spiritual Biochemistry",
"Statistical Occultism",
"Police Necromancer",
"Sixgun Poisoner",
"Pharmaceutical Gunslinger",
"Infernal Banker",
"Spell Analyst",
"Gunslinger Corruptor",
"Torque Interfacer",
"Exo Interfacer",
"Gunpowder Torturer",
"Orbital Gravedigger",
"Phased Linguist",
"Mathematical Pharmacist",
"Plasma Outlaw",
"Malefic Chemist",
"Police Cultist"
];
var maxes = [4,3,3,3,3,2,2,1,1]
var drawSlots = function(Slots){
var slots = Number(Slots);
return _.times(9, function(i){
var max = maxes[i];
if(slots < 1) return "—";
var res = _.min([max, slots]);
slots -= res;
return res;
}).join(' | ')
}
var extraWide = (_.random(0,1) === 0) ? "" : "___\n";
var cantrips = 3;
var spells = 1;
var slots = 2;
return "##### The " + classname + "\n" +
"___\n" + extraWide +
"| Level | Proficiency Bonus | Features | Cantrips Known | Spells Known | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |\n"+
"|:---:|:---:|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n" +
_.map(["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th"],function(levelName, level){
var res = [
levelName,
"+" + Math.ceil(level/5 + 1),
_.sample(features, _.sample([0,1,1])).join(', ') || "Ability Score Improvement",
cantrips,
spells,
drawSlots(slots)
].join(' | ');
cantrips += _.random(0,1);
spells += _.random(0,1);
slots += _.random(0,2);
return "| " + res + " |";
}).join('\n') +'\n\n';
};

View File

@@ -1,43 +0,0 @@
var _ = require('lodash');
var ClassFeatureGen = require('./classfeature.gen.js');
var ClassTableGen = require('./classtable.gen.js');
module.exports = function(){
var classname = _.sample(['Archivist', 'Fancyman', 'Linguist', 'Fletcher',
'Notary', 'Berserker-Typist', 'Fishmongerer', 'Manicurist', 'Haberdasher', 'Concierge'])
var image = _.sample(_.map([
"http://orig01.deviantart.net/4682/f/2007/099/f/c/bard_stick_figure_by_wrpigeek.png",
"http://img07.deviantart.net/a3c9/i/2007/099/3/a/archer_stick_figure_by_wrpigeek.png",
"http://pre04.deviantart.net/d596/th/pre/f/2007/099/5/2/adventurer_stick_figure_by_wrpigeek.png",
"http://img13.deviantart.net/d501/i/2007/099/d/4/black_mage_stick_figure_by_wrpigeek.png",
"http://img09.deviantart.net/5cf3/i/2007/099/d/d/dark_knight_stick_figure_by_wrpigeek.png",
"http://pre01.deviantart.net/7a34/th/pre/f/2007/099/6/3/monk_stick_figure_by_wrpigeek.png",
"http://img11.deviantart.net/5dcc/i/2007/099/d/1/mystic_knight_stick_figure_by_wrpigeek.png",
"http://pre08.deviantart.net/ad45/th/pre/f/2007/099/a/0/thief_stick_figure_by_wrpigeek.png",
], function(url){
return "<img src = '" + url + "' style='max-width:8cm;max-height:25cm' />"
}))
return [
image,
"",
"```",
"```",
"<div style='margin-top:240px'></div>\n\n",
"## " + classname,
"Cool intro stuff will go here",
"\\page",
ClassTableGen(classname),
ClassFeatureGen(classname),
].join('\n') + '\n\n\n';
};

View File

@@ -1,168 +0,0 @@
var _ = require('lodash');
var genList = function(list, max){
return _.sample(list, _.random(0,max)).join(', ') || "None";
}
module.exports = function(){
var monsterName = _.sample([
"All-devouring Baseball Imp",
"All-devouring Gumdrop Wraith",
"Chocolate Hydra",
"Devouring Peacock",
"Economy-sized Colossus of the Lemonade Stand",
"Ghost Pigeon",
"Gibbering Duck",
"Sparklemuffin Peacock Spider",
"Gum Elemental",
"Illiterate Construct of the Candy Store",
"Ineffable Chihuahua",
"Irritating Death Hamster",
"Irritating Gold Mouse",
"Juggernaut Snail",
"Juggernaut of the Sock Drawer",
"Koala of the Cosmos",
"Mad Koala of the West",
"Milk Djinni of the Lemonade Stand",
"Mind Ferret",
"Mystic Salt Spider",
"Necrotic Halitosis Angel",
"Pinstriped Famine Sheep",
"Ritalin Leech",
"Shocker Kangaroo",
"Stellar Tennis Juggernaut",
"Wailing Quail of the Sun",
"Angel Pigeon",
"Anime Sphinx",
"Bored Avalanche Sheep of the Wasteland",
"Devouring Nougat Sphinx of the Sock Drawer",
"Djinni of the Footlocker",
"Ectoplasmic Jazz Devil",
"Flatuent Angel",
"Gelatinous Duck of the Dream-Lands",
"Gelatinous Mouse",
"Golem of the Footlocker",
"Lich Wombat",
"Mechanical Sloth of the Past",
"Milkshake Succubus",
"Puffy Bone Peacock of the East",
"Rainbow Manatee",
"Rune Parrot",
"Sand Cow",
"Sinister Vanilla Dragon",
"Snail of the North",
"Spider of the Sewer",
"Stellar Sawdust Leech",
"Storm Anteater of Hell",
"Stupid Spirit of the Brewery",
"Time Kangaroo",
"Tomb Poodle",
]);
var type = _.sample(['Tiny', 'Small', 'Medium', 'Large', 'Gargantuan', 'Stupidly vast']) + " " + _.sample(['beast', 'fiend', 'annoyance', 'guy', 'cutie'])
var alignment =_.sample([
"annoying evil",
"chaotic gossipy",
"chaotic sloppy",
"depressed neutral",
"lawful bogus",
"lawful coy",
"manic-depressive evil",
"narrow-minded neutral",
"neutral annoying",
"neutral ignorant",
"oedpipal neutral",
"silly neutral",
"unoriginal neutral",
"weird neutral",
"wordy evil",
"unaligned"
]);
var stats = '>|' + _.times(6, function(){
var num = _.random(1,20);
var mod = Math.ceil(num/2 - 5)
return num + " (" + (mod >= 0 ? '+'+mod : mod ) + ")"
}).join('|') + '|';
var genAbilities = function(){
return _.sample([
"> ***Pack Tactics.*** These guys work together. Like super well, you don't even know.",
"> ***False Appearance. *** While the armor reamin motionless, it is indistinguishable from a normal suit of armor.",
]);
}
var genAction = function(){
var name = _.sample([
"Abdominal Drop",
"Airplane Hammer",
"Atomic Death Throw",
"Bulldog Rake",
"Corkscrew Strike",
"Crossed Splash",
"Crossface Suplex",
"DDT Powerbomb",
"Dual Cobra Wristlock",
"Dual Throw",
"Elbow Hold",
"Gory Body Sweep",
"Heel Jawbreaker",
"Jumping Driver",
"Open Chin Choke",
"Scorpion Flurry",
"Somersault Stump Fists",
"Suffering Wringer",
"Super Hip Submission",
"Super Spin",
"Team Elbow",
"Team Foot",
"Tilt-a-whirl Chin Sleeper",
"Tilt-a-whirl Eye Takedown",
"Turnbuckle Roll"
])
return "> ***" + name + ".*** *Melee Weapon Attack:* +4 to hit, reach 5ft., one target. *Hit* 5 (1d6 + 2) ";
}
return [
"___",
"> ## " + monsterName,
">*" + type + ", " + alignment+ "*",
"> ___",
"> - **Armor Class** " + _.random(10,20),
"> - **Hit Points** " + _.random(1, 150) + "(1d4 + 5)",
"> - **Speed** " + _.random(0,50) + "ft.",
">___",
">|STR|DEX|CON|INT|WIS|CHA|",
">|:---:|:---:|:---:|:---:|:---:|:---:|",
stats,
">___",
"> - **Condition Immunities** " + genList(["groggy", "swagged", "weak-kneed", "buzzed", "groovy", "melancholy", "drunk"], 3),
"> - **Senses** passive Perception " + _.random(3, 20),
"> - **Languages** " + genList(["Common", "Pottymouth", "Gibberish", "Latin", "Jive"], 2),
"> - **Challenge** " + _.random(0, 15) + " (" + _.random(10,10000)+ " XP)",
"> ___",
_.times(_.random(0,2), function(){
return genAbilities()
}).join('\n>\n'),
"> ### Actions",
_.times(_.random(1,2), function(){
return genAction()
}).join('\n>\n'),
].join('\n') + '\n\n\n';
}
/*
*/
/*
*/

View File

@@ -1,109 +0,0 @@
var SpellGen = require('./spell.gen.js');
var ClassTableGen = require('./classtable.gen.js');
var MonsterBlockGen = require('./monsterblock.gen.js');
var ClassFeatureGen = require('./classfeature.gen.js');
var FullClassGen = require('./fullclass.gen.js');
module.exports = [
/*
{
tooltip : 'Full Class',
icon : 'fa-user',
snippet : FullClassGen,
},
*/
{
tooltip : 'Spell',
icon : 'fa-magic',
snippet : SpellGen,
},
{
tooltip : 'Class Feature',
icon : 'fa-trophy',
snippet : ClassFeatureGen,
},
{
tooltip : 'Note',
icon : 'fa-sticky-note',
snippet : function(){
return [
"> ##### Time to Drop Knowledge",
"> Use notes to point out some interesting information. ",
"> ",
"> **Tables and lists** both work within a note."
].join('\n');
},
},
{
tooltip : 'Table',
icon : 'fa-list',
snippet : function(){
return [
"##### Cookie Tastiness",
"| Tastiness | Cookie Type |",
"|:----:|:-------------|",
"| -5 | Raisin |",
"| 8th | Chocolate Chip |",
"| 11th | 2 or lower |",
"| 14th | 3 or lower |",
"| 17th | 4 or lower |\n\n",
].join('\n');
},
},
{
tooltip : 'Monster Stat Block',
icon : 'fa-bug',
snippet : MonsterBlockGen,
},
{
tooltip : "Class Table",
icon : 'fa-table',
snippet : ClassTableGen,
},
{
tooltip : "Column Break",
icon : 'fa-columns',
snippet : function(){
return "```\n```\n\n";
}
},
{
tooltip : "New Page",
icon : 'fa-file-text',
snippet : function(){
return "\\page\n\n";
}
},
{
tooltip : "Vertical Spacing",
icon : 'fa-arrows-v',
snippet : function(){
return "<div style='margin-top:140px'></div>\n\n";
}
},
{
tooltip : "Insert Image",
icon : 'fa-image',
snippet : function(){
return "<img src='https://i.imgur.com/RJ6S6eY.gif' style='position:absolute;bottom:-10px;right:-60px;' />";
}
},
{
tooltip : "Page number & Footnote",
icon : 'fa-book',
snippet : function(){
return "<div class='pageNumber'>1</div>\n<div class='footnote'>PART 1 | FANCINESS</div>\n\n";
}
},
{
tooltip : "Ink Friendly",
icon : 'fa-print',
snippet : function(){
return "<style>\n .phb{ background : white;}\n .phb img{ display : none;}\n .phb hr+blockquote{background : white;}\n</style>\n\n";
}
},
]

View File

@@ -1,78 +0,0 @@
var _ = require('lodash');
module.exports = function(){
var spellNames = [
"Astral Rite of Acne",
"Create Acne",
"Cursed Ramen Erruption",
"Dark Chant of the Dentists",
"Erruption of Immaturity",
"Flaming Disc of Inconvenience",
"Heal Bad Hygene",
"Heavenly Transfiguration of the Cream Devil",
"Hellish Cage of Mucus",
"Irritate Peanut Butter Fairy",
"Luminous Erruption of Tea",
"Mystic Spell of the Poser",
"Sorcerous Enchantment of the Chimneysweep",
"Steak Sauce Ray",
"Talk to Groupie",
"Astonishing Chant of Chocolate",
"Astounding Pasta Puddle",
"Ball of Annoyance",
"Cage of Yarn",
"Control Noodles Elemental",
"Create Nervousness",
"Cure Baldness",
"Cursed Ritual of Bad Hair",
"Dispell Piles in Dentist",
"Eliminate Florists",
"Illusionary Transfiguration of the Babysitter",
"Necromantic Armor of Salad Dressing",
"Occult Transfiguration of Foot Fetish",
"Protection from Mucus Giant",
"Tinsel Blast",
"Alchemical Evocation of the Goths",
"Call Fangirl",
"Divine Spell of Crossdressing",
"Dominate Ramen Giant",
"Eliminate Vindictiveness in Gym Teacher",
"Extra-Planar Spell of Irritation",
"Induce Whining in Babysitter",
"Invoke Complaining",
"Magical Enchantment of Arrogance",
"Occult Globe of Salad Dressing",
"Overwhelming Enchantment of the Chocolate Fairy",
"Sorcerous Dandruff Globe",
"Spiritual Invocation of the Costumers",
"Ultimate Rite of the Confetti Angel",
"Ultimate Ritual of Mouthwash",
];
var level = ["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th"];
var spellSchools = ["abjuration", "conjuration", "divination", "enchantment", "evocation", "illusion", "necromancy", "transmutation"];
var components = _.sample(["V", "S", "M"], _.random(1,3)).join(', ');
if(components.indexOf("M") !== -1){
components += " (" + _.sample(['a small doll', 'a crushed button worth at least 1cp', 'discarded gum wrapper'], _.random(1,3)).join(', ') + ")"
}
return [
"#### " + _.sample(spellNames),
"*" + _.sample(level) + "-level " + _.sample(spellSchools) + "*",
"___",
"- **Casting Time:** 1 action",
"- **Range:** " + _.sample(["Self", "Touch", "30 feet", "60 feet"]),
"- **Components:** " + components,
"- **Duration:** " + _.sample(["Until dispelled", "1 round", "Instantaneous", "Concentration, up to 10 minutes", "1 hour"]),
"",
"A flame, equivalent in brightness to a torch, springs from from an object that you touch. ",
"The effect look like a regular flame, but it creates no heat and doesn't use oxygen. ",
"A *continual flame* can be covered or hidden but not smothered or quenched.",
"\n\n\n"
].join('\n');
}

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,71 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Statusbar = require('../statusbar/statusbar.jsx');
var PageContainer = require('../pageContainer/pageContainer.jsx');
var Editor = require('../editor/editor.jsx');
//var WelcomeText = require('./welcomeMessage.js');
var KEY = 'naturalCrit-homebrew';
var HomePage = React.createClass({
getDefaultProps: function() {
return {
welcomeText : ""
};
},
getInitialState: function() {
return {
text: this.props.welcomeText
};
},
componentDidMount: function() {
/*
var storage = localStorage.getItem(KEY);
if(storage){
this.setState({
text : storage
})
}
*/
},
handleTextChange : function(text){
this.setState({
text : text
});
//localStorage.setItem(KEY, text);
},
render : function(){
return(
<div className='homePage'>
<Statusbar
printId="Nkbh52nx_l"
/>
<div className='paneSplit'>
<div className='leftPane'>
<Editor text={this.state.text} onChange={this.handleTextChange} />
</div>
<div className='rightPane'>
<PageContainer text={this.state.text} />
</div>
</div>
<a href='/homebrew/new' className='floatingNewButton'>
Create your own <i className='fa fa-magic' />
</a>
</div>
);
}
});
module.exports = HomePage;

View File

@@ -1,21 +0,0 @@
.homePage{
position : relative;
a.floatingNewButton{
.animate(background-color);
position : absolute;
display : block;
right : 70px;
bottom : 70px;
z-index : 100;
padding : 1em;
background-color : @orange;
font-size : 1.5em;
color : white;
text-decoration : none;
box-shadow : 3px 3px 15px black;
&:hover{
background-color : darken(@orange, 20%);
}
}
}

View File

@@ -1,120 +0,0 @@
# 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.
### Homebrew made easy
The Homebrewery allows for the creation and sharing of authentic looking Fifth-Edition homebrews, with just text editing. It accomplishes this by using [Markdown](https://help.github.com/articles/markdown-basics/) along with some custom CSS-styling.
Stop worrying about learning photoshop, fiddling with spacing, or tracking down the PHB assets. Just focus on making your homebrew **great**.
**Try it! **Simply edit the text on the left and watch it *update live* on the right.
#### Features
* Monster Stat Blocks
* Full class tables
* Notes and Tables
* Images
* Vertical spacing, column breaks, and multiple pages
#### Snippets
If you aren't used the Markdown-style syntax, don't worry! I've provided several **snippets** at the top of the editor. When clicked, these will *inject* text wherever your text cursor was.
Each snippet is a common format from the Player's Handbook or is a feature of The Homebrewery. You'll never have to memorize exactly how a Monster Stat Block is suppose to be formatted.
### Editing and Sharing
When you create your own homebrew you will be given a *edit url* and a *share url*. Any changes you make will be automatically saved to the database within a few seconds. Anyone with the edit url will be able to make edits to your homebrew. So be careful about who you share it with.
Anyone with the *share url* will be able to access a read-only version of your homebrew.
> ##### Words of Caution
> ___
> * **Concurrent Editing** The Homebrewery does not support concurrent user editing. It's best one user at a time makes edits to avoid overwriting each other.
> * **Back-up your brews** I can not guarantee that I will support this project indefinitely. So if you'd like to hang on to your creation be sure to back up it up.
```
```
## New Things!
What's new in the latest update? Check out the full changelog [here](https://github.com/stolksdorf/NaturalCrit/blob/master/changelog.md)
* **View Source** on the share page to see the markdown text for the brew
* **Fixed Server Issues** should increase stability of the site greatly
* **Footnotes & Page Numbers**
* **Print View** displays your brew ready for printing, saving to PDF or image.
* **Footer Accent** now switches directions each page, neat!
* **Standalone Styling** the PHB-style has been reduced to a single file
* **Reduced asset sizes** This should help with page load times
>##### PDF Exporting
>The best way to do a PDF export is to use the **print view** of a brew, print that page and save as PDF.
>
>***"But there's no columns when I do this in Chrome!"***
>
>This is a known bug in Chrome for **five years**. When saving to PDF, it doesn't respect columns. Amazingly this was just fixed [last month](https://code.google.com/p/chromium/issues/detail?id=99358), but hasn't been deployed yet.
>
>Converting to PDF *precisely* is **very** difficult. There are many services and libraries out there, but none of them have gotten it right to the level I'm happy with. Most of them use Chrome's engine which has the aforementioned bug in it.
>
>This is why I made the **print view**. It gives you a single completely standalone HTML version of your brew; Download it, export it, screenshot it, print it, *do whatever you want*.
## Bugs, Issues, Suggestions?
Have an idea of how to make The Homebrewery better? Or did you find something that wasn't quite right? Head [here](https://github.com/stolksdorf/NaturalCrit/issues/new) and let me know!.
<img src='http://i.imgur.com/hMna6G0.png' style='position:absolute;bottom:50px;right:30px;width:280px' />
<div class='pageNumber'>1</div>
<div class='footnote'>PART 1 | FANCINESS</div>
\page
# Appendix
### Not quite Markdown
Although the Homebrewery uses Markdown, to get all the styling features from the PHB, we had to get a little creative. Some base HTML elements are not used as expected and I've had to include a few new keywords.
___
* **Horizontal Rules** are generally used to *modify* existing elements into a different style. For example, a horizontal rule before a blockquote will give it the style of a Monster Stat Block instead of a note.
* **New Pages** are controlled by the author. It's impossible for the site to detect when the end of a page is reached, so indicate you'd like to start a new page, use the new page snippet to get the syntax.
* **Code Blocks** are used only to indicate column breaks. Since they don't allow for styling within them, they weren't that useful to use.
* **HTML** can be used to get *just* the right look for your homebrew. I've included some examples in the snippet icons above the editor.
### Images
Images can be included 'inline' with the text using Markdown-style images. However for background images more control is needed.
Background images should be included as HTML-style img tags. Using inline CSS you can precisely position your image where you'd like it to be. The image **snippet** provides an example of doing this.
```
```
### Legal Junk
You are free to use The Homebrewery is any way that you want, except for claiming that you made it yourself. 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 images or resources used.
### Things that don't work
There are a few things I couldn't get right
* Spell save block, with centered text and sans serif are not support. Ran out of mark-up to use
* Full page monster stat blocks
* "Spell slots per level" text above the levels on a class table.
* I built this for Chrome, so if it looks weird to you, use Chrome instead.
<div class='pageNumber'>2</div>
<div class='footnote'>PART 2 | BORING STUFF</div>

View File

@@ -1,45 +1,89 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
var CreateRouter = require('pico-router').createRouter;
const CreateRouter = require('pico-router').createRouter;
var HomePage = require('./homePage/homePage.jsx');
var EditPage = require('./editPage/editPage.jsx');
var SharePage = require('./sharePage/sharePage.jsx');
const HomePage = require('./pages/homePage/homePage.jsx');
const EditPage = require('./pages/editPage/editPage.jsx');
const UserPage = require('./pages/userPage/userPage.jsx');
const SharePage = require('./pages/sharePage/sharePage.jsx');
const NewPage = require('./pages/newPage/newPage.jsx');
const ErrorPage = require('./pages/errorPage/errorPage.jsx');
const PrintPage = require('./pages/printPage/printPage.jsx');
var Router;
var Homebrew = React.createClass({
getDefaultProps: function() {
let Router;
const Homebrew = createClass({
getDefaultProps : function() {
return {
url : "",
welcomeText : "",
brew : {
text : "",
shareId : null,
editId : null,
url : '',
welcomeText : '',
changelog : '',
version : '0.0.0',
account : null,
brew : {
title : '',
text : '',
shareId : null,
editId : null,
createdAt : null,
updatedAt : null,
}
};
},
componentWillMount: function() {
componentWillMount : function() {
global.account = this.props.account;
global.version = this.props.version;
Router = CreateRouter({
'/homebrew/edit/:id' : (args) => {
return <EditPage id={args.id} entry={this.props.brew} />
'/edit/:id' : (args)=>{
if(!this.props.brew.editId){
return <ErrorPage errorId={args.id}/>;
}
return <EditPage
id={args.id}
brew={this.props.brew} />;
},
'/homebrew/share/:id' : (args) => {
return <SharePage id={args.id} entry={this.props.brew} />
'/share/:id' : (args)=>{
if(!this.props.brew.shareId){
return <ErrorPage errorId={args.id}/>;
}
return <SharePage
id={args.id}
brew={this.props.brew} />;
},
'/homebrew*' : <HomePage welcomeText={this.props.welcomeText} />,
'/user/:username' : (args)=>{
return <UserPage
username={args.username}
brews={this.props.brews}
/>;
},
'/print/:id' : (args, query)=>{
return <PrintPage brew={this.props.brew} query={query}/>;
},
'/print' : (args, query)=>{
return <PrintPage query={query}/>;
},
'/new' : (args)=>{
return <NewPage />;
},
'/changelog' : (args)=>{
return <SharePage
brew={{ title: 'Changelog', text: this.props.changelog }} />;
},
'*' : <HomePage
welcomeText={this.props.welcomeText} />,
});
},
render : function(){
return(
<div className='homebrew'>
<Router initialUrl={this.props.url}/>
</div>
);
return <div className='homebrew'>
<Router defaultUrl={this.props.url}/>
</div>;
}
});

View File

@@ -1,42 +1,16 @@
@import 'naturalCrit/styles/reset.less';
//@import 'naturalCrit/styles/elements.less';
@import 'naturalCrit/styles/animations.less';
@import 'naturalCrit/styles/colors.less';
@import 'naturalCrit/styles/tooltip.less';
html,body, #reactContainer{
min-height: 100%;
font-family : 'Open Sans', sans-serif;
}
.homebrew{
background-color: @steel;
height : 100%;
.paneSplit{
width : 100%;
height: 100vh;
padding-top: 25px;
position: relative;
box-sizing: border-box;
.leftPane, .rightPane{
display: inline-block;
vertical-align: top;
position: relative;
height: 100%;
min-height: 100%;
}
.leftPane{
width : 40%;
}
.rightPane{
width : 60%;
height: 100%;
overflow-y: scroll;
}
}
@import 'naturalcrit/styles/core.less';
.homebrew{
height : 100%;
.page{
display : flex;
height : 100%;
background-color : @steel;
flex-direction : column;
.content{
position : relative;
height : calc(~"100% - 29px"); //Navbar height
flex : auto;
}
}
}

View File

@@ -0,0 +1,18 @@
const React = require('react');
const createClass = require('create-react-class');
const Nav = require('naturalcrit/nav/nav.jsx');
module.exports = function(props){
if(global.account){
return <Nav.item href={`/user/${global.account.username}`} color='yellow' icon='fa-user'>
{global.account.username}
</Nav.item>;
}
let url = '';
if(typeof window !== 'undefined'){
url = window.location.href;
}
return <Nav.item href={`http://naturalcrit.com/login?redirect=${url}`} color='teal' icon='fa-sign-in'>
login
</Nav.item>;
};

View File

@@ -0,0 +1,34 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Nav = require('naturalcrit/nav/nav.jsx');
const MAX_TITLE_LENGTH = 50;
const EditTitle = createClass({
getDefaultProps : function() {
return {
title : '',
onChange : function(){}
};
},
handleChange : function(e){
if(e.target.value.length > MAX_TITLE_LENGTH) return;
this.props.onChange(e.target.value);
},
render : function(){
return <Nav.item className='editTitle'>
<input placeholder='Brew Title' type='text' value={this.props.title} onChange={this.handleChange} />
<div className={cx('charCount', { 'max': this.props.title.length >= MAX_TITLE_LENGTH })}>
{this.props.title.length}/{MAX_TITLE_LENGTH}
</div>
</Nav.item>;
},
});
module.exports = EditTitle;

View 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='fa-bug'
href={`https://www.reddit.com/r/homebrewery/submit?selftext=true&title=${encodeURIComponent('[Issue] Describe Your Issue Here')}`} >
report issue
</Nav.item>;
};

View File

@@ -0,0 +1,50 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = createClass({
getInitialState : function() {
return {
//showNonChromeWarning : false,
ver : '0.0.0'
};
},
componentDidMount : function() {
//const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
this.setState({
//showNonChromeWarning : !isChrome,
ver : window.version
});
},
/*
renderChromeWarning : function(){
if(!this.state.showNonChromeWarning) return;
return <Nav.item className='warning' icon='fa-exclamation-triangle'>
Optimized for Chrome
<div className='dropdown'>
If you are experiencing rendering issues, use Chrome instead
</div>
</Nav.item>
},
*/
render : function(){
return <Nav.base>
<Nav.section>
<Nav.logo />
<Nav.item href='/' className='homebrewLogo'>
<div>The Homebrewery</div>
</Nav.item>
<Nav.item>{`v${this.state.ver}`}</Nav.item>
{/*this.renderChromeWarning()*/}
</Nav.section>
{this.props.children}
</Nav.base>;
}
});
module.exports = Navbar;

View File

@@ -0,0 +1,128 @@
@navbarHeight : 28px;
.homebrew nav{
.homebrewLogo{
.animate(color);
font-family : CodeBold;
font-size : 12px;
color : white;
div{
margin-top : 2px;
margin-bottom : -2px;
}
&:hover{
color : @blue;
}
}
.editTitle.navItem{
padding : 2px 12px;
input{
width : 250px;
margin : 0;
padding : 2px;
background-color : #444;
font-family : 'Open Sans', sans-serif;
font-size : 12px;
font-weight : 800;
color : white;
text-align : center;
border : 1px solid @blue;
outline : none;
}
.charCount{
display : inline-block;
vertical-align : bottom;
margin-left : 8px;
color : #666;
text-align : right;
&.max{
color : @red;
}
}
}
.brewTitle.navItem{
font-size : 12px;
font-weight : 800;
color : white;
text-align : center;
text-transform : initial;
}
.patreon.navItem{
i{
.animate(color);
&:hover{
color : @red;
}
}
}
.recent.navItem{
position : relative;
.dropdown{
position : absolute;
top : 28px;
left : 0px;
z-index : 10000;
width : 100%;
h4{
display : block;
box-sizing : border-box;
padding : 5px 0px;
background-color : #333;
font-size : 0.8em;
color : #bbb;
text-align : center;
border-top : 1px solid #888;
&:nth-of-type(1){ background-color: darken(@teal, 20%); }
&:nth-of-type(2){ background-color: darken(@purple, 30%); }
}
.item{
.animate(background-color);
position : relative;
display : block;
box-sizing : border-box;
padding : 13px 5px;
background-color : #333;
color : white;
text-decoration : none;
border-top : 1px solid #888;
&:hover{
background-color : @blue;
}
.title{
display : inline-block;
overflow : hidden;
width : 100%;
text-overflow : ellipsis;
white-space : nowrap;
}
.time{
position : absolute;
right : 2px;
bottom : 2px;
font-size : 0.7em;
color : #888;
}
}
}
}
.warning.navItem{
position : relative;
background-color : @orange;
color : white;
&:hover>.dropdown{
visibility : visible;
}
.dropdown{
position : absolute;
display : block;
top : 28px;
left : 0px;
visibility : hidden;
z-index : 10000;
box-sizing : border-box;
width : 100%;
padding : 13px 5px;
background-color : #333;
text-align : center;
}
}
}

View File

@@ -0,0 +1,14 @@
const React = require('react');
const createClass = require('create-react-class');
const Nav = require('naturalcrit/nav/nav.jsx');
module.exports = function(props){
return <Nav.item
className='patreon'
newTab={true}
href='https://www.patreon.com/stolksdorf'
color='green'
icon='fa-heart'>
help out
</Nav.item>;
};

View File

@@ -0,0 +1,9 @@
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} href={`/print/${props.shareId}?dialog=true`} color='purple' icon='fa-file-pdf-o'>
get PDF
</Nav.item>;
};

View File

@@ -0,0 +1,200 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Moment = require('moment');
const Nav = require('naturalcrit/nav/nav.jsx');
const VIEW_KEY = 'homebrewery-recently-viewed';
const EDIT_KEY = 'homebrewery-recently-edited';
const BaseItem = createClass({
getDefaultProps : function() {
return {
storageKey : '',
text : '',
currentBrew : {
title : '',
id : '',
url : ''
}
};
},
getInitialState : function() {
return {
showDropdown : false,
brews : []
};
},
componentDidMount : function() {
let brews = JSON.parse(localStorage.getItem(this.props.storageKey) || '[]');
brews = _.filter(brews, (brew)=>{
return brew.id !== this.props.currentBrew.id;
});
if(this.props.currentBrew.id){
brews.unshift({
id : this.props.currentBrew.id,
url : this.props.currentBrew.url,
title : this.props.currentBrew.title,
ts : Date.now()
});
}
brews = _.slice(brews, 0, 8);
localStorage.setItem(this.props.storageKey, JSON.stringify(brews));
this.setState({
brews : brews
});
},
handleDropdown : function(show){
this.setState({
showDropdown : show
});
},
renderDropdown : function(){
if(!this.state.showDropdown) return null;
const items = _.map(this.state.brews, (brew)=>{
return <a href={brew.url} className='item' key={brew.id} target='_blank' rel='noopener noreferrer'>
<span className='title'>{brew.title}</span>
<span className='time'>{Moment(brew.ts).fromNow()}</span>
</a>;
});
return <div className='dropdown'>{items}</div>;
},
render : function(){
return <Nav.item icon='fa-clock-o' color='grey' className='recent'
onMouseEnter={()=>this.handleDropdown(true)}
onMouseLeave={()=>this.handleDropdown(false)}>
{this.props.text}
{this.renderDropdown()}
</Nav.item>;
},
});
module.exports = {
viewed : createClass({
getDefaultProps : function() {
return {
brew : {
title : '',
shareId : ''
}
};
},
render : function(){
return <BaseItem text='recently viewed' storageKey={VIEW_KEY}
currentBrew={{
id : this.props.brew.shareId,
title : this.props.brew.title,
url : `/share/${this.props.brew.shareId}`
}}
/>;
},
}),
edited : createClass({
getDefaultProps : function() {
return {
brew : {
title : '',
editId : ''
}
};
},
render : function(){
return <BaseItem text='recently edited' storageKey={EDIT_KEY}
currentBrew={{
id : this.props.brew.editId,
title : this.props.brew.title,
url : `/edit/${this.props.brew.editId}`
}}
/>;
},
}),
both : createClass({
getDefaultProps : function() {
return {
errorId : null
};
},
getInitialState : function() {
return {
showDropdown : false,
edit : [],
view : []
};
},
componentDidMount : function() {
let edited = JSON.parse(localStorage.getItem(EDIT_KEY) || '[]');
let viewed = JSON.parse(localStorage.getItem(VIEW_KEY) || '[]');
if(this.props.errorId){
edited = _.filter(edited, (edit)=>{
return edit.id !== this.props.errorId;
});
viewed = _.filter(viewed, (view)=>{
return view.id !== this.props.errorId;
});
localStorage.setItem(EDIT_KEY, JSON.stringify(edited));
localStorage.setItem(VIEW_KEY, JSON.stringify(viewed));
}
this.setState({
edit : edited,
view : viewed
});
},
handleDropdown : function(show){
this.setState({
showDropdown : show
});
},
renderDropdown : function(){
if(!this.state.showDropdown) return null;
const makeItems = (brews)=>{
return _.map(brews, (brew)=>{
return <a href={brew.url} className='item' key={brew.id} target='_blank' rel='noopener noreferrer'>
<span className='title'>{brew.title}</span>
<span className='time'>{Moment(brew.ts).fromNow()}</span>
</a>;
});
};
return <div className='dropdown'>
<h4>edited</h4>
{makeItems(this.state.edit)}
<h4>viewed</h4>
{makeItems(this.state.view)}
</div>;
},
render : function(){
return <Nav.item icon='fa-clock-o' color='grey' className='recent'
onMouseEnter={()=>this.handleDropdown(true)}
onMouseLeave={()=>this.handleDropdown(false)}>
Recent brews
{this.renderDropdown()}
</Nav.item>;
}
})
};

View File

@@ -0,0 +1,52 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
//var striptags = require('striptags');
const Nav = require('naturalcrit/nav/nav.jsx');
const MAX_URL_SIZE = 2083;
const MAIN_URL = 'https://www.reddit.com/r/UnearthedArcana/submit?selftext=true';
const RedditShare = createClass({
getDefaultProps : function() {
return {
brew : {
title : '',
sharedId : '',
text : ''
}
};
},
getText : function(){
},
handleClick : function(){
const url = [
MAIN_URL,
`title=${encodeURIComponent(this.props.brew.title ? this.props.brew.title : 'Check out my brew!')}`,
`text=${encodeURIComponent(this.props.brew.text)}`
].join('&');
window.open(url, '_blank');
},
render : function(){
return <Nav.item icon='fa-reddit-alien' color='red' onClick={this.handleClick}>
share on reddit
</Nav.item>;
},
});
module.exports = RedditShare;

View File

@@ -1,28 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Markdown = require('marked');
var PageContainer = React.createClass({
getDefaultProps: function() {
return {
text : ""
};
},
renderPages : function(){
return _.map(this.props.text.split('\\page'), (pageText, index) => {
return <div className='phb' dangerouslySetInnerHTML={{__html:Markdown(pageText)}} key={index} />
})
},
render : function(){
var self = this;
return <div className="pageContainer">
{this.renderPages()}
</div>;
}
});
module.exports = PageContainer;

View File

@@ -1,12 +0,0 @@
@import (less) './client/homebrew/phbStyle/phb.style.less';
.pageContainer{
padding : 30px 0px;
background-color : @steel;
&>.phb{
margin-right : auto;
margin-bottom : 30px;
margin-left : auto;
box-shadow : 1px 4px 14px #000;
}
}

View File

@@ -0,0 +1,222 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const ReportIssue = require('../../navbar/issue.navitem.jsx');
const PrintLink = require('../../navbar/print.navitem.jsx');
const Account = require('../../navbar/account.navitem.jsx');
//const RecentlyEdited = require('../../navbar/recent.navitem.jsx').edited;
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
const Editor = require('../../editor/editor.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const Markdown = require('naturalcrit/markdown.js');
const SAVE_TIMEOUT = 3000;
const EditPage = createClass({
getDefaultProps : function() {
return {
brew : {
text : '',
shareId : null,
editId : null,
createdAt : null,
updatedAt : null,
title : '',
description : '',
tags : '',
published : false,
authors : [],
systems : []
}
};
},
getInitialState : function() {
return {
brew : this.props.brew,
isSaving : false,
isPending : false,
errors : null,
htmlErrors : Markdown.validate(this.props.brew.text),
};
},
savedBrew : null,
componentDidMount : function(){
this.trySave();
window.onbeforeunload = ()=>{
if(this.state.isSaving || this.state.isPending){
return 'You have unsaved changes!';
}
};
this.setState((prevState)=>({
htmlErrors : Markdown.validate(prevState.brew.text)
}));
document.addEventListener('keydown', this.handleControlKeys);
},
componentWillUnmount : function() {
window.onbeforeunload = function(){};
document.removeEventListener('keydown', this.handleControlKeys);
},
handleControlKeys : function(e){
if(!(e.ctrlKey || e.metaKey)) return;
const S_KEY = 83;
const P_KEY = 80;
if(e.keyCode == S_KEY) this.save();
if(e.keyCode == P_KEY) window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
e.stopPropagation();
e.preventDefault();
}
},
handleSplitMove : function(){
this.refs.editor.update();
},
handleMetadataChange : function(metadata){
this.setState((prevState)=>({
brew : _.merge({}, prevState.brew, metadata),
isPending : true,
}), ()=>this.trySave());
},
handleTextChange : function(text){
//If there are errors, run the validator on everychange to give quick feedback
let htmlErrors = this.state.htmlErrors;
if(htmlErrors.length) htmlErrors = Markdown.validate(text);
this.setState((prevState)=>({
brew : _.merge({}, prevState.brew, { text: text }),
isPending : true,
htmlErrors : htmlErrors
}), ()=>this.trySave());
},
hasChanges : function(){
const savedBrew = this.savedBrew ? this.savedBrew : this.props.brew;
return !_.isEqual(this.state.brew, savedBrew);
},
trySave : function(){
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
if(this.hasChanges()){
this.debounceSave();
} else {
this.debounceSave.cancel();
}
},
save : function(){
if(this.debounceSave && this.debounceSave.cancel) this.debounceSave.cancel();
this.setState((prevState)=>({
isSaving : true,
errors : null,
htmlErrors : Markdown.validate(prevState.brew.text)
}));
request
.put(`/api/update/${this.props.brew.editId}`)
.send(this.state.brew)
.end((err, res)=>{
if(err){
this.setState({
errors : err,
});
} else {
this.savedBrew = res.body;
this.setState({
isPending : false,
isSaving : false,
});
}
});
},
renderSaveButton : function(){
if(this.state.errors){
let errMsg = '';
try {
errMsg += `${this.state.errors.toString()}\n\n`;
errMsg += `\`\`\`\n${JSON.stringify(this.state.errors.response.error, null, ' ')}\n\`\`\``;
} catch (e){}
return <Nav.item className='save error' icon='fa-warning'>
Oops!
<div className='errorContainer'>
Looks like there was a problem saving. <br />
Report the issue <a target='_blank' rel='noopener noreferrer'
href={`https://github.com/stolksdorf/naturalcrit/issues/new?body=${encodeURIComponent(errMsg)}`}>
here
</a>.
</div>
</Nav.item>;
}
if(this.state.isSaving){
return <Nav.item className='save' icon='fa-spinner fa-spin'>saving...</Nav.item>;
}
if(this.state.isPending && this.hasChanges()){
return <Nav.item className='save' onClick={this.save} color='blue' icon='fa-save'>Save Now</Nav.item>;
}
if(!this.state.isPending && !this.state.isSaving){
return <Nav.item className='save saved'>saved.</Nav.item>;
}
},
renderNavbar : function(){
return <Navbar>
<Nav.section>
<Nav.item className='brewTitle'>{this.state.brew.title}</Nav.item>
</Nav.section>
<Nav.section>
{this.renderSaveButton()}
{/*<RecentlyEdited brew={this.props.brew} />*/}
<ReportIssue />
<Nav.item newTab={true} href={`/share/${this.props.brew.shareId}`} color='teal' icon='fa-share-alt'>
Share
</Nav.item>
<PrintLink shareId={this.props.brew.shareId} />
<Account />
</Nav.section>
</Navbar>;
},
render : function(){
return <div className='editPage page'>
{this.renderNavbar()}
<div className='content'>
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
<Editor
ref='editor'
value={this.state.brew.text}
onChange={this.handleTextChange}
metadata={this.state.brew}
onMetadataChange={this.handleMetadataChange}
/>
<BrewRenderer text={this.state.brew.text} errors={this.state.htmlErrors} />
</SplitPane>
</div>
</div>;
}
});
module.exports = EditPage;

View File

@@ -0,0 +1,27 @@
.editPage{
.navItem.save{
width : 105px;
text-align : center;
&.saved{
cursor : initial;
color : #666;
}
&.error{
position : relative;
background-color : @red;
.errorContainer{
position : absolute;
top : 29px;
left : -20px;
z-index : 1000;
width : 120px;
padding : 8px;
background-color : #333;
a{
color : @teal;
}
}
}
}
}

View File

@@ -0,0 +1,47 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const PatreonNavItem = require('../../navbar/patreon.navitem.jsx');
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const ErrorPage = createClass({
getDefaultProps : function() {
return {
ver : '0.0.0',
errorId : ''
};
},
text : '# Oops \n We could not find a brew with that id. **Sorry!**',
render : function(){
return <div className='errorPage page'>
<Navbar ver={this.props.ver}>
<Nav.section>
<Nav.item className='errorTitle'>
Crit Fail!
</Nav.item>
</Nav.section>
<Nav.section>
<PatreonNavItem />
<IssueNavItem />
<RecentNavItem.both errorId={this.props.errorId} />
</Nav.section>
</Navbar>
<div className='content'>
<BrewRenderer text={this.text} />
</div>
</div>;
}
});
module.exports = ErrorPage;

View File

@@ -0,0 +1,5 @@
.errorPage{
.errorTitle{
background-color: @orange;
}
}

View File

@@ -0,0 +1,12 @@
//TODO: Depricate
module.exports = function(shareId){
return function(event){
event = event || window.event;
if((event.ctrlKey || event.metaKey) && event.keyCode == 80){
const win = window.open(`/homebrew/print/${shareId}?dialog=true`, '_blank');
win.focus();
event.preventDefault();
}
};
};

View File

@@ -0,0 +1,95 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const PatreonNavItem = require('../../navbar/patreon.navitem.jsx');
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx');
const AccountNavItem = require('../../navbar/account.navitem.jsx');
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
const Editor = require('../../editor/editor.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const HomePage = createClass({
getDefaultProps : function() {
return {
welcomeText : '',
ver : '0.0.0'
};
},
getInitialState : function() {
return {
text : this.props.welcomeText
};
},
handleSave : function(){
request.post('/api')
.send({
text : this.state.text
})
.end((err, res)=>{
if(err) return;
const brew = res.body;
window.location = `/edit/${brew.editId}`;
});
},
handleSplitMove : function(){
this.refs.editor.update();
},
handleTextChange : function(text){
this.setState({
text : text
});
},
renderNavbar : function(){
return <Navbar ver={this.props.ver}>
<Nav.section>
<PatreonNavItem />
<IssueNavItem />
<Nav.item newTab={true} href='/changelog' color='purple' icon='fa-file-text-o'>
Changelog
</Nav.item>
<RecentNavItem.both />
<AccountNavItem />
{/*}
<Nav.item href='/new' color='green' icon='fa-external-link'>
New Brew
</Nav.item>
*/}
</Nav.section>
</Navbar>;
},
render : function(){
return <div className='homePage page'>
{this.renderNavbar()}
<div className='content'>
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
<Editor value={this.state.text} onChange={this.handleTextChange} ref='editor'/>
<BrewRenderer text={this.state.text} />
</SplitPane>
</div>
<div className={cx('floatingSaveButton', { show: this.props.welcomeText != this.state.text })} onClick={this.handleSave}>
Save current <i className='fa fa-save' />
</div>
<a href='/new' className='floatingNewButton'>
Create your own <i className='fa fa-magic' />
</a>
</div>;
}
});
module.exports = HomePage;

View File

@@ -0,0 +1,43 @@
.homePage{
position : relative;
a.floatingNewButton{
.animate(background-color);
position : absolute;
display : block;
right : 70px;
bottom : 70px;
z-index : 100;
z-index : 5001;
padding : 1em;
background-color : @orange;
font-size : 1.5em;
color : white;
text-decoration : none;
box-shadow : 3px 3px 15px black;
&:hover{
background-color : darken(@orange, 20%);
}
}
.floatingSaveButton{
.animateAll();
position : absolute;
display : block;
right : 200px;
bottom : 90px;
z-index : 100;
z-index : 5000;
padding : 0.8em;
cursor : pointer;
background-color : @blue;
font-size : 0.8em;
color : white;
text-decoration : none;
box-shadow : 3px 3px 15px black;
&:hover{
background-color : darken(@blue, 20%);
}
&.show{
right : 350px;
}
}
}

View File

@@ -0,0 +1,100 @@
# 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.
### Homebrew D&D made easy
The Homebrewery makes the creation and sharing of authentic looking Fifth-Edition homebrews easy. It uses [Markdown](https://help.github.com/articles/markdown-basics/) with a little CSS magic to make your brews come to life.
**Try it! **Simply edit the text on the left and watch it *update live* on the right.
### Editing and Sharing
When you create your own homebrew you will be given a *edit url* and a *share url*. Any changes you make will be automatically saved to the database within a few seconds. Anyone with the edit url will be able to make edits to your homebrew. So be careful about who you share it with.
Anyone with the *share url* will be able to access a read-only version of your homebrew.
## Helping out
Like this tool? Want to buy me a beer? [Head here](https://www.patreon.com/stolksdorf) to help me keep the servers running.
This tool will **always** be free, never have ads, and I will never offer any "premium" features or whatever.
>##### PDF Exporting
> PDF Printing works best in Chrome. If you are having quality/consistency issues, try using Chrome to print instead.
>
> After clicking the "Print" item in the navbar a new page will open and a print dialog will pop-up.
> * Set the **Destination** to "Save as PDF"
> * Set **Paper Size** to "Letter"
> * If you are printing on A4 paper, make sure to have the "A4 page size snippet" in your brew
> * In **Options** make sure "Background Images" is selected.
> * Hit print and enjoy! You're done!
>
> If you want to save ink or have a monochrome printer, add the **Ink Friendly** snippet to your brew before you print
```
```
## Big things coming in v3.0.0
With the next major release of Homebrewery, v3.0.0, this tool *will no longer support raw HTML input for brew code*. All brews made previous to the release of v3.0.0 will still render normally.
## New Things All The Time!
What's new in the latest update? Check out the full changelog [here](/changelog)
### Bugs, Issues, Suggestions?
Have an idea of how to make The Homebrewery better? Or did you find something that wasn't quite right? Head [here](https://github.com/stolksdorf/homebrewery/issues/new) and let me know!.
### Legal Junk
The Homebrewery is licensed using the [MIT License](https://github.com/stolksdorf/homebrewery/blob/master/license). Which means you are free to use The Homebrewery is any way that you want, except for claiming that you made it yourself.
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 images or resources used.
### More 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/comments/3uwxx9/resources_open_to_the_community/).
<img src='https://i.imgur.com/hMna6G0.png' style='position:absolute;bottom:50px;right:30px;width:280px' />
<div class='pageNumber'>1</div>
<div class='footnote'>PART 1 | FANCINESS</div>
\page
# Appendix
### Not quite Markdown
Although the Homebrewery uses Markdown, to get all the styling features from the PHB, we had to get a little creative. Some base HTML elements are not used as expected and I've had to include a few new keywords.
___
* **Horizontal Rules** are generally used to *modify* existing elements into a different style. For example, a horizontal rule before a blockquote will give it the style of a Monster Stat Block instead of a note.
* **New Pages** are controlled by the author. It's impossible for the site to detect when the end of a page is reached, so indicate you'd like to start a new page, use the new page snippet to get the syntax.
* **Code Blocks** are used only to indicate column breaks. Since they don't allow for styling within them, they weren't that useful to use.
* **HTML** can be used to get *just* the right look for your homebrew. I've included some examples in the snippet icons above the editor.
```
```
### Images
Images must be hosted online somewhere, like imgur. You use the address to that image to reference it in your brew. Images can be included 'inline' with the text using Markdown-style images. However for background images more control is needed.
Background images should be included as HTML-style img tags. Using inline CSS you can precisely position your image where you'd like it to be. I have added both a inflow image snippet and a background image snippet to give you exmaples of how to do it.
### Crediting Me
If you'd like to credit The Homebrewery in your brew, I'd be flattered! Just reference that you made it with The Homebrewery.
<div class='pageNumber'>2</div>
<div class='footnote'>PART 2 | BORING STUFF</div>

View File

@@ -0,0 +1,162 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const Markdown = require('naturalcrit/markdown.js');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const AccountNavItem = require('../../navbar/account.navitem.jsx');
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
const Editor = require('../../editor/editor.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const KEY = 'homebrewery-new';
const NewPage = createClass({
getInitialState : function() {
return {
metadata : {
title : '',
description : '',
tags : '',
published : false,
authors : [],
systems : []
},
text : '',
isSaving : false,
errors : []
};
},
componentDidMount : function() {
const storage = localStorage.getItem(KEY);
if(storage){
this.setState({
text : storage
});
}
document.addEventListener('keydown', this.handleControlKeys);
},
componentWillUnmount : function() {
document.removeEventListener('keydown', this.handleControlKeys);
},
handleControlKeys : function(e){
if(!(e.ctrlKey || e.metaKey)) return;
const S_KEY = 83;
const P_KEY = 80;
if(e.keyCode == S_KEY) this.save();
if(e.keyCode == P_KEY) this.print();
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
e.stopPropagation();
e.preventDefault();
}
},
handleSplitMove : function(){
this.refs.editor.update();
},
handleMetadataChange : function(metadata){
this.setState({
metadata : _.merge({}, this.state.metadata, metadata)
});
},
handleTextChange : function(text){
this.setState({
text : text,
errors : Markdown.validate(text)
});
localStorage.setItem(KEY, text);
},
save : function(){
this.setState({
isSaving : true
});
request.post('/api')
.send(_.merge({}, this.state.metadata, {
text : this.state.text
}))
.end((err, res)=>{
if(err){
this.setState({
isSaving : false
});
return;
}
window.onbeforeunload = function(){};
const brew = res.body;
localStorage.removeItem(KEY);
window.location = `/edit/${brew.editId}`;
});
},
renderSaveButton : function(){
if(this.state.isSaving){
return <Nav.item icon='fa-spinner fa-spin' className='saveButton'>
save...
</Nav.item>;
} else {
return <Nav.item icon='fa-save' className='saveButton' onClick={this.save}>
save
</Nav.item>;
}
},
print : function(){
localStorage.setItem('print', this.state.text);
window.open('/print?dialog=true&local=print', '_blank');
},
renderLocalPrintButton : function(){
return <Nav.item color='purple' icon='fa-file-pdf-o' onClick={this.print}>
get PDF
</Nav.item>;
},
renderNavbar : function(){
return <Navbar>
<Nav.section>
<Nav.item className='brewTitle'>{this.state.metadata.title}</Nav.item>
</Nav.section>
<Nav.section>
{this.renderSaveButton()}
{this.renderLocalPrintButton()}
<IssueNavItem />
<AccountNavItem />
</Nav.section>
</Navbar>;
},
render : function(){
return <div className='newPage page'>
{this.renderNavbar()}
<div className='content'>
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
<Editor
ref='editor'
value={this.state.text}
onChange={this.handleTextChange}
metadata={this.state.metadata}
onMetadataChange={this.handleMetadataChange}
/>
<BrewRenderer text={this.state.text} errors={this.state.errors} />
</SplitPane>
</div>
</div>;
}
});
module.exports = NewPage;

View File

@@ -0,0 +1,10 @@
.newPage{
.saveButton{
background-color: @orange;
&:hover{
background-color: @green;
}
}
}

View File

@@ -0,0 +1,50 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Markdown = require('naturalcrit/markdown.js');
const PrintPage = createClass({
getDefaultProps : function() {
return {
query : {},
brew : {
text : '',
}
};
},
getInitialState : function() {
return {
brewText : this.props.brew.text
};
},
componentDidMount : function() {
if(this.props.query.local){
this.setState((prevState, prevProps)=>({
brewText : localStorage.getItem(prevProps.query.local)
}));
}
if(this.props.query.dialog) window.print();
},
renderPages : function(){
return _.map(this.state.brewText.split('\\page'), (page, index)=>{
return <div
className='phb'
id={`p${index + 1}`}
dangerouslySetInnerHTML={{ __html: Markdown.render(page) }}
key={index} />;
});
},
render : function(){
return <div>
{this.renderPages()}
</div>;
}
});
module.exports = PrintPage;

View File

@@ -0,0 +1,3 @@
.printPage{
}

View File

@@ -0,0 +1,72 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const PrintLink = require('../../navbar/print.navitem.jsx');
const ReportIssue = require('../../navbar/issue.navitem.jsx');
//const RecentlyViewed = require('../../navbar/recent.navitem.jsx').viewed;
const Account = require('../../navbar/account.navitem.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const SharePage = createClass({
getDefaultProps : function() {
return {
brew : {
title : '',
text : '',
shareId : null,
createdAt : null,
updatedAt : null,
views : 0
}
};
},
componentDidMount : function() {
document.addEventListener('keydown', this.handleControlKeys);
},
componentWillUnmount : function() {
document.removeEventListener('keydown', this.handleControlKeys);
},
handleControlKeys : function(e){
if(!(e.ctrlKey || e.metaKey)) return;
const P_KEY = 80;
if(e.keyCode == P_KEY){
window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
e.stopPropagation();
e.preventDefault();
}
},
render : function(){
return <div className='sharePage page'>
<Navbar>
<Nav.section>
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
</Nav.section>
<Nav.section>
<ReportIssue />
{/*<RecentlyViewed brew={this.props.brew} />*/}
<PrintLink shareId={this.props.brew.shareId} />
<Nav.item href={`/source/${this.props.brew.shareId}`} color='teal' icon='fa-code'>
source
</Nav.item>
<Account />
</Nav.section>
</Navbar>
<div className='content'>
<BrewRenderer text={this.props.brew.text} />
</div>
</div>;
}
});
module.exports = SharePage;

View File

@@ -0,0 +1,76 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const moment = require('moment');
const request = require('superagent');
const BrewItem = createClass({
getDefaultProps : function() {
return {
brew : {
title : '',
description : '',
authors : []
}
};
},
deleteBrew : function(){
if(!confirm('are you sure you want to delete this brew?')) return;
if(!confirm('are you REALLY sure? You will not be able to recover it')) return;
request.get(`/api/remove/${this.props.brew.editId}`)
.send()
.end(function(err, res){
location.reload();
});
},
renderDeleteBrewLink : function(){
if(!this.props.brew.editId) return;
return <a onClick={this.deleteBrew}>
<i className='fa fa-trash' />
</a>;
},
renderEditLink : function(){
if(!this.props.brew.editId) return;
return <a href={`/edit/${this.props.brew.editId}`} target='_blank' rel='noopener noreferrer'>
<i className='fa fa-pencil' />
</a>;
},
render : function(){
const brew = this.props.brew;
return <div className='brewItem'>
<h2>{brew.title}</h2>
<p className='description' >{brew.description}</p>
<hr />
<div className='info'>
<span>
<i className='fa fa-user' /> {brew.authors.join(', ')}
</span>
<span>
<i className='fa fa-eye' /> {brew.views}
</span>
<span>
<i className='fa fa-refresh' /> {moment(brew.updatedAt).fromNow()}
</span>
</div>
<div className='links'>
<a href={`/share/${brew.shareId}`} target='_blank' rel='noopener noreferrer'>
<i className='fa fa-share-alt' />
</a>
{this.renderEditLink()}
{this.renderDeleteBrewLink()}
</div>
</div>;
}
});
module.exports = BrewItem;

View File

@@ -0,0 +1,60 @@
.brewItem{
position : relative;
display : inline-block;
vertical-align : top;
box-sizing : border-box;
box-sizing : border-box;
overflow : hidden;
width : 48%;
margin-right : 15px;
margin-bottom : 15px;
padding : 5px 15px 5px 8px;
padding-right : 15px;
border : 1px solid #c9ad6a;
border-radius : 5px;
-webkit-column-break-inside : avoid;
page-break-inside : avoid;
break-inside : avoid;
h4{
margin-bottom : 5px;
font-size : 2.2em;
}
.info{
font-family : ScalySans;
font-size : 1.2em;
&>span{
margin-right : 15px;
}
}
&:hover{
.links{
opacity : 1;
}
}
&:nth-child(2n + 1){
margin-right : 0px;
}
.links{
.animate(opacity);
position : absolute;
top : 0px;
right : 0px;
height : 100%;
width : 2em;
opacity : 0;
background-color : fade(black, 60%);
text-align : center;
a{
.animate(opacity);
display : block;
margin : 8px 0px;
opacity : 0.6;
font-size : 1.3em;
color : white;
&:hover{
opacity : 1;
}
}
}
}

View File

@@ -0,0 +1,76 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx');
const Account = require('../../navbar/account.navitem.jsx');
const BrewItem = require('./brewItem/brewItem.jsx');
// const brew = {
// title : 'SUPER Long title woah now',
// authors : []
// };
//const BREWS = _.times(25, ()=>{ return brew;});
const UserPage = createClass({
getDefaultProps : function() {
return {
username : '',
brews : []
};
},
renderBrews : function(brews){
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
const sortedBrews = _.sortBy(brews, (brew)=>{ return brew.title; });
return _.map(sortedBrews, (brew, idx)=>{
return <BrewItem brew={brew} key={idx}/>;
});
},
getSortedBrews : function(){
return _.groupBy(this.props.brews, (brew)=>{
return (brew.published ? 'published' : 'private');
});
},
renderPrivateBrews : function(privateBrews){
if(!privateBrews || !privateBrews.length) return;
return [
<h1>{this.props.username}'s unpublished brews</h1>,
this.renderBrews(privateBrews)
];
},
render : function(){
const brews = this.getSortedBrews();
return <div className='userPage page'>
<Navbar>
<Nav.section>
<RecentNavItem.both />
<Account />
</Nav.section>
</Navbar>
<div className='content'>
<div className='phb'>
<h1>{this.props.username}'s brews</h1>
{this.renderBrews(brews.published)}
{this.renderPrivateBrews(brews.private)}
</div>
</div>
</div>;
}
});
module.exports = UserPage;

View File

@@ -0,0 +1,33 @@
.noColumns(){
column-count : auto;
column-fill : auto;
column-gap : auto;
column-width : auto;
-webkit-column-count : auto;
-moz-column-count : auto;
-webkit-column-width : auto;
-moz-column-width : auto;
-webkit-column-gap : auto;
-moz-column-gap : auto;
}
.userPage{
.content{
overflow-y : scroll;
.phb{
.noColumns();
height : auto;
min-height : 279.4mm;
margin : 20px auto;
&::after{
display : none;
}
.noBrews{
margin : 10px 0px;
font-size : 1.3em;
font-style : italic;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,31 @@
.phb{
//Double hr for full width elements
hr+hr+blockquote{
column-span : all;
-webkit-column-span : all;
-moz-column-span : all;
}
//*****************************
// * CLASS TABLE
// *****************************/
hr+table{
margin-top : -5px;
margin-bottom : 50px;
padding-top : 10px;
border-collapse : separate;
background-color : white;
border : initial;
border-style : solid;
border-image-outset : 37px 17px;
border-image-repeat : round;
border-image-slice : 150 200 150 200;
border-image-source : @frameBorderImage;
border-image-width : 47px;
}
h5+hr+table{
column-span : all;
-webkit-column-span : all;
-moz-column-span : all;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,8 @@
@import (less) 'shared/naturalCrit/styles/reset.less';
@import (less) 'shared/naturalcrit/styles/reset.less';
@import (less) './client/homebrew/phbStyle/phb.fonts.css';
@import (less) './client/homebrew/phbStyle/phb.assets.less';
@import (less) './client/homebrew/phbStyle/phb.depricated.less';
//Colors
@background : #EEE5CE;
@noteGreen : #e0e5c1;
@@ -9,6 +10,13 @@
@horizontalRule : #9c2b1b;
@headerText : #58180D;
@monsterStatBackground : #FDF1DC;
@page { margin: 0; }
body {
counter-reset : phb-page-numbers;
}
*{
-webkit-print-color-adjust : exact;
}
.useSansSerif(){
font-family : ScalySans;
em{
@@ -16,38 +24,41 @@
font-style : italic;
}
strong{
font-family : ScalySans;
font-weight : 800;
letter-spacing: -0.02em;
font-family : ScalySans;
font-weight : 800;
letter-spacing : -0.02em;
}
}
.useColumns(){
.useColumns(@multiplier : 1){
column-count : 2;
column-fill : auto;
column-gap : 1cm;
column-width : 8cm;
column-width : 8cm * @multiplier;
-webkit-column-count : 2;
-moz-column-count : 2;
-webkit-column-width : 8cm;
-moz-column-width : 8cm;
-webkit-column-width : 8cm * @multiplier;
-moz-column-width : 8cm * @multiplier;
-webkit-column-gap : 1cm;
-moz-column-gap : 1cm;
}
.phb{
.useColumns();
position : relative;
z-index : 15;
box-sizing : border-box;
overflow : hidden;
height : 279.4mm;
width : 215.9mm;
padding : 1.0cm 1.7cm;
padding-bottom : 1.5cm;
background-color : @background;
background-image : @backgroundImage;
font-family : BookSanity;
font-size : 9pt;
text-rendering : optimizeLegibility;
counter-increment : phb-page-numbers;
position : relative;
z-index : 15;
box-sizing : border-box;
overflow : hidden;
height : 279.4mm;
width : 215.9mm;
padding : 1.0cm 1.7cm;
padding-bottom : 1.5cm;
background-color : @background;
background-image : @backgroundImage;
font-family : BookSanity;
font-size : 0.317cm;
text-rendering : optimizeLegibility;
page-break-before : always;
page-break-after : always;
//*****************************
// * BASE
// *****************************/
@@ -55,32 +66,47 @@
padding-bottom : 0.8em;
line-height : 1.3em;
&+p{
margin-top : -0.8em;
text-indent : 1em;
margin-top : -0.8em;
}
}
ul{
margin-bottom : 0.8em;
padding-left : 1.4em;
line-height : 1.3em;
list-style-position : inside;
list-style-position : outside;
list-style-type : disc;
}
ol{
list-style-position: inside;
margin-bottom : 0.8em;
padding-left : 1.4em;
line-height : 1.3em;
list-style-position : outside;
list-style-type : decimal;
}
//Indents after p or lists
p+p, ul+p, ol+p{
text-indent : 1em;
}
img{
z-index : -1;
}
strong{
font-weight : bold;
letter-spacing: 0.03em;
font-weight : bold;
letter-spacing : 0.03em;
}
em{
font-style : italic;
}
sup{
vertical-align : super;
font-size : smaller;
line-height : 0;
}
sub{
vertical-align : sub;
font-size : smaller;
line-height : 0;
}
//*****************************
// * HEADERS
// *****************************/
@@ -92,33 +118,33 @@
color : @headerText;
}
h1{
column-span : 2;
font-size : 28pt;
-webkit-column-span : 2;
-moz-column-span : 2;
column-span : all;
font-size : 0.987cm;
-webkit-column-span : all;
-moz-column-span : all;
&+p::first-letter{
float : left;
font-family : Solberry;
line-height: 0.8em;
font-size : 10em;
color : #222;
float : left;
font-family : Solberry;
font-size : 10em;
color : #222;
line-height : 0.8em;
}
}
h2{
font-size : 20pt;
font-size : 0.705cm;
}
h3{
font-size : 15pt;
font-size : 0.529cm;
border-bottom : 2px solid @headerUnderline;
}
h4{
margin-bottom : 0.00em;
font-size : 12pt;
font-size : 0.458cm;
}
h5{
margin-bottom : 0.2em;
font-family : ScalySansSmallCaps;
font-size : 13pt;
font-size : 0.423cm;
font-weight : 900;
}
//*****************************
@@ -130,6 +156,7 @@
margin-bottom : 1em;
font-size : 10pt;
thead{
display: table-row-group;
font-weight : 800;
th{
vertical-align : bottom;
@@ -154,26 +181,36 @@
// *****************************/
blockquote{
.useSansSerif();
box-sizing : border-box;
margin-bottom : 1em;
padding : 5px 10px;
background-color : @noteGreen;
border-top : 2px black solid;
border-bottom : 2px black solid;
box-shadow : 1px 4px 14px #888;
box-sizing : border-box;
margin-bottom : 1em;
padding : 5px 10px;
background-color : @noteGreen;
border-style : solid;
border-width : 11px;
border-image : @noteBorderImage 11;
border-image-outset : 9px 0px;
box-shadow : 1px 4px 14px #888;
p, ul{
font-size : 10pt;
font-size : 0.352cm;
line-height : 1.1em;
}
}
//If a note starts a column, give it space at the top to render border
pre+blockquote, h2+blockquote, h3+blockquote, h4+blockquote, h5+blockquote {
margin-top : 13px;
}
//*****************************
// * MONSTER STAT BLOCK
// *****************************/
hr+blockquote{
position : relative;
padding-top : 15px;
background-color : @monsterStatBackground;
border : none;
border-style : solid;
border-width : 10px;
border-image : @monsterBorderImage 10;
h2{
margin-top : -8px;
margin-bottom : 0px;
&+p{
padding-bottom : 0px;
@@ -184,19 +221,20 @@
font-weight : 400;
border-bottom : 1px solid @headerText;
}
hr+ul{
color : @headerText;
}
ul{
.useSansSerif();
padding-left : 1em;
font-size : 10pt;
color : @headerText;
text-indent : -1em;
list-style-type : none;
padding-left : 1em;
font-size : 0.352cm;
}
// Monster Ability table
hr+table{
margin : 0;
column-span : 1;
background-color : transparent;
border-style : none;
border-image : none;
-webkit-column-span : 1;
tbody{
@@ -215,65 +253,17 @@
}
//Triangle dividers
hr{
@height : 3px;
position : relative;
visibility : visible;
margin : 8px 0px;
border-color : transparent;
&:after, &:before{
content : "";
position : absolute;
left : 0px;
height : @height;
width : 100%;
}
&:before{
top : -@height;
background : linear-gradient(to right top, @horizontalRule 40%, transparent 50%)
}
&:after{
top : 0px;
background : linear-gradient(to right bottom, @horizontalRule 40%, transparent 50%)
}
}
//Top and Bottom Borders
&:after, &:before{
content : "";
position : absolute;
height : 4px;
width : 100%;
padding : 0px 3px;
background-color : #E69A28;
border : 1px solid black;
}
&:before{
top : 0px;
left : -3px;
}
&:after{
bottom : 0px;
left : -3px;
visibility : visible;
height : 6px;
margin : 4px 0px;
background-image : @redTriangleImage;
background-size : 100% 100%;
border : none;
}
}
//Full Width
hr+hr+blockquote{
.useColumns();
}
//*****************************
// * FULL CLASS TABLE
// *****************************/
hr+table{
margin-top : -5px;
margin-bottom : 50px;
padding-top : 10px;
border-collapse : separate;
background-color : white;
border : initial;
border-image-outset : 37px 17px;
border-image-repeat : round;
border-image-slice : 150 200 150 200;
border-image-source : @frameBorderImage;
border-image-width : 47px;
.useColumns(0.96);
}
//*****************************
// * FOOTER
@@ -283,6 +273,7 @@
position : absolute;
bottom : 0px;
left : 0px;
z-index : 100;
height : 50px;
width : 100%;
background-image : @footerAccentImage;
@@ -308,11 +299,15 @@
font-size : 0.9em;
color : #c9ad6a;
text-align : center;
&.auto::after {
content : counter(phb-page-numbers);
}
}
.footnote{
position : absolute;
right : 80px;
bottom : 32px;
z-index : 150;
width : 200px;
font-size : 0.8em;
color : #c9ad6a;
@@ -332,28 +327,146 @@
text-indent : -1em;
list-style-type : none;
}
//Double hr for full width elements
hr+hr+table, hr+hr+blockquote{
column-span : all;
-webkit-column-span : all;
-moz-column-span : all;
}
//Column Break
pre{
pre, code{
visibility : hidden;
-webkit-column-break-after : always;
break-after : always;
-moz-column-break-after : always;
}
//Avoid breaking up
p,ul,blockquote,table{
p,blockquote,table{
z-index : 15;
-webkit-column-break-inside : avoid;
column-break-inside : avoid;
page-break-inside : avoid;
break-inside : avoid;
overflow: hidden; /* Firefox fix */
}
//Better spacing for spell blocks
h4+p+hr+ul{
margin-top : -0.5em
}
}
//Text indent right after table
table+p{
text-indent : 1em;
}
// Nested lists
ul ul,ol ol,ul ol,ol ul{
margin-bottom : 0px;
margin-left : 1.5em;
}
li{
-webkit-column-break-inside : avoid;
page-break-inside : avoid;
break-inside : avoid;
}
}
//*****************************
// * SPELL LIST
// *****************************/
.phb .spellList{
.useSansSerif();
column-count : 4;
column-span : all;
-webkit-column-span : all;
-moz-column-span : all;
ul+h5{
margin-top : 15px;
}
p, ul{
font-size : 0.352cm;
line-height : 1.3em;
}
ul{
margin-bottom : 0.5em;
padding-left : 1em;
text-indent : -1em;
list-style-type : none;
-webkit-column-break-inside : auto;
page-break-inside : auto;
break-inside : auto;
}
}
//*****************************
// * WIDE
// *****************************/
.phb .wide{
column-span : all;
-webkit-column-span : all;
-moz-column-span : all;
}
//*****************************
// * CLASS TABLE
// *****************************/
.phb .classTable{
margin-top : 25px;
margin-bottom : 40px;
border-collapse : separate;
background-color : white;
border : initial;
border-style : solid;
border-image-outset : 25px 17px;
border-image-repeat : stretch;
border-image-slice : 150 200 150 200;
border-image-source : @frameBorderImage;
border-image-width : 47px;
h5{
margin-bottom : 10px;
}
}
//************************************
// * DESCRIPTIVE TEXT BOX
// ************************************/
.phb .descriptive{
display : block-inline;
margin-bottom : 1em;
background-color : #faf7ea;
font-family : ScalySans;
border-style : solid;
border-width : 7px;
border-image : @descriptiveBoxImage 12 stretch;
border-image-outset : 4px;
box-shadow : 0px 0px 6px #faf7ea;
p{
display : block;
padding-bottom : 0px;
line-height : 1.5em;
}
p + p {
padding-top : .8em;
}
em {
font-family : ScalySans;
font-style : italic;
}
strong {
font-family : ScalySans;
font-weight : 800;
letter-spacing : -0.02em;
}
}
.phb pre+.descriptive{
margin-top : 8px;
}
//*****************************
// * TABLE OF CONTENTS
// *****************************/
.phb .toc{
-webkit-column-break-inside : avoid;
page-break-inside : avoid;
break-inside : avoid;
a{
color : black;
text-decoration : none;
&:hover{
text-decoration : underline;
}
}
ul{
padding-left : 0;
list-style-type : none;
}
&>ul>li{
margin-bottom : 10px;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

View File

@@ -1,40 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Statusbar = require('../statusbar/statusbar.jsx');
var PageContainer = require('../pageContainer/pageContainer.jsx');
var SharePage = React.createClass({
getDefaultProps: function() {
return {
id : null,
entry : {
text : "",
shareId : null,
editId : null,
createdAt : null,
updatedAt : null,
views : 0
}
};
},
render : function(){
return(
<div className='sharePage'>
<Statusbar
sourceText={this.props.entry.text}
lastUpdated={this.props.entry.updatedAt}
views={this.props.entry.views}
printId={this.props.entry.shareId}
/>
<PageContainer text={this.props.entry.text} />
</div>
);
}
});
module.exports = SharePage;

View File

@@ -1,134 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Moment = require('moment');
var Logo = require('naturalCrit/logo/logo.jsx');
var replaceAll = function(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
var Statusbar = React.createClass({
getDefaultProps: function() {
return {
//editId: null,
sourceText : null,
shareId : null,
printId : null,
isPending : false,
lastUpdated : null,
info : null,
views : 0
};
},
componentDidMount: function() {
//Updates the last updated text every 10 seconds
if(this.props.lastUpdated){
this.refreshTimer = setInterval(()=>{
this.forceUpdate();
}, 10000)
}
},
componentWillUnmount: function() {
clearInterval(this.refreshTimer);
},
openSourceWindow : function(){
var sourceWindow = window.open();
var content = replaceAll(this.props.sourceText, '<', '&lt;');
content = replaceAll(content, '>', '&gt;');
console.log(content);
sourceWindow.document.write('<code><pre>' + content + '</pre></code>');
},
renderInfo : function(){
if(!this.props.lastUpdated) return null;
return [
<div className='views' key='views'>
Views: {this.props.views}
</div>,
<div className='lastUpdated' key='lastUpdated'>
Last updated: {Moment(this.props.lastUpdated).fromNow()}
</div>
];
},
renderSourceButton : function(){
if(!this.props.sourceText) return null;
return <a className='sourceField' onClick={this.openSourceWindow}>
View Source <i className='fa fa-code' />
</a>
},
renderNewButton : function(){
if(this.props.editId || this.props.shareId) return null;
return <a className='newButton' target='_blank' href='/homebrew/new'>
New Brew <i className='fa fa-external-link' />
</a>
},
renderShare : function(){
if(!this.props.shareId) return null;
return <a className='shareField' key='share' href={'/homebrew/share/' + this.props.shareId} target="_blank">
Share Link <i className='fa fa-external-link' />
</a>
},
renderPrintButton : function(){
if(!this.props.printId) return null;
return <a className='printField' key='print' href={'/homebrew/print/' + this.props.printId} target="_blank">
Print View <i className='fa fa-print' />
</a>
},
renderStatus : function(){
if(!this.props.editId) return null;
var text = 'Saved.'
if(this.props.isPending){
text = 'Saving...'
}
return <div className='savingStatus'>
{text}
</div>
},
render : function(){
return <div className='statusbar'>
<Logo
hoverSlide={true}
/>
<div className='left'>
<a href='/homebrew' className='toolName'>
The Home<small>Brewery</small>
</a>
</div>
<div className='controls right'>
{this.renderStatus()}
{this.renderInfo()}
{this.renderSourceButton()}
{this.renderPrintButton()}
{this.renderShare()}
{this.renderNewButton()}
</div>
</div>
}
});
module.exports = Statusbar;

View File

@@ -1,110 +0,0 @@
.statusbar{
position : fixed;
z-index : 1000;
height : 25px;
width : 100%;
background-color : black;
font-size : 24px;
color : white;
line-height : 1.0em;
border-bottom : 1px solid @grey;
.logo{
display : inline-block;
vertical-align : middle;
margin-top : -5px;
margin-right : 20px;
svg{
margin-top : -6px;
}
}
.left{
display : inline-block;
vertical-align : top;
}
.right{
float : right;
}
.toolName{
display : block;
vertical-align : middle;
font-family : CodeBold;
font-size : 16px;
color : white;
line-height : 30px;
text-decoration : none;
small{
font-family : CodeBold;
}
}
.controls{
font-size : 12px;
>*{
display : inline-block;
height : 100%;
padding : 0px 10px;
border-left : 1px solid @grey;
}
.savingStatus{
width : 56px;
color : @grey;
text-align : center;
}
.newButton{
.animate(background-color);
color : white;
text-decoration : none;
&:hover{
background-color : fade(@green, 70%);
}
}
.shareField{
.animate(background-color);
cursor : pointer;
color : white;
text-decoration : none;
&:hover{
background-color : fade(@teal, 70%);
}
span{
margin-right : 5px;
}
input{
width : 100px;
font-size : 12px;
}
}
.printField{
.animate(background-color);
cursor : pointer;
color : white;
text-decoration : none;
&:hover{
background-color : fade(@orange, 70%);
}
span{
margin-right : 5px;
}
input{
width : 100px;
font-size : 12px;
}
}
.sourceField{
.animate(background-color);
cursor : pointer;
color : white;
text-decoration : none;
&:hover{
background-color : fade(@teal, 70%);
}
span{
margin-right : 5px;
}
input{
width : 100px;
font-size : 12px;
}
}
}
}

View File

@@ -1,165 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Sidebar = require('./sidebar/sidebar.jsx');
var Encounter = require('./encounter/encounter.jsx');
var encounters = [
{
name : 'The Big Bad',
desc : 'The big fight!',
reward : 'gems',
enemies : ['goblin', 'goblin'],
reserve : ['goblin'],
},
{
name : 'Demon Goats',
desc : 'Gross fight',
reward : 'curved horn, goat sac',
enemies : ['demon_goat', 'demon_goat', 'demon_goat'],
unique : {
demon_goat : {
"hp" : 140,
"ac" : 16,
"attr" : {
"str" : 8,
"con" : 8,
"dex" : 8,
"int" : 8,
"wis" : 8,
"cha" : 8
},
"attacks" : {
"charge" : {
"atk" : "1d20+5",
"dmg" : "1d8+5",
"type" : "bludge"
}
},
"abilities" : ["charge"],
}
}
},
];
var defaultMonsterManual = require('naturalCrit/defaultMonsterManual.js');
var attrMod = function(attr){
return Math.floor(attr/2) - 5;
}
var Store = require('naturalCrit/combat.store');
var Actions = require('naturalCrit/combat.actions');
var CombatManager = React.createClass({
mixins : [Store.mixin()],
getInitialState: function() {
var self = this;
return {
selectedEncounterIndex : 0,
encounters : JSON.parse(localStorage.getItem('encounters')) || encounters,
monsterManual : JSON.parse(localStorage.getItem('monsterManual')) || defaultMonsterManual,
players : localStorage.getItem('players') || 'jasper 13\nzatch 19',
};
},
onStoreChange : function(){
console.log('STORE CAHNGE', Store.getInc());
this.setState({
inc : Store.getInc()
})
},
handleEncounterJSONChange : function(encounterIndex, json){
this.state.encounters[encounterIndex] = json;
this.setState({
encounters : this.state.encounters
})
localStorage.setItem("encounters", JSON.stringify(this.state.encounters));
},
handleMonsterManualJSONChange : function(json){
this.setState({
monsterManual : json
});
localStorage.setItem("monsterManual", JSON.stringify(this.state.monsterManual));
},
handlePlayerChange : function(e){
this.setState({
players : e.target.value
});
localStorage.setItem("players", e.target.value);
},
handleSelectedEncounterChange : function(encounterIndex){
console.log(encounterIndex);
this.setState({
selectedEncounterIndex : encounterIndex
});
},
handleRemoveEncounter : function(encounterIndex){
this.state.encounters.splice(encounterIndex, 1);
this.setState({
encounters : this.state.encounters
});
localStorage.setItem("encounters", JSON.stringify(this.state.encounters));
},
renderSelectedEncounter : function(){
var self = this;
if(this.state.selectedEncounterIndex != null && this.state.encounters[this.state.selectedEncounterIndex]){
var selectedEncounter = this.state.encounters[this.state.selectedEncounterIndex]
return <Encounter
key={selectedEncounter.name}
{...selectedEncounter}
monsterManual={this.state.monsterManual}
players={this.state.players}
/>
}
return null;
},
temp : function(){
Actions.setInc(++this.state.inc);
},
render : function(){
var self = this;
return(
<div className='combatManager'>
<Sidebar
selectedEncounter={this.state.selectedEncounterIndex}
encounters={this.state.encounters}
monsterManual={this.state.monsterManual}
players={this.state.players}
onSelectEncounter={this.handleSelectedEncounterChange}
onRemoveEncounter={this.handleRemoveEncounter}
onJSONChange={this.handleEncounterJSONChange}
onMonsterManualChange={this.handleMonsterManualJSONChange}
onPlayerChange={this.handlePlayerChange}
/>
{this.renderSelectedEncounter()}
<button onClick={this.temp}>YUP {this.state.inc}</button>
</div>
);
}
});
module.exports = CombatManager;

View File

@@ -1,8 +0,0 @@
.combatManager{
.encounterContainer{
display: inline-block;
vertical-align: top;
}
}

View File

@@ -1,162 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Store = require('naturalCrit/combat.store.js');
var MonsterCard = require('./monsterCard/monsterCard.jsx');
var attrMod = function(attr){
return Math.floor(attr/2) - 5;
}
var Encounter = React.createClass({
mixins : [Store.mixin()],
getInitialState: function() {
return {
enemies: this.createEnemies(this.props)
};
},
onStoreChange : function(){
var players = Store.getplayersText();
},
getDefaultProps: function() {
return {
name : '',
desc : '',
reward : '',
enemies : [],
players : '',
unique : {},
monsterManual : {}
};
},
componentWillReceiveProps: function(nextProps) {
this.setState({
enemies : this.createEnemies(nextProps)
})
},
createEnemies : function(props){
var self = this;
return _.indexBy(_.map(props.enemies, function(type, index){
return self.createEnemy(props, type, index)
}), 'id')
},
createEnemy : function(props, type, index){
var stats = props.unique[type] || props.monsterManual[type];
if(!stats) return;
return _.extend({
id : type + index,
name : type,
currentHP : stats.hp,
initiative : _.random(1,20) + attrMod(stats.attr.dex)
}, stats);
},
updateHP : function(enemyId, newHP){
this.state.enemies[enemyId].currentHP = newHP;
this.setState({
enemies : this.state.enemies
});
},
removeEnemy : function(enemyId){
delete this.state.enemies[enemyId];
this.setState({
enemies : this.state.enemies
});
},
getPlayerObjects : function(){
return _.reduce(this.props.players.split('\n'), function(r, line){
var parts = line.split(' ');
if(parts.length != 2) return r;
r.push({
name : parts[0],
initiative : parts[1] * 1,
isPC : true
})
return r;
},[])
},
renderEnemies : function(){
var self = this;
var sortedEnemies = _.sortBy(_.union(_.values(this.state.enemies), this.getPlayerObjects()), function(e){
if(e && e.initiative) return -e.initiative;
return 0;
});
return _.map(sortedEnemies, function(enemy){
if(enemy.isPC){
return <PlayerCard {...enemy} key={enemy.name} />
}
return <MonsterCard
{...enemy}
key={enemy.id}
updateHP={self.updateHP.bind(self, enemy.id)}
remove={self.removeEnemy.bind(self, enemy.id)}
/>
})
},
render : function(){
var self = this;
var reward;
if(this.props.reward){
reward = <div className='reward'>
<i className='fa fa-trophy' /> Rewards: {this.props.reward}
</div>
}
return(
<div className='mainEncounter'>
<div className='info'>
<h1>{this.props.name}</h1>
<p>{this.props.desc}</p>
{reward}
</div>
<div className='cardContainer'>
{this.renderEnemies()}
</div>
</div>
);
}
});
module.exports = Encounter;
var PlayerCard = React.createClass({
getDefaultProps: function() {
return {
name : '',
initiative : 0
};
},
render : function(){
return <div className='playerCard'>
<span className='name'>{_.startCase(this.props.name)}</span>
<span className='initiative'><i className='fa fa-hourglass-2'/>{this.props.initiative}</span>
</div>
},
})

View File

@@ -1,36 +0,0 @@
.mainEncounter{
box-sizing : border-box;
overflow : hidden;
width : auto;
&>.info{
margin-left: 10px;
padding-bottom : 10px;
border-bottom: 1px solid #ddd;
h1{
font-size: 2em;
font-weight: 800;
margin-bottom: 5px;
}
p{
margin-left: 10px;
font-size: 0.8em;
line-height: 1.5em;
max-width: 600px;
}
.reward{
font-size: 0.8em;
font-weight: 800;
margin-top: 5px;
i{
margin-right: 5px;
}
}
}
}

View File

@@ -1,101 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var RollDice = require('naturalCrit/rollDice');
var AttackSlot = React.createClass({
getDefaultProps: function() {
return {
name : '',
uses : null
};
},
getInitialState: function() {
return {
lastRoll: {},
usedCount : 0
};
},
rollDice : function(key, notation){
var res = RollDice(notation);
this.state.lastRoll[key] = res
this.state.lastRoll[key + 'key'] = _.uniqueId(key);
this.setState({
lastRoll : this.state.lastRoll
})
},
renderUses : function(){
var self = this;
if(!this.props.uses) return null;
return _.times(this.props.uses, function(index){
var atCount = index < self.state.usedCount;
return <i
key={index}
className={cx('fa', {'fa-circle-o' : !atCount, 'fa-circle' : atCount})}
onClick={self.updateCount.bind(self, atCount)}
/>
})
},
updateCount : function(used){
this.setState({
usedCount : this.state.usedCount + (used ? -1 : 1)
});
},
renderNotes : function(){
var notes = _.omit(this.props, ['name', 'atk', 'dmg', 'uses', 'heal']);
return _.map(notes, function(text, key){
return <div key={key}>{key + ': ' + text}</div>
});
},
renderRolls : function(){
var self = this;
return _.map(['atk', 'dmg', 'heal'], function(type){
if(!self.props[type]) return null;
return <div className={cx('roll', type)} key={type}>
<button onClick={self.rollDice.bind(self, type, self.props[type])}>
<i className={cx('fa', {
'fa-hand-grab-o' : type=='dmg',
'fa-bullseye' : type=='atk',
'fa-plus' : type=='heal'
})} />
{self.props[type]}
</button>
<span key={self.state.lastRoll[type+'key']}>{self.state.lastRoll[type]}</span>
</div>
})
},
render : function(){
var self = this;
return(
<div className='attackSlot'>
<div className='info'>
<div className='name'>{this.props.name}</div>
<div className='uses'>
{this.renderUses()}
</div>
<div className='notes'>
{this.renderNotes()}
</div>
</div>
<div className='rolls'>
{this.renderRolls()}
</div>
</div>
);
}
});
module.exports = AttackSlot;

View File

@@ -1,71 +0,0 @@
.attackSlot{
//border : 1px solid black;
border-bottom: 1px solid #eee;
margin-bottom : 5px;
font-size : 0.8em;
.info, .rolls{
display : inline-block;
vertical-align : top;
}
.info{
width : 40%;
.name{
font-weight : 800;
margin-bottom: 3px;
}
.notes{
font-size : 0.8em;
}
.uses{
cursor : pointer;
//font-size: 0.8em;
//margin-top: 3px;
}
}
.rolls{
.roll{
margin-bottom : 2px;
&>span{
font-weight: 800;
.fadeInLeft();
}
button{
width : 70px;
margin-right : 5px;
cursor : pointer;
font-size : 0.7em;
font-weight : 800;
text-align : left;
border : none;
outline : 0;
i{
width : 15px;
margin-right : 5px;
border-right : 1px solid white;
}
&:hover{
//text-align: right;
}
}
&.atk{
button{
background-color : fade(@blue, 40%);
i { border-color: @blue}
}
}
&.dmg{
button{
background-color : fade(@red, 40%);
i { border-color: @red}
}
}
&.heal{
button{
background-color : fade(@green, 40%);
i { border-color: @green}
}
}
}
}
}

View File

@@ -1,202 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var AttackSlot = require('./attackSlot/attackSlot.jsx');
var MonsterCard = React.createClass({
getDefaultProps: function() {
return {
name : '',
hp : 1,
currentHP : 1,
ac: 1,
move : 30,
attr : {
str : 8,
con : 8,
dex : 8,
int : 8,
wis : 8,
cha : 8
},
attacks : {},
spells : {},
abilities : [],
items : [],
updateHP : function(){},
remove : function(){},
};
},
getInitialState: function() {
return {
status : 'normal',
usedItems : [],
lastRoll : { },
mousePos : null,
tempHP : 0
};
},
componentDidMount: function() {
window.addEventListener('mousemove', this.handleMouseDrag);
window.addEventListener('mouseup', this.handleMouseUp);
},
handleMouseDown : function(e){
this.setState({
mousePos : {
x : e.pageX,
y : e.pageY,
}
});
e.stopPropagation()
e.preventDefault()
},
handleMouseUp : function(e){
if(!this.state.mousePos) return;
this.props.updateHP(this.props.currentHP + this.state.tempHP);
this.setState({
mousePos : null,
tempHP : 0
});
},
handleMouseDrag : function(e){
if (!this.state.mousePos) return;
var distance = Math.sqrt(Math.pow(e.pageX - this.state.mousePos.x, 2) + Math.pow(e.pageY - this.state.mousePos.y, 2));
var mult = (e.pageY > this.state.mousePos.y ? -1 : 1)
this.setState({
tempHP : Math.floor(distance * mult/25)
})
},
addUsed : function(item, shouldRemove){
if(!shouldRemove) this.state.usedItems.push(item);
if(shouldRemove) this.state.usedItems.splice(this.state.usedItems.indexOf(item), 1);
this.setState({
usedItems : this.state.usedItems
});
},
renderHPBox : function(){
var self = this;
var tempHP
if(this.state.tempHP){
var sign = (this.state.tempHP > 0 ? '+' : '');
tempHP = <span className='tempHP'>{['(',sign,this.state.tempHP,')'].join('')}</span>
}
return <div className='hpBox' onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
<div className='currentHP'>
{tempHP} {this.props.currentHP}
</div>
{self.renderStats()}
</div>
},
renderStats : function(){
var stats = {
'fa fa-shield' : this.props.ac,
//'fa fa-hourglass-2' : this.props.initiative,
}
return _.map(stats, function(val, icon){
return <div className='stat' key={icon}> {val} <i className={icon} /></div>
})
},
renderAttacks : function(){
var self = this;
return _.map(this.props.attacks, function(attack, name){
return <AttackSlot key={name} name={name} {...attack} />
})
},
renderSpells : function(){
var self = this;
return _.map(this.props.spells, function(spell, name){
return <AttackSlot key={name} name={name} {...spell} />
})
},
renderAbilities : function(){
return _.map(this.props.abilities, function(text, name){
return <div className='ability' key={name}>
<span className='name'>{name}</span>: {text}
</div>
});
},
renderItems : function(){
var self = this;
var usedItems = this.state.usedItems.slice(0);
return _.map(this.props.items, function(item, index){
var used = _.contains(usedItems, item);
if(used){
usedItems.splice(usedItems.indexOf(item), 1);
}
return <span
key={index}
className={cx({'used' : used})}
onClick={self.addUsed.bind(self, item, used)}>
{item}
</span>
});
},
render : function(){
var self = this;
var condition = ''
if(this.props.currentHP + this.state.tempHP > this.props.hp) condition='overhealed';
if(this.props.currentHP + this.state.tempHP <= this.props.hp * 0.5) condition='hurt';
if(this.props.currentHP + this.state.tempHP <= this.props.hp * 0.2) condition='last_legs';
if(this.props.currentHP + this.state.tempHP <= 0) condition='dead';
return(
<div className={cx('monsterCard', condition)}>
<div className='healthbar' style={{width : (this.props.currentHP + this.state.tempHP)/this.props.hp*100 + '%'}} />
<div className='overhealbar' style={{width : (this.props.currentHP + this.state.tempHP - this.props.hp)/this.props.hp*100 + '%'}} />
{this.renderHPBox()}
<div className='info'>
<span className='name'>{this.props.name}</span>
</div>
<div className='attackContainer'>
{this.renderAttacks()}
</div>
<div className='spellContainer'>
{this.renderSpells()}
</div>
<div className='abilitiesContainer'>
{this.renderAbilities()}
</div>
<div className='itemContainer'>
<i className='fa fa-flask' />
{this.renderItems()}
</div>
</div>
);
}
});
module.exports = MonsterCard;
/*
{this.props.initiative}
<i className='fa fa-times' onClick={this.props.remove} />
*/

View File

@@ -1,129 +0,0 @@
@marginSize : 10px;
.playerCard{
display : inline-block;
box-sizing : border-box;
margin : @marginSize;
padding : 10px;
background-color : white;
border : 1px solid #bbb;
.name{
margin-right : 20px;
}
.initiative{
font-size : 0.8em;
i{
font-size : 0.8em;
}
}
&:nth-child(5n + 1){ background-color: fade(@blue, 25%); }
&:nth-child(5n + 2){ background-color: fade(@purple, 25%); }
&:nth-child(5n + 3){ background-color: fade(@steel, 25%); }
&:nth-child(5n + 4){ background-color: fade(@green, 25%); }
&:nth-child(5n + 5){ background-color: fade(@orange, 25%); }
}
.monsterCard{
position : relative;
display : inline-block;
vertical-align : top;
box-sizing : border-box;
width : 220px;
margin : @marginSize;
padding : 10px;
background-color : white;
border : 1px solid #bbb;
.healthbar{
position : absolute;
top : 0px;
left : 0px;
z-index : 50;
height : 3px;
max-width : 100%;
background-color : @green;
}
.overhealbar{
position : absolute;
top : 0px;
left : 0px;
z-index : 100;
height : 3px;
max-width : 100%;
background-color : @blueLight;
}
&.hurt{
.healthbar{
background-color : orange;
}
}
&.last_legs{
background-color : lighten(@red, 49%);
.healthbar{
background-color : red;
}
}
&.dead{
opacity : 0.3;
}
&>.info{
margin-bottom : 10px;
.name{
margin-right : 10px;
font-size : 1.5em;
}
.stat{
margin-right : 5px;
font-size : 0.7em;
i{
font-size : 0.7em;
}
}
}
.hpBox{
.noselect();
position : absolute;
top : 5px;
right : 5px;
cursor : pointer;
text-align : right;
.currentHP{
font-size : 2em;
font-weight : 800;
line-height : 0.8em;
.tempHP{
vertical-align : top;
font-size : 0.4em;
line-height : 0.8em;
}
}
.stat{
font-size : 0.8em;
}
.hpText{
font-size : 0.6em;
font-weight : 800;
}
}
.abilitiesContainer{
margin-top : 10px;
.ability{
font-size: 0.7em;
.name{
font-weight: 800;
}
}
}
.itemContainer{
margin-top : 10px;
i{
font-size : 0.7em;
}
span{
margin-right : 5px;
cursor : pointer;
font-size : 0.7em;
&.used{
text-decoration : line-through;
}
}
}
}

View File

@@ -1,59 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var RollDice = require('naturalCrit/rollDice');
var DmDice = React.createClass({
getInitialState: function() {
return {
lastRoll:{ },
diceNotation : {
a : "1d20",
b : "6d6 + 3",
c : "1d20 - 1"
}
};
},
roll : function(id){
this.state.lastRoll[id] = RollDice(this.state.diceNotation[id]);
this.setState({
lastRoll : this.state.lastRoll
});
},
handleChange : function(id, e){
this.state.diceNotation[id] = e.target.value;
this.setState({
diceNotation : this.state.diceNotation
});
e.stopPropagation();
e.preventDefault();
},
renderRolls : function(){
var self = this;
return _.map(['a', 'b', 'c'], function(id){
return <div className='roll' key={id} onClick={self.roll.bind(self, id)}>
<input type="text" value={self.state.diceNotation[id]} onChange={self.handleChange.bind(self, id)} />
<i className='fa fa-random' />
<span key={self.state.lastRoll[id]}>{self.state.lastRoll[id]}</span>
</div>
})
},
render : function(){
var self = this;
return(
<div className='dmDice'>
<h3> <i className='fa fa-random' /> DM Dice </h3>
{this.renderRolls()}
</div>
);
}
});
module.exports = DmDice;

View File

@@ -1,32 +0,0 @@
.dmDice{
h3{
color : white;
background-color: @teal;
}
.roll{
cursor: pointer;
.noselect();
input[type="text"]{
margin-left: 10px;
margin-bottom: 6px;
margin-top: 6px;
width : 60px;
font-family: monospace;
padding : 5px;
}
i.fa-random{
font-size: 0.8em;
margin: 0 10px;
}
span{
font-weight: 800;
.fadeInLeft();
}
&:hover{
background-color: fade(@teal, 20%);
}
}
}

View File

@@ -1,100 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var JSONFileEditor = require('naturalCrit/jsonFileEditor/jsonFileEditor.jsx');
//var GetRandomEncounter = require('naturalCrit/randomEncounter.js');
var Store = require('naturalCrit/combat.store.js');
var Actions = require('naturalCrit/combat.actions.js');
var Encounters = React.createClass({
mixins : [Store.mixin()],
onStoreChange : function(){
this.setState({
encounters : Store.getEncounters(),
selectedEncounter : Store.getSelectedEncounterIndex()
});
},
getInitialState: function() {
return {
encounters : Store.getEncounters(),
selectedEncounter : Store.getSelectedEncounterIndex()
};
},
/*
getDefaultProps: function() {
return {
encounters : [],
selectedEncounter : 0,
onJSONChange : function(encounterIndex, json){},
onSelectEncounter : function(encounterIndex){},
onRemoveEncounter : function(encounterIndex){}
};
},
*/
handleJSONChange : function(encounterIndex, json){
//this.props.onJSONChange(encounterIndex, json);
Actions.updateEncounter(encounterIndex, json);
},
handleSelectEncounter : function(encounterIndex){
//this.props.onSelectEncounter(encounterIndex);
Actions.selectEncounter(encounterIndex);
},
handleRemoveEncounter : function(encounterIndex){
//this.props.onRemoveEncounter(encounterIndex);
Actions.removeEncounter(encounterIndex);
},
addRandomEncounter : function(){
Actions.addEncounter();
},
renderEncounters : function(){
var self = this;
return _.map(this.state.encounters, function(encounter, index){
var isSelected = self.state.selectedEncounter == index;
return <div className={cx('encounter' , {'selected' : isSelected})} key={index}>
<i onClick={self.handleSelectEncounter.bind(self, index)} className={cx('select', 'fa', {
'fa-square-o' : !isSelected,
'fa-check-square-o' : isSelected,
})} />
<JSONFileEditor
name={encounter.name}
json={encounter}
onJSONChange={self.handleJSONChange.bind(self, index)}
/>
<i onClick={self.handleRemoveEncounter.bind(self, index)} className='remove fa fa-times' />
</div>
})
},
render : function(){
var self = this;
return(
<div className='encounters'>
<h3>
<i className='fa fa-flag' /> Encounters
<button className='addEncounter'>
<i className='fa fa-plus' onClick={this.addRandomEncounter}/>
</button>
</h3>
{this.renderEncounters()}
<div className='controls'>
</div>
</div>
);
}
});
module.exports = Encounters;

View File

@@ -1,53 +0,0 @@
.encounters{
margin-bottom : 20px;
h3{
background-color : @red;
color : white;
button{
.animate(color);
float : right;
cursor : pointer;
background-color : transparent;
border : none;
outline : none;
&:hover{
color : white;
}
}
}
.encounter{
position : relative;
padding-left : 15px;
border-left : 0px solid @teal;
.animateAll();
&:hover{
i.remove{
opacity : 1;
}
}
i.remove{
.animate(opacity);
position : absolute;
top : 3px;
right : 3px;
cursor : pointer;
opacity : 0;
font-size : 0.6em;
color : #333;
&:hover{
color : @red;
}
}
i.select{
cursor : pointer;
}
.jsonFileEditor{
display : inline-block;
}
&.selected{
//background-color : fade(@green, 30%);
border-left : 8px solid @teal;
}
}
}

Some files were not shown because too many files have changed in this diff Show More