diff --git a/.circleci/config.yml b/.circleci/config.yml index 461a0dfa6..666a9564a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,12 +5,12 @@ version: 2.1 orbs: - node: circleci/node@3.0.0 + node: circleci/node@5.1.0 jobs: build: docker: - - image: cimg/node:16.11.0 + - image: cimg/node:20.8.0 - image: mongo:4.4 working_directory: ~/homebrewery @@ -27,7 +27,7 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- - - run: sudo npm install -g npm@8.10.0 + - run: sudo npm install -g npm@10.2.0 - node/install-packages: app-dir: ~/homebrewery cache-path: node_modules @@ -45,7 +45,7 @@ jobs: test: docker: - - image: cimg/node:16.11.0 + - image: cimg/node:20.8.0 working_directory: ~/homebrewery parallelism: 1 diff --git a/changelog.md b/changelog.md index 040680ce6..e86c2ea0f 100644 --- a/changelog.md +++ b/changelog.md @@ -75,11 +75,286 @@ pre { .page { padding-bottom: 1.5cm; } + +.varSyntaxTable th:first-of-type { + width:6cm; +} ``` ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Wednesday 21/2/2024 - v3.11.0 +{{taskList + +##### Gazook89 + +* [x] Brew view count no longer increases when viewed by owner + +Fixes issue [#3037](https://github.com/naturalcrit/homebrewery/issues/3037) + +* [x] Small tweak to PHB H3 sizing + +Fixes issue [#2989](https://github.com/naturalcrit/homebrewery/issues/2989) + +* [x] Add **Fold/Unfold All** {{fas,fa-compress-alt}} / {{fas,fa-expand-alt}} buttons to editor bar + +Fixes issue [#2965](https://github.com/naturalcrit/homebrewery/issues/2965) + + +##### G-Ambatte + +* [x] Share link added to Editor Access error page + +Fixes issue [#3086](https://github.com/naturalcrit/homebrewery/issues/3086) + +* [x] Add Darkbrewery theme to Editor theme selector {{fas,fa-palette}} + +Fixes issue [#3034](https://github.com/naturalcrit/homebrewery/issues/3034) + +* [x] Fix Firefox prints with alternating blank pages + +Fixes issue [#3115](https://github.com/naturalcrit/homebrewery/issues/3115) + +* [x] Admin page working again + +Fixes issue [#2657](https://github.com/naturalcrit/homebrewery/issues/2657) + + +##### 5e-Cleric + +* [x] Fix indenting issue with Monster Blocks and italics in Class Feature + +Fixes issues [#527](https://github.com/naturalcrit/homebrewery/issues/527), +[#3247](https://github.com/naturalcrit/homebrewery/issues/3247) + +* [x] Allow CSS vars in curly syntax to be formatted as strings using single quotes + +`{{--customVar:"'a string'"}}` + +Fixes issue [#3066](https://github.com/naturalcrit/homebrewery/issues/3066) + +* [x] Add *Elderberry Inn* icons {{ei,action}} `{{ei,icon-name}}` + +Fixes issue [#3171](https://github.com/naturalcrit/homebrewery/issues/3171) + +* [x] New {{openSans **{{fas,fa-keyboard}} FONTS** }} snippets! + +Fixes issue [#3171](https://github.com/naturalcrit/homebrewery/issues/3171) + +* [x] New page now opens in a new tab + + +##### abquintic (new contributor!) + +* [x] Add ^super^ `^abc^` and ^^sub^^ `^^abc^^` syntax. + +Fixes issue [#2171](https://github.com/naturalcrit/homebrewery/issues/2171) + +* [x] Add HTML tag assignment to curly syntax `{{tag=value}}` + +Fixes issue [1488](https://github.com/naturalcrit/homebrewery/issues/1488) + +* [x] {{openSans **Brew → Clone to New**}} now clones tags + +Fixes issue [1488](https://github.com/naturalcrit/homebrewery/issues/1488) + +##### calculuschild + +* [x] Better error messages for "Out of Google Drive Storage" and "Not logged in to edit" + +Fixes issues [2510](https://github.com/naturalcrit/homebrewery/issues/2510), +[2975](https://github.com/naturalcrit/homebrewery/issues/2975) + +* [x] New Variables syntax. See below for details. +}} + +{{wide + +### Brew Variable Syntax + +You may already be familiar with `[link](url)` and `![image](url)` syntax. We have expanded this to include a third `$[variable](text)` syntax. All three of these syntaxes now share a common set of features: + +{{varSyntaxTable +| syntax | description | +|:-------|-------------| +| `[var]:content` | Assigns a variable (must start on a line by itself, and ends at the next blank line) | +| `[var](content)` | Assigns a variable and outputs it (can be inline) | +| `[var]` | Outputs the variable contents as a link, if formatted as a valid link | +| `![var]` | Outputs as an image, if formatted as a valid image | +| `$[var]` | Outputs as Markdown | +| `$[var1 + var2 - 2 * var3]` | Performs math operations and outputs result if all variables are valid numbers | +}} + +}} + +{{wide,margin-top:0,margin-bottom:0 +### Examples +}} + +{{wide,columns:2,margin-top:0,margin-bottom:0 + +``` +[first]: Bob + +[last]: Jones + +My name is $[first] $[last]. +``` + +\column + +[first]: Bob + +[last]: Jones + +My name is $[first] $[last]. + +}} + +{{wide,columns:2,margin-top:0,margin-bottom:0 + +``` +[myTable]: +| h1 | h2 | +|----|----| +| c1 | c2 | + +Here is my table: +$[myTable] +``` + +\column + +[myTable]: +| h1 | h2 | +|----|----| +| c1 | c2 | + +Here is my table: +$[myTable] +}} + +{{wide,columns:2,margin-top:0,margin-bottom:0 + +``` +There are $[TableNum] tables total. + +#### Table $[TableNum](1): Horses + +#### Table $[TableNum]($[TableNum + 1]): Cows +``` + +\column + +There are $[TableNum] tables in this document. *(note: final value of `$[TableNum]` gets hoisted up if available)* + + +#### Table $[TableNum](1): Horses + +#### Table $[TableNum]($[TableNum + 1]): Cows +}} + +\page + +### Friday 13/10/2023 - v3.10.0 +{{taskList + +##### G-Ambatte + +* [x] Fix user preferred save location being ignored + +Fixes issue [#2993](https://github.com/naturalcrit/homebrewery/issues/2993) + +* [x] Fix crash to white screen when starting new brews while not signed in + +Fixes issue [#2999](https://github.com/naturalcrit/homebrewery/issues/2999) + +* [x] Fix FreeBSD install script + +Fixes issue [#3005](https://github.com/naturalcrit/homebrewery/issues/3005) + +* [x] Fix *"This brew has been changed on another device"* triggering when manually saving during auto-save + +Fixes issue [#2641](https://github.com/naturalcrit/homebrewery/issues/2641) + +* [x] Fix Firefox different column-flow behavior + +Fixes issue [#2982](https://github.com/naturalcrit/homebrewery/issues/2982) + +* [x] Fix brew titles being mis-sorted on user page + +Fixes issue [#2775](https://github.com/naturalcrit/homebrewery/issues/2775) + +* [x] Text Editor themes now available via new drop-down + +Fixes issue [#362](https://github.com/naturalcrit/homebrewery/issues/362) + +##### 5e-Cleric + +* [x] New {{openSans **PHB → {{fas,fa-quote-right}} QUOTE** }} snippet for V3! + +Fixes issue [#2920](https://github.com/naturalcrit/homebrewery/issues/2920) + +* [x] Several updates and fixes to FAQ and Welcome page + +Fixes issue [#2729](https://github.com/naturalcrit/homebrewery/issues/2729), +[#2787](https://github.com/naturalcrit/homebrewery/issues/2787) + +##### Gazook89 + +* [x] Add syntax highlighting for Definition Lists :\: +}} + + +### Thursday 17/08/2023 - v3.9.2 +{{taskList + +##### Calculuschild + +* [x] Fix links to certain old Google Drive files + +Fixes issue [#2917](https://github.com/naturalcrit/homebrewery/issues/2917) + +##### G-Ambatte + +* [x] Menus now open on click, and internally consistent + +Fixes issue [#2702](https://github.com/naturalcrit/homebrewery/issues/2702), [#2782](https://github.com/naturalcrit/homebrewery/issues/2782) + +* [x] Add smarter footer snippet + +Fixes issue [#2289](https://github.com/naturalcrit/homebrewery/issues/2289) + +* [x] Add sanitization in Style editor + +Fixes issue [#1437](https://github.com/naturalcrit/homebrewery/issues/1437) + +* [x] Rework class table snippets to remove unnecessary randomness + +Fixes issue [#2964](https://github.com/naturalcrit/homebrewery/issues/2964) + +* [x] Add User Page link to Google Drive file for file owners, add icons for additional storage locations + +Fixes issue [#2954](https://github.com/naturalcrit/homebrewery/issues/2954) + +* [x] Add default save location selection to Account Page + +Fixes issue [#2943](https://github.com/naturalcrit/homebrewery/issues/2943) + +##### 5e-Cleric + +* [x] Exclude cover pages from Table of Content generation (editing on mobile is still not recommended) + +Fixes issue [#2920](https://github.com/naturalcrit/homebrewery/issues/2920) + +##### Gazook89 + +* [x] Adjustments to improve mobile viewing +}} + + + ### Wednesday 28/06/2023 - v3.9.1 {{taskList @@ -124,6 +399,8 @@ Fixes issue [#2790](https://github.com/naturalcrit/homebrewery/issues/2790) Fixes issue [#2784](https://github.com/naturalcrit/homebrewery/issues/2784) }} +\page + ### Wednesday 12/04/2023 - v3.8.0 {{taskList @@ -185,8 +462,6 @@ Fixes issues [#2731](https://github.com/naturalcrit/homebrewery/issues/2731) }} -\page - ### Monday 13/03/2023 - v3.7.2 {{taskList @@ -267,7 +542,11 @@ Fixes issues [#2603](https://github.com/naturalcrit/homebrewery/issues/2603) * [x] Add message to refresh the browser if the user is missing an update to the Homebrewery Fixes issues [#2583](https://github.com/naturalcrit/homebrewery/issues/2583) +}} +\page + +{{taskList ##### G-Ambatte * [x] Auto-compile Themes CSS on development server @@ -277,7 +556,6 @@ Fixes issues [#2583](https://github.com/naturalcrit/homebrewery/issues/2583) * [x] Fix cloned brews inheriting the parent view count }} -\page ### Friday 23/12/2022 - v3.5.0 {{taskList @@ -1361,4 +1639,4 @@ Massive changelog incoming: * Added `phb.standalone.css` plus a build system for creating it * Added page numbers and footer text -* Page accent now flips each page +* Page accent now flips each page \ No newline at end of file diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 4e5fa3526..f1c9cdeda 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -1,9 +1,8 @@ /*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/ require('./brewRenderer.less'); const React = require('react'); -const createClass = require('create-react-class'); +const { useState, useRef, useEffect } = React; const _ = require('lodash'); -const cx = require('classnames'); const MarkdownLegacy = require('naturalcrit/markdownLegacy.js'); const Markdown = require('naturalcrit/markdown.js'); @@ -13,244 +12,226 @@ const ErrorBar = require('./errorBar/errorBar.jsx'); const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx'); const NotificationPopup = require('./notificationPopup/notificationPopup.jsx'); const Frame = require('react-frame-component').default; +const dedent = require('dedent-tabs').default; const Themes = require('themes/themes.json'); const PAGE_HEIGHT = 1056; -const PPR_THRESHOLD = 50; -const BrewRenderer = createClass({ - displayName : 'BrewRenderer', - getDefaultProps : function() { - return { - text : '', - style : '', - renderer : 'legacy', - theme : '5ePHB', - lang : '', - errors : [] - }; - }, - getInitialState : function() { - let pages; - if(this.props.renderer == 'legacy') { - pages = this.props.text.split('\\page'); - } else { - pages = this.props.text.split(/^\\page$/gm); - } +const INITIAL_CONTENT = dedent` + + + + + +
`; - return { - viewablePageNumber : 0, - height : 0, - isMounted : false, +//v=====----------------------< Brew Page Component >---------------------=====v// +const BrewPage = (props)=>{ + props = { + contents : '', + index : 0, + ...props + }; + return
+
+
; +}; - pages : pages, - usePPR : pages.length >= PPR_THRESHOLD, - visibility : 'hidden', - initialContent : ` - - - - -
` - }; - }, - height : 0, - lastRender :
, - componentWillUnmount : function() { - window.removeEventListener('resize', this.updateSize); - }, +//v=====--------------------< Brew Renderer Component >-------------------=====v// +const renderedPages = []; +let rawPages = []; - componentDidUpdate : function(prevProps) { - if(prevProps.text !== this.props.text) { - let pages; - if(this.props.renderer == 'legacy') { - pages = this.props.text.split('\\page'); - } else { - pages = this.props.text.split(/^\\page$/gm); - } - this.setState({ - pages : pages, - usePPR : pages.length >= PPR_THRESHOLD - }); - } - }, +const BrewRenderer = (props)=>{ + props = { + text : '', + style : '', + renderer : 'legacy', + theme : '5ePHB', + lang : '', + errors : [], + currentEditorPage : 0, + ...props + }; - updateSize : function() { - this.setState({ - height : this.refs.main.parentNode.clientHeight, - }); - }, + const [state, setState] = useState({ + viewablePageNumber : 0, + height : PAGE_HEIGHT, + isMounted : false, + visibility : 'hidden', + }); - handleScroll : function(e){ - const target = e.target; - this.setState((prevState)=>({ - viewablePageNumber : Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length) + const mainRef = useRef(null); + + if(props.renderer == 'legacy') { + rawPages = props.text.split('\\page'); + } else { + rawPages = props.text.split(/^\\page$/gm); + } + + useEffect(()=>{ // Unmounting steps + return ()=>{window.removeEventListener('resize', updateSize);}; + }, []); + + const updateSize = ()=>{ + setState((prevState)=>({ + ...prevState, + height : mainRef.current.parentNode.clientHeight, })); - }, + }; - shouldRender : function(pageText, index){ - if(!this.state.isMounted) return false; + const handleScroll = (e)=>{ + const target = e.target; + setState((prevState)=>({ + ...prevState, + viewablePageNumber : Math.floor(target.scrollTop / target.scrollHeight * rawPages.length) + })); + }; - 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; + const isInView = (index)=>{ + if(!state.isMounted) + return false; - //Check for style tages - if(pageText.indexOf('` }} />; + const renderStyle = ()=>{ + if(!props.style) return; + const cleanStyle = sanitizeScriptTags(props.style); + //return
@layer styleTab {\n${sanitizeScriptTags(props.style)}\n} ` }} />; return
${cleanStyle} ` }} />; - }, + }; - renderPage : function(pageText, index){ - const cleanPageText = this.sanitizeScriptTags(pageText); - if(this.props.renderer == 'legacy') - return
; - else { - pageText += `\n\n \n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear) - return ( -
-
-
- ); + const renderPage = (pageText, index)=>{ + let cleanPageText = sanitizeScriptTags(pageText); + if(props.renderer == 'legacy') { + const html = MarkdownLegacy.render(cleanPageText); + return ; + } else { + cleanPageText += `\n\n \n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear) + const html = Markdown.render(cleanPageText, index); + return ; } - }, + }; - renderPages : function(){ - if(this.state.usePPR){ - return _.map(this.state.pages, (page, index)=>{ - if(this.shouldRender(page, index) && typeof window !== 'undefined'){ - 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)=>{ - if(typeof window !== 'undefined') { - return this.renderPage(page, index); - } else { - return this.renderDummyPage(index); + const renderPages = ()=>{ + if(props.errors && props.errors.length) + return renderedPages; + + if(rawPages.length != renderedPages.length) // Re-render all pages when page count changes + renderedPages.length = 0; + + // Render currently-edited page first so cross-page effects (variables, links) can propagate out first + renderedPages[props.currentEditorPage] = renderPage(rawPages[props.currentEditorPage], props.currentEditorPage); + + _.forEach(rawPages, (page, index)=>{ + if((isInView(index) || !renderedPages[index]) && typeof window !== 'undefined'){ + renderedPages[index] = renderPage(page, index); // Render any page not yet rendered, but only re-render those in PPR range } }); - return this.lastRender; - }, + return renderedPages; + }; - frameDidMount : function(){ //This triggers when iFrame finishes internal "componentDidMount" + const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount" setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame - this.updateSize(); - window.addEventListener('resize', this.updateSize); - this.renderPages(); //Make sure page is renderable before showing - this.setState({ + updateSize(); + window.addEventListener('resize', updateSize); + renderPages(); //Make sure page is renderable before showing + setState((prevState)=>({ + ...prevState, isMounted : true, visibility : 'visible' - }); + })); }, 100); - }, + }; - emitClick : function(){ - // console.log('iFrame clicked'); + const emitClick = ()=>{ // Allow clicks inside iFrame to interact with dropdowns, etc. from outside if(!window || !document) return; document.dispatchEvent(new MouseEvent('click')); - }, + }; - render : function(){ - //render in iFrame so broken code doesn't crash the site. - //Also render dummy page while iframe is mounting. - const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy'; - const themePath = this.props.theme ?? '5ePHB'; - const baseThemePath = Themes[rendererPath][themePath].baseTheme; - return ( - - {!this.state.isMounted - ?
-
- {this.renderDummyPage(1)} -
+ const rendererPath = props.renderer == 'V3' ? 'V3' : 'Legacy'; + const themePath = props.theme ?? '5ePHB'; + const baseThemePath = Themes[rendererPath][themePath].baseTheme; + + return ( + <> + {/*render dummy page while iFrame is mounting.*/} + {!state.isMounted + ?
+
+ {renderDummyPage(1)}
- : null} +
+ : null} - {this.emitClick();}} - > -
+ {/*render in iFrame so broken code doesn't crash the site.*/} + {emitClick();}} + > +
- -
- - -
- - {baseThemePath && - - } - - {/* Apply CSS from Style tab and render pages from Markdown tab */} - {this.state.isMounted - && - <> - {this.renderStyle()} -
- {this.renderPages()} -
- - } + +
+ +
- - {this.renderPageInfo()} - {this.renderPPRmsg()} - - ); - } -}); + + {baseThemePath && + + } + + + {/* Apply CSS from Style tab and render pages from Markdown tab */} + {state.isMounted + && + <> + {renderStyle()} +
+ {renderPages()} +
+ + } +
+ + {renderPageInfo()} + + ); +}; module.exports = BrewRenderer; diff --git a/client/homebrew/brewRenderer/brewRenderer.less b/client/homebrew/brewRenderer/brewRenderer.less index bde91c92e..17aa146fb 100644 --- a/client/homebrew/brewRenderer/brewRenderer.less +++ b/client/homebrew/brewRenderer/brewRenderer.less @@ -1,46 +1,44 @@ @import (multiple, less) 'shared/naturalcrit/styles/reset.less'; -.brewRenderer{ +.brewRenderer { will-change : transform; overflow-y : scroll; - .pages{ + :where(.pages) { margin : 30px 0px; - &>.page{ + & > :where(.page) { + width : 215.9mm; + height : 279.4mm; margin-right : auto; margin-bottom : 30px; margin-left : auto; - box-shadow : 1px 4px 14px #000; + box-shadow : 1px 4px 14px #000000; } } } -.pane{ - position : relative; -} -.pageInfo{ +.pane { position : relative; } +.pageInfo { position : absolute; right : 17px; bottom : 0; z-index : 1000; - background-color : #333; font-size : 10px; font-weight : 800; color : white; + background-color : #333333; div { - display: inline-block; + display : inline-block; padding : 8px 10px; - &:not(:last-child){ - border-right: 1px solid #666; - } + &:not(:last-child) { border-right : 1px solid #666666; } } } -.ppr_msg{ +.ppr_msg { position : absolute; - left : 0px; bottom : 0; + left : 0px; z-index : 1000; padding : 8px 10px; - background-color : #333; font-size : 10px; font-weight : 800; color : white; + background-color : #333333; } diff --git a/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx b/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx index 3c706d6f7..5a870c108 100644 --- a/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx +++ b/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx @@ -25,13 +25,10 @@ const NotificationPopup = createClass({ return ( <>
  • - Broken default logo on CoverPage
    - If you have used the Cover Page snippet and notice the Naturalcrit - logo is showing as a broken image, this is due to some small tweaks - of this BETA feature. To fix the logo in your cover page, rename - the image link "/assets/naturalCritLogoRed.svg". Remember - that any snippet marked "BETA" may have a similar change in the - future as we encounter any bugs or reworks. + Don't store IMAGES in Google Drive
    + Google Drive is not an image service, and will block images from being used + in brews if they get more views than expected. Google has confirmed they won't fix + this, so we recommend you look for another image hosting service such as imgur, ImgBB or Google Photos.
  • diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index ed8cb87d5..d79d2ce4e 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -10,6 +10,8 @@ const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx'); const SnippetBar = require('./snippetbar/snippetbar.jsx'); const MetadataEditor = require('./metadataEditor/metadataEditor.jsx'); +const EDITOR_THEME_KEY = 'HOMEBREWERY-EDITOR-THEME'; + const SNIPPETBAR_HEIGHT = 25; const DEFAULT_STYLE_TEXT = dedent` /*=======--- Example CSS styling ---=======*/ @@ -34,12 +36,14 @@ const Editor = createClass({ onMetaChange : ()=>{}, reportError : ()=>{}, - renderer : 'legacy' + editorTheme : 'default', + renderer : 'legacy' }; }, getInitialState : function() { return { - view : 'text' //'text', 'style', 'meta' + editorTheme : this.props.editorTheme, + view : 'text' //'text', 'style', 'meta' }; }, @@ -51,6 +55,13 @@ const Editor = createClass({ this.updateEditorSize(); this.highlightCustomMarkdown(); window.addEventListener('resize', this.updateEditorSize); + + const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY); + if(editorTheme) { + this.setState({ + editorTheme : editorTheme + }); + } }, componentWillUnmount : function() { @@ -138,9 +149,38 @@ const Editor = createClass({ codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); } + // definition lists + if(line.includes('::')){ + const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; + let match; + while ((match = regex.exec(line)) != null){ + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[0]) }, { line: lineNumber, ch: line.indexOf(match[0]) + match[0].length }, { className: 'define' }); + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'term' }); + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[2]) }, { line: lineNumber, ch: line.indexOf(match[2]) + match[2].length }, { className: 'definition' }); + } + } + + // Superscript + if(line.includes('\^')) { + const regex = /\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/g; + let match; + while ((match = regex.exec(line)) != null) { + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) - 1 }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length + 1 }, { className: 'superscript' }); + } + } + + // Subscript + if(line.includes('^^')) { + const regex = /\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/g; + let match; + while ((match = regex.exec(line)) != null) { + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) - 2 }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length + 2 }, { className: 'subscript' }); + } + } + // Highlight injectors {style} if(line.includes('{') && line.includes('}')){ - const regex = /(?:^|[^{\n])({(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\2})/gm; + const regex = /(?:^|[^{\n])({(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\2})/gm; let match; while ((match = regex.exec(line)) != null) { codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'injection' }); @@ -148,7 +188,7 @@ const Editor = createClass({ } // Highlight inline spans {{content}} if(line.includes('{{') && line.includes('}}')){ - const regex = /{{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1 *|}}/g; + const regex = /{{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1 *|}}/g; let match; let blockCount = 0; while ((match = regex.exec(line)) != null) { @@ -167,7 +207,7 @@ const Editor = createClass({ // Highlight block divs {{\n Content \n}} let endCh = line.length+1; - const match = line.match(/^ *{{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1 *$|^ *}}$/); + const match = line.match(/^ *{{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1 *$|^ *}}$/); if(match) endCh = match.index+match[0].length; codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' }); @@ -255,6 +295,13 @@ const Editor = createClass({ this.refs.codeEditor?.updateSize(); }, + updateEditorTheme : function(newTheme){ + window.localStorage.setItem(EDITOR_THEME_KEY, newTheme); + this.setState({ + editorTheme : newTheme + }); + }, + //Called by CodeEditor after document switch, so Snippetbar can refresh UndoHistory rerenderParent : function (){ this.forceUpdate(); @@ -269,6 +316,7 @@ const Editor = createClass({ view={this.state.view} value={this.props.brew.text} onChange={this.props.onTextChange} + editorTheme={this.state.editorTheme} rerenderParent={this.rerenderParent} /> ; } @@ -281,6 +329,7 @@ const Editor = createClass({ value={this.props.brew.style ?? DEFAULT_STYLE_TEXT} onChange={this.props.onStyleChange} enableFolding={false} + editorTheme={this.state.editorTheme} rerenderParent={this.rerenderParent} /> ; } @@ -310,6 +359,14 @@ const Editor = createClass({ return this.refs.codeEditor?.undo(); }, + foldCode : function(){ + return this.refs.codeEditor?.foldAllCode(); + }, + + unfoldCode : function(){ + return this.refs.codeEditor?.unfoldAllCode(); + }, + render : function(){ return (
    @@ -323,7 +380,11 @@ const Editor = createClass({ theme={this.props.brew.theme} undo={this.undo} redo={this.redo} + foldCode={this.foldCode} + unfoldCode={this.unfoldCode} historySize={this.historySize()} + currentEditorTheme={this.state.editorTheme} + updateEditorTheme={this.updateEditorTheme} cursorPos={this.refs.codeEditor?.getCursorPosition() || {}} /> {this.renderEditor()} diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 86e523a13..b165f91db 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -1,65 +1,85 @@ - -.editor{ +@import 'themes/codeMirror/customEditorStyles.less'; +.editor { position : relative; width : 100%; - .codeEditor{ + .codeEditor { height : 100%; - .pageLine{ + .pageLine { background : #33333328; - border-top : #339 solid 1px; + border-top : #333399 solid 1px; } - .editor-page-count{ - color : grey; + .editor-page-count { float : right; + color : grey; } - .columnSplit{ - font-style : italic; - color : grey; - background-color : fade(#299, 15%); - border-bottom : #299 solid 1px; + .columnSplit { + font-style : italic; + color : grey; + background-color : fade(#229999, 15%); + border-bottom : #229999 solid 1px; } - .block:not(.cm-comment){ - color : purple; + .define { + &:not(.term):not(.definition) { + font-weight : bold; + color : #949494; + background : #E5E5E5; + border-radius : 3px; + } + &.term { color : rgb(96, 117, 143); } + &.definition { color : rgb(97, 57, 178); } + } + .block:not(.cm-comment) { font-weight : bold; + color : purple; //font-style: italic; } - .inline-block:not(.cm-comment){ - color : red; + .inline-block:not(.cm-comment) { font-weight : bold; + color : red; //font-style: italic; } - .injection:not(.cm-comment){ + .injection:not(.cm-comment) { + font-weight : bold; color : green; - font-weight : bold; + } + .superscript:not(.cm-comment) { + font-weight : bold; + color : goldenrod; + vertical-align : super; + font-size : 0.9em; + } + .subscript:not(.cm-comment) { + font-weight : bold; + color : rgb(123, 123, 15); + vertical-align : sub; + font-size : 0.9em; } } - .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"); + .brewJump { + position : absolute; + right : 20px; + bottom : 20px; + z-index : 1000000; + display : flex; + align-items : center; + justify-content : center; + width : 30px; + height : 30px; + cursor : pointer; + background-color : @teal; + .tooltipLeft('Jump to brew page'); } - .editorToolbar{ - position: absolute; - top: 5px; - left: 50%; - color: black; - font-size: 13px; - z-index: 9; - span { - padding: 2px 5px; - } + .editorToolbar { + position : absolute; + top : 5px; + left : 50%; + z-index : 9; + font-size : 13px; + color : black; + span { padding : 2px 5px; } } } diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.less b/client/homebrew/editor/metadataEditor/metadataEditor.less index 5678c2554..7f7ce3060 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.less +++ b/client/homebrew/editor/metadataEditor/metadataEditor.less @@ -2,7 +2,7 @@ .metadataEditor{ position : absolute; - z-index : 10000; + z-index : 5; box-sizing : border-box; width : 100%; padding : 25px; diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index fee1a5780..75fe0d736 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -1,3 +1,4 @@ +/*eslint max-lines: ["warn", {"max": 250, "skipBlankLines": true, "skipComments": true}]*/ require('./snippetbar.less'); const React = require('react'); const createClass = require('create-react-class'); @@ -15,6 +16,8 @@ ThemeSnippets['V3_5eDMG'] = require('themes/V3/5eDMG/snippets.js'); ThemeSnippets['V3_Journal'] = require('themes/V3/Journal/snippets.js'); ThemeSnippets['V3_Blank'] = require('themes/V3/Blank/snippets.js'); +const EditorThemes = require('build/homebrew/codeMirror/editorThemes.json'); + const execute = function(val, props){ if(_.isFunction(val)) return val(props); return val; @@ -24,24 +27,28 @@ const Snippetbar = createClass({ displayName : 'SnippetBar', getDefaultProps : function() { return { - brew : {}, - view : 'text', - onViewChange : ()=>{}, - onInject : ()=>{}, - onToggle : ()=>{}, - showEditButtons : true, - renderer : 'legacy', - undo : ()=>{}, - redo : ()=>{}, - historySize : ()=>{}, - cursorPos : {} + brew : {}, + view : 'text', + onViewChange : ()=>{}, + onInject : ()=>{}, + onToggle : ()=>{}, + showEditButtons : true, + renderer : 'legacy', + undo : ()=>{}, + redo : ()=>{}, + historySize : ()=>{}, + foldCode : ()=>{}, + unfoldCode : ()=>{}, + updateEditorTheme : ()=>{}, + cursorPos : {} }; }, getInitialState : function() { return { - renderer : this.props.renderer, - snippets : [] + renderer : this.props.renderer, + themeSelector : false, + snippets : [] }; }, @@ -67,6 +74,7 @@ const Snippetbar = createClass({ } }, + mergeCustomizer : function(valueA, valueB, key) { if(key == 'snippets') { const result = _.reverse(_.unionBy(_.reverse(valueB), _.reverse(valueA), 'name')); // Join snippets together, with preference for the current theme over the base theme @@ -95,6 +103,33 @@ const Snippetbar = createClass({ this.props.onInject(injectedText); }, + toggleThemeSelector : function(e){ + if(e.target.tagName != 'SELECT'){ + this.setState({ + themeSelector : !this.state.themeSelector + }); + } + }, + + changeTheme : function(e){ + if(e.target.value == this.props.currentEditorTheme) return; + this.props.updateEditorTheme(e.target.value); + + this.setState({ + showThemeSelector : false, + }); + }, + + renderThemeSelector : function(){ + return
    + +
    ; + }, + renderSnippetGroups : function(){ const snippets = this.state.snippets.filter((snippetGroup)=>snippetGroup.view === this.props.view); @@ -114,6 +149,22 @@ const Snippetbar = createClass({ renderEditorButtons : function(){ if(!this.props.showEditButtons) return; + let foldButtons; + if(this.props.view == 'text'){ + foldButtons = + <> +
    + +
    +
    + +
    + + + } + return
    @@ -123,6 +174,14 @@ const Snippetbar = createClass({ onClick={this.props.redo} >
    +
    + {foldButtons} +
    + + {this.state.themeSelector && this.renderThemeSelector()} +
    +
    this.props.onViewChange('text')}> @@ -173,7 +232,7 @@ const SnippetGroup = createClass({ return _.map(snippets, (snippet)=>{ return
    this.handleSnippetClick(e, snippet)}> - {snippet.name} + {snippet.name} {snippet.experimental && beta} {snippet.subsnippets && <> @@ -196,5 +255,4 @@ const SnippetGroup = createClass({
    ; }, - }); diff --git a/client/homebrew/editor/snippetbar/snippetbar.less b/client/homebrew/editor/snippetbar/snippetbar.less index cb24da105..be6ebe11a 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.less +++ b/client/homebrew/editor/snippetbar/snippetbar.less @@ -1,144 +1,190 @@ @import (less) './client/icons/customIcons.less'; -.snippetBar{ +@import (less) '././././themes/fonts/5e/fonts.less'; + +.snippetBar { @menuHeight : 25px; position : relative; height : @menuHeight; - background-color : #ddd; - .editors{ + color : black; + background-color : #DDDDDD; + + .editors { position : absolute; - display : flex; top : 0px; right : 0px; - height : @menuHeight; - width : 125px; + display : flex; justify-content : space-between; - &>div{ - height : @menuHeight; + height : @menuHeight; + & > div { width : @menuHeight; - cursor : pointer; + height : @menuHeight; line-height : @menuHeight; text-align : center; - &:hover,&.selected{ - background-color : #999; - } - &.text{ + cursor : pointer; + &:hover,&.selected { background-color : #999999; } + &.text { .tooltipLeft('Brew Editor'); } - &.style{ + &.style { .tooltipLeft('Style Editor'); } - &.meta{ + &.meta { .tooltipLeft('Properties'); } - &.undo{ + &.undo { .tooltipLeft('Undo'); font-size : 0.75em; color : grey; - &.active{ - color : black; - } + &.active { color : inherit; } } - &.redo{ + &.redo { .tooltipLeft('Redo'); font-size : 0.75em; color : grey; - &.active{ - color : black; + &.active { color : inherit; } + } + &.foldAll { + .tooltipLeft('Fold All'); + font-size : 0.75em; + color : inherit; + } + &.unfoldAll { + .tooltipLeft('Unfold All'); + font-size : 0.75em; + color : inherit; + } + &.editorTheme { + .tooltipLeft('Editor Themes'); + font-size : 0.75em; + color : black; + &.active { + position : relative; + background-color : #999999; } } &.divider { - background: linear-gradient(#000, #000) no-repeat center/1px 100%; - width: 5px; - &:hover{ - background-color: inherit; - } + width : 5px; + background : linear-gradient(currentColor, currentColor) no-repeat center/1px 100%; + &:hover { background-color : inherit; } } } + .themeSelector { + position : absolute; + top : 25px; + right : 0; + z-index : 10; + display : flex; + align-items : center; + justify-content : center; + width : 170px; + height : inherit; + background-color : inherit; + } } - .snippetBarButton{ - height : @menuHeight; - line-height : @menuHeight; + .snippetBarButton { display : inline-block; + height : @menuHeight; padding : 0px 5px; - font-weight : 800; font-size : 0.625em; + font-weight : 800; + line-height : @menuHeight; text-transform : uppercase; cursor : pointer; - &:hover, &.selected{ - background-color : #999; - } - i{ - vertical-align : middle; + &:hover, &.selected { background-color : #999999; } + i { margin-right : 3px; font-size : 1.4em; + vertical-align : middle; } } - .toggleMeta{ - position : absolute; - top : 0px; - right : 0px; - border-left : 1px solid black; - .tooltipLeft("Edit Brew Properties"); + .toggleMeta { + position : absolute; + top : 0px; + right : 0px; + border-left : 1px solid black; + .tooltipLeft('Edit Brew Properties'); } - .snippetGroup{ - border-right : 1px solid black; - &:hover{ - &>.dropdown{ - visibility : visible; - } + .snippetGroup { + border-right : 1px solid currentColor; + &:hover { + & > .dropdown { visibility : visible; } } - .dropdown{ + .dropdown { position : absolute; top : 100%; - visibility : hidden; z-index : 1000; - margin-left : -5px; padding : 0px; - background-color : #ddd; - .snippet{ - position: relative; - .animate(background-color); + margin-left : -5px; + visibility : hidden; + background-color : #DDDDDD; + .snippet { + position : relative; display : flex; align-items : center; min-width : max-content; padding : 5px; - cursor : pointer; font-size : 10px; - i{ + cursor : pointer; + .animate(background-color); + i { + height : 1.2em; margin-right : 8px; font-size : 1.2em; - height : 1.2em; - &~i{ - margin-right: 0; - margin-left: 5px; + & ~ i { + margin-right : 0; + margin-left : 5px; + } + /* Fonts */ + &.font { + height : auto; + &::before { + font-size : 1.4em; + content : 'ABC'; + } + + &.OpenSans {font-family : 'OpenSans';} + &.CodeBold {font-family : 'CodeBold';} + &.CodeLight {font-family : 'CodeLight';} + &.ScalySansRemake {font-family : 'ScalySansRemake';} + &.BookInsanityRemake {font-family : 'BookInsanityRemake';} + &.MrEavesRemake {font-family : 'MrEavesRemake';} + &.SolberaImitationRemake {font-family : 'SolberaImitationRemake';} + &.ScalySansSmallCapsRemake {font-family : 'ScalySansSmallCapsRemake';} + &.WalterTurncoat {font-family : 'WalterTurncoat';} + &.Lato {font-family : 'Lato';} + &.Courier {font-family : 'Courier';} + &.NodestoCapsCondensed {font-family : 'NodestoCapsCondensed';} + &.Overpass {font-family : 'Overpass';} + &.Davek {font-family : 'Davek';} + &.Iokharic {font-family : 'Iokharic';} + &.Rellanic {font-family : 'Rellanic';} + &.TimesNewRoman {font-family : 'Times New Roman';} } } - .name { - margin-right : auto; - } + .name { margin-right : auto; } .beta { - color : white; - padding : 4px 6px; - line-height : 1em; - margin-left : 5px; align-self : center; + padding : 4px 6px; + margin-left : 5px; + font-family : monospace; + line-height : 1em; + color : white; background : grey; border-radius : 12px; - font-family : monospace; } - &:hover{ - background-color : #999; - &>.dropdown{ + &:hover { + background-color : #999999; + & > .dropdown { visibility : visible; &.side { - left: 100%; - top: 0%; - margin-left:0; - box-shadow: -1px 1px 2px 0px #999; + top : 0%; + left : 100%; + margin-left : 0; + box-shadow : -1px 1px 2px 0px #999999; } } } } } } -} +} \ No newline at end of file diff --git a/client/homebrew/navbar/error-navitem.jsx b/client/homebrew/navbar/error-navitem.jsx index eb2872c22..8551408c5 100644 --- a/client/homebrew/navbar/error-navitem.jsx +++ b/client/homebrew/navbar/error-navitem.jsx @@ -21,10 +21,11 @@ const ErrorNavItem = createClass({ this.props.parent.setState(state); }; - const error = this.props.error; - const response = error.response; - const status = response.status; - const message = response.body?.message; + const error = this.props.error; + const response = error.response; + const status = response.status; + const HBErrorCode = response.body?.HBErrorCode; + const message = response.body?.message; let errMsg = ''; try { errMsg += `${error.toString()}\n\n`; @@ -40,7 +41,9 @@ const ErrorNavItem = createClass({ {message ?? 'Conflict: please refresh to get latest changes'}
    ; - } else if(status === 412) { + } + + if(status === 412) { return Oops!
    @@ -48,6 +51,36 @@ const ErrorNavItem = createClass({
    ; } + + if(HBErrorCode === '04') { + return + Oops! +
    + You are no longer signed in as an author of + this brew! Were you signed out from a different + window? Visit our log in page, then try again! +

    + +
    + Sign In +
    +
    +
    + Not Now +
    +
    +
    ; + } + + if(response.body?.errors?.[0].reason == 'storageQuotaExceeded') { + return + Oops! +
    + Can't save because your Google Drive seems to be full! +
    +
    ; + } if(response.req.url.match(/^\/api.*Google.*$/m)){ return @@ -57,6 +90,7 @@ const ErrorNavItem = createClass({ expired! Visit our log in page to sign out and sign back in with Google, then try saving again! +

    diff --git a/client/homebrew/navbar/newbrew.navitem.jsx b/client/homebrew/navbar/newbrew.navitem.jsx index 2cbbce466..cc833013d 100644 --- a/client/homebrew/navbar/newbrew.navitem.jsx +++ b/client/homebrew/navbar/newbrew.navitem.jsx @@ -4,6 +4,7 @@ const Nav = require('naturalcrit/nav/nav.jsx'); module.exports = function(props){ return new diff --git a/client/homebrew/pages/accountPage/accountPage.jsx b/client/homebrew/pages/accountPage/accountPage.jsx index 77f246a8b..d08832427 100644 --- a/client/homebrew/pages/accountPage/accountPage.jsx +++ b/client/homebrew/pages/accountPage/accountPage.jsx @@ -16,6 +16,8 @@ const HelpNavItem = require('../../navbar/help.navitem.jsx'); const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx'); +let SAVEKEY = ''; + const AccountPage = createClass({ displayName : 'AccountPage', getDefaultProps : function() { @@ -29,6 +31,27 @@ const AccountPage = createClass({ uiItems : this.props.uiItems }; }, + componentDidMount : function(){ + if(!this.state.saveLocation && this.props.uiItems.username) { + SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${this.props.uiItems.username}`; + let saveLocation = window.localStorage.getItem(SAVEKEY); + saveLocation = saveLocation ?? (this.state.uiItems.googleId ? 'GOOGLE-DRIVE' : 'HOMEBREWERY'); + this.makeActive(saveLocation); + } + }, + + makeActive : function(newSelection){ + if(this.state.saveLocation == newSelection) return; + window.localStorage.setItem(SAVEKEY, newSelection); + this.setState({ + saveLocation : newSelection + }); + }, + + renderButton : function(name, key, shouldRender=true){ + if(!shouldRender) return; + return ; + }, renderNavItems : function() { return @@ -61,6 +84,11 @@ const AccountPage = createClass({

    }
    +
    +

    Default Save Location

    + {this.renderButton('Homebrewery', 'HOMEBREWERY')} + {this.renderButton('Google Drive', 'GOOGLE-DRIVE', this.state.uiItems.googleId)} +
    ; }, diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx index 99bcc9351..90f9d32f2 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx @@ -7,6 +7,7 @@ const moment = require('moment'); const request = require('../../../../utils/request-middleware.js'); const googleDriveIcon = require('../../../../googleDrive.svg'); +const homebreweryIcon = require('../../../../thumbnail.png'); const dedent = require('dedent-tabs').default; const BrewItem = createClass({ @@ -90,11 +91,17 @@ const BrewItem = createClass({
    ; }, - renderGoogleDriveIcon : function(){ - if(!this.props.brew.googleId) return; + renderStorageIcon : function(){ + if(this.props.brew.googleId) { + return + + googleDriveIcon + + ; + } - return - googleDriveIcon + return + homebreweryIcon ; }, @@ -118,7 +125,7 @@ const BrewItem = createClass({
    {brew.tags?.length ? <> -
    +
    {brew.tags.map((tag, idx)=>{ const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/); @@ -128,7 +135,11 @@ const BrewItem = createClass({ : <> } - {brew.authors?.join(', ')} + {brew.authors?.map((author, index)=>( + <> + {author} + {index < brew.authors.length - 1 && ', '} + ))}
    @@ -144,7 +155,7 @@ const BrewItem = createClass({ Last updated: ${moment(brew.updatedAt).local().format(dateFormatString)}`}> {moment(brew.updatedAt).fromNow()} - {this.renderGoogleDriveIcon()} + {this.renderStorageIcon()}
    diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less index da46eeb01..5a1bb3d92 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less @@ -48,6 +48,10 @@ &>span{ margin-right : 12px; line-height : 1.5em; + + a { + color:inherit; + } } } .brewTags span { @@ -98,4 +102,11 @@ padding : 0px; margin : -5px; } + .homebreweryIcon { + mix-blend-mode : darken; + height : 24px; + position : relative; + top : 5px; + left : -5px; + } } diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 86570ec46..d0cd11ec6 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -89,7 +89,7 @@ const ListPage = createClass({ sortBrewOrder : function(brew){ if(!brew.title){brew.title = 'No Title';} const mapping = { - 'alpha' : _.deburr(brew.title.toLowerCase()), + 'alpha' : _.deburr(brew.title.trim().toLowerCase()), 'created' : moment(brew.createdAt).format(), 'updated' : moment(brew.updatedAt).format(), 'views' : brew.views, @@ -220,6 +220,7 @@ const ListPage = createClass({ render : function(){ return
    {/**/} + {this.props.navItems} {this.renderSortOptions()} diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index bcffbf3e7..00d753429 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -2,17 +2,18 @@ .noColumns(){ column-count : auto; column-fill : auto; - column-gap : auto; + column-gap : normal; 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; + -webkit-column-gap : normal; + -moz-column-gap : normal; height : auto; min-height : 279.4mm; margin : 20px auto; + contain : unset; } .listPage{ .content{ diff --git a/client/homebrew/pages/basePages/uiPage/uiPage.less b/client/homebrew/pages/basePages/uiPage/uiPage.less index fc5ed583d..913c74a2e 100644 --- a/client/homebrew/pages/basePages/uiPage/uiPage.less +++ b/client/homebrew/pages/basePages/uiPage/uiPage.less @@ -16,6 +16,23 @@ margin : 5px 0px; border : 2px solid black; border-radius : 5px; + button { + background-color : transparent; + border : 1px solid black; + border-radius : 5px; + width : 125px; + color : black; + margin-right : 5px; + &.active { + background-color: #0007; + color: white; + &:before { + content: '\f00c'; + font-family: 'FONT AWESOME 5 FREE'; + margin-right: 5px; + } + } + } } h1, h2, h3, h4 { width : 100%; diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 4f2e8f8a2..d5af310b5 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -50,7 +50,8 @@ const EditPage = createClass({ url : '', autoSave : true, autoSaveWarning : false, - unsavedTime : new Date() + unsavedTime : new Date(), + currentEditorPage : 0 }; }, savedBrew : null, @@ -91,7 +92,7 @@ const EditPage = createClass({ if(!(e.ctrlKey || e.metaKey)) return; const S_KEY = 83; const P_KEY = 80; - if(e.keyCode == S_KEY) this.save(); + if(e.keyCode == S_KEY) this.trySave(true); if(e.keyCode == P_KEY) window.open(`/print/${this.processShareId()}?dialog=true`, '_blank').focus(); if(e.keyCode == P_KEY || e.keyCode == S_KEY){ e.stopPropagation(); @@ -109,9 +110,10 @@ const EditPage = createClass({ if(htmlErrors.length) htmlErrors = Markdown.validate(text); this.setState((prevState)=>({ - brew : { ...prevState.brew, text: text }, - isPending : true, - htmlErrors : htmlErrors + brew : { ...prevState.brew, text: text }, + isPending : true, + htmlErrors : htmlErrors, + currentEditorPage : this.refs.editor.getCurrentPage() - 1 //Offset index since Marked starts pages at 0 }), ()=>{if(this.state.autoSave) this.trySave();}); }, @@ -137,13 +139,14 @@ const EditPage = createClass({ return !_.isEqual(this.state.brew, this.savedBrew); }, - trySave : function(){ + trySave : function(immediate=false){ if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT); if(this.hasChanges()){ this.debounceSave(); } else { this.debounceSave.cancel(); } + if(immediate) this.debounceSave.flush(); }, handleGoogleClick : function(){ @@ -404,6 +407,7 @@ const EditPage = createClass({ theme={this.state.brew.theme} errors={this.state.htmlErrors} lang={this.state.brew.lang} + currentEditorPage={this.state.currentEditorPage} />
    diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index a7e61d08d..c2de04142 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -22,18 +22,18 @@ const errorIndex = (props)=>{ ## We can't find this brew in Google Drive! This file was saved on Google Drive, but this link doesn't work anymore. - ${ props.brew.authors?.length > 0 - ? `Note that this brew belongs to the Homebrewery account **${ props.brew.authors[0] }**, - ${ props.brew.account - ? `which is + ${props.brew.authors?.length > 0 + ? `Note that this brew belongs to the Homebrewery account **${props.brew.authors[0]}**, + ${props.brew.account + ? `which is ${props.brew.authors[0] == props.brew.account - ? `your account.` - : `not your account (you are currently signed in as **${props.brew.account}**).` - }` - : 'and you are not currently signed in to any account.' - }` - : '' - } + ? `your account.` + : `not your account (you are currently signed in as **${props.brew.account}**).` +}` + : 'and you are not currently signed in to any account.' +}` + : '' +} The Homebrewery cannot delete files from Google Drive on its own, so there are three most likely possibilities: : @@ -75,7 +75,9 @@ const errorIndex = (props)=>{ **Brew Title:** ${props.brew.brewTitle || 'Unable to show title'} - **Current Authors:** ${props.brew.authors?.map((author)=>{return `${author}`;}).join(', ') || 'Unable to list authors'}`, + **Current Authors:** ${props.brew.authors?.map((author)=>{return `${author}`;}).join(', ') || 'Unable to list authors'} + + [Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`, // User is not signed in; must be a user on the Authors List '04' : dedent` diff --git a/client/homebrew/pages/homePage/homePage.jsx b/client/homebrew/pages/homePage/homePage.jsx index 9802517b1..3d3139e74 100644 --- a/client/homebrew/pages/homePage/homePage.jsx +++ b/client/homebrew/pages/homePage/homePage.jsx @@ -31,9 +31,10 @@ const HomePage = createClass({ }, getInitialState : function() { return { - brew : this.props.brew, - welcomeText : this.props.brew.text, - error : undefined + brew : this.props.brew, + welcomeText : this.props.brew.text, + error : undefined, + currentEditorPage : 0 }; }, handleSave : function(){ @@ -53,7 +54,8 @@ const HomePage = createClass({ }, handleTextChange : function(text){ this.setState((prevState)=>({ - brew : { ...prevState.brew, text: text } + brew : { ...prevState.brew, text: text }, + currentEditorPage : this.refs.editor.getCurrentPage() - 1 //Offset index since Marked starts pages at 0 })); }, renderNavbar : function(){ @@ -85,7 +87,12 @@ const HomePage = createClass({ renderer={this.state.brew.renderer} showEditButtons={false} /> - +
    diff --git a/client/homebrew/pages/homePage/welcome_msg.md b/client/homebrew/pages/homePage/welcome_msg.md index 3332dfc39..9df769903 100644 --- a/client/homebrew/pages/homePage/welcome_msg.md +++ b/client/homebrew/pages/homePage/welcome_msg.md @@ -16,9 +16,9 @@ The Homebrewery makes the creation and sharing of authentic looking Fifth-Editio **Try it!** Simply edit the text on the left and watch it *update live* on the right. Note that not every button is visible on this demo page. Click New {{fas,fa-plus-square}} in the navbar above to start brewing with all the features! ### Editing and Sharing -When you create your own homebrew, you will be given a *edit url* and a *share url*. +When you create a new homebrew document ("brew"), your document will be given a *edit link* and a *share link*. -Any changes you make while on the *edit url* 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. +The *edit link* is where you write your brew. If you edit a brew while logged in, you are added as one of the brew's authors, and no one else can edit that brew until you add them as a new author via the {{fa,fa-info-circle}} **Properties** tab. Brews without any author can still be edited by anyone with the *edit link*, so be careful about who you share it with if you prefer to work without an account. Anyone with the *share url* will be able to access a read-only version of your homebrew. @@ -48,57 +48,63 @@ If you want to save ink or have a monochrome printer, add the **PRINT → {{fas, \column -## New in V3.0.0 -We've implemented an extended Markdown-like syntax for block and span elements, plus a few other changes, eliminating the need for HTML tags like `div` and `span` in most cases. No raw HTML tags should be needed in a brew (*but can still be used if you insist*). +## V3 vs Legacy +The Homebrewery has two renderers: Legacy and V3. The V3 renderer is recommended for all users because it is more powerful, more customizable, and continues to receive new feature updates while Legacy does not. However Legacy mode will remain available for older brews and veteran users. + +At any time, any individual brew can be changed to your renderer of choice via the {{fa,fa-info-circle}} **Properties** tab on your brew. However, converting between Legacy and V3 may require heavily tweaking the document; while both renderers can use raw HTML, V3 prefers a streamlined curly bracket syntax that avoids the complex HTML structures required by Legacy. -Much of the syntax and styling has changed in V3, so converting a Legacy brew to V3 (or vice-versa) will require tweaking your document. *However*, all brews made prior to the release of v3.0.0 will still render normally, and you may switch between the "Legacy" brew renderer and the newer "V3" renderer via the {{fa,fa-info-circle}} **Properties** button on your brew at any time. - -Scroll down to the next page for a brief summary of the changes and new features available in V3! +Scroll down to the next page for a brief summary of the changes and features available in V3! #### New Things All The Time! Check out the latest updates in the full changelog [here](/changelog). ### Helping out -Like this tool? Want to buy me a beer? [Head here](https://www.patreon.com/Naturalcrit) to help me keep the servers running. +Like this tool? Head over to our [Patreon](https://www.patreon.com/Naturalcrit) to help us keep the servers running. -This tool will **always** be free, never have ads, and I will never offer any "premium" features or whatever. + +This tool will **always** be free, never have ads, and we will never offer any "premium" features or whatever. ### Bugs, Issues, Suggestions? -Take a quick look at our [Frequently Asked Questions page](/faq) to see if your question has a handy answer. - -Need help getting started or just the right look for your brew? Head to [r/Homebrewery](https://www.reddit.com/r/homebrewery/submit?selftext=true&title=%5BIssue%5D%20Describe%20Your%20Issue%20Here) and let us know! - -Have an idea to make The Homebrewery better? Or did you find something that wasn't quite right? Check out the [GitHub Repo](https://github.com/naturalcrit/homebrewery/) to report technical issues. +- Check the [Frequently Asked Questions](/faq) page first for quick answers. +- Get help or the right look for your brew by posting on [r/Homebrewery](https://www.reddit.com/r/homebrewery/submit?selftext=true&title=%5BIssue%5D%20Describe%20Your%20Issue%20Here) or joining the [Discord Of Many Things](https://discord.gg/by3deKx). +- Report technical issues or provide feedback on the [GitHub Repo](https://github.com/naturalcrit/homebrewery/). ### Legal Junk The Homebrewery is licensed using the [MIT License](https://github.com/naturalcrit/homebrewery/blob/master/license). Which means you are free to use The Homebrewery codebase 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. - -#### Crediting Me -If you'd like to credit me in your brew, I'd be flattered! Just reference that you made it with The Homebrewery. +#### Crediting Us +If you'd like to credit us in your brew, we'd be flattered! Just reference that you made it with The Homebrewery. ### More Homebrew Resources -Discord of Many Things Logo -If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/wiki/resources). The Discord of Many Things is another great resource to connect with fellow homebrewers for help and feedback. +[![Discord](/assets/discordOfManyThings.svg){width:50px,float:right,padding-left:10px}](https://discord.gg/by3deKx) + +If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/wiki/resources). The [Discord Of Many Things](https://discord.gg/by3deKx) is another great resource to connect with fellow homebrewers for help and feedback. + {{position:absolute;top:20px;right:20px;width:auto - - - - +[![Discord](/assets/discord.png){height:30px}](https://discord.gg/by3deKx) +[![Github](/assets/github.png){height:30px}](https://github.com/naturalcrit/homebrewery) +[![Patreon](/assets/patreon.png){height:30px}](https://patreon.com/NaturalCrit) +[![Reddit](/assets/reddit.png){height:30px}](https://www.reddit.com/r/homebrewery/) }} \page + + + + + + + ## Markdown+ The Homebrewery aims to make homebrewing as simple as possible, providing a live editor with Markdown syntax that is more human-readable and faster to write with than raw HTML. -In version 3.0.0, with a goal of adding maximum flexibility without users resorting to complex HTML to accomplish simple tasks, Homebrewery provides an extended verision of Markdown with additional syntax. -**You can enable V3 via the {{fa,fa-info-circle}} Properties button!** +From version 3.0.0, with a goal of adding maximum flexibility without users resorting to complex HTML to accomplish simple tasks, Homebrewery provides an extended verision of Markdown with additional syntax. ### Curly Brackets -The biggest change in V3 is the replacement of `` and `
    ` with `{{ }}` for a cleaner custom formatting. Inline spans and block elements can be created and given ID's and Classes, as well as css properties, each of which are comma separated with no spaces. Use double quotes if a value requires spaces. Spans and Blocks start the same: +Standard Markdown lacks several equivalences to HTML. Hence, we have introduced `{{ }}` as a replacement for `` and `
    ` for a cleaner custom formatting. Inline spans and block elements can be created and given ID's and Classes, as well as CSS properties, each of which are comma separated with no spaces. Use double quotes if a value requires spaces. Spans and Blocks start the same: #### Span My favorite author is {{pen,#author,color:orange,font-family:"trebuchet ms" Brandon Sanderson}}. The orange text has a class of `pen`, an id of `author`, is colored orange, and given a new font. The first space outside of quotes marks the beginning of the content. @@ -126,16 +132,17 @@ A blank line can be achieved with a run of one or more `:` alone on a line. More :: + Much nicer than `




    ` ### Definition Lists **Example** :: V3 uses HTML *definition lists* to create "lists" with hanging indents. + + ### Column Breaks Column and page breaks with `\column` and `\page`. -\column - ### Tables Tables now allow column & row spanning between cells. This is included in some updated snippets, but a simplified example is given below. @@ -163,13 +170,13 @@ Using *Curly Injection* you can assign an id, classes, or inline CSS properties ![alt-text](https://s-media-cache-ak0.pinimg.com/736x/4a/81/79/4a8179462cfdf39054a418efd4cb743e.jpg) {width:100px,border:"2px solid",border-radius:10px} -\* *When using Imgur-hosted images, use the "direct link", which can be found when you click into your image in the Imgur interace.* +\* *When using Imgur-hosted images, use the "direct link", which can be found when you click into your image in the Imgur interface.* ## Snippets Homebrewery comes with a series of *code snippets* found at the top of the editor pane that make it easy to create brews as quickly as possible. Just set your cursor where you want the code to appear in the editor pane, choose a snippet, and make the adjustments you need. ## Style Editor Panel -{{fa,fa-paint-brush}} Technically released prior to v3 but still new to many users, check out the new **Style Editor** located on the right side of the Snippet bar. This editor accepts CSS for styling without requiring `