mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 18:32:41 +00:00
Merge branch 'master' into issue_4201
This commit is contained in:
@@ -47,9 +47,7 @@ Make an changes you need to `config/docker.json` then build the image. If it doe
|
||||
"naturalcrit_url" : "local.naturalcrit.com:8010",
|
||||
"secret" : "secret",
|
||||
"web_port" : 8000,
|
||||
"enable_v3" : true,
|
||||
"mongodb_uri": "mongodb://172.17.0.2/homebrewery",
|
||||
"enable_themes" : true,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -90,6 +88,13 @@ docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/
|
||||
docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest
|
||||
```
|
||||
|
||||
**NOTE:** If you are running from the Windows command line, this will not work as `$(pwd)` is not valid syntax. Use this command instead:
|
||||
```shell
|
||||
# Make sure you run this in the homebrewery directory
|
||||
docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v %cd%/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest
|
||||
```
|
||||
|
||||
|
||||
## Updating the Image
|
||||
|
||||
When Homebrewery code updates, your docker container will not automatically follow the changes. To do so you will need to rebuild your homebrewery image.
|
||||
@@ -117,3 +122,9 @@ docker-compose build homebrewery
|
||||
docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest
|
||||
```
|
||||
|
||||
**NOTE:** If you are running from the Windows command line, this will not work as `$(pwd)` is not valid syntax. Use this command instead:
|
||||
```shell
|
||||
# Make sure you run this in the homebrewery directory
|
||||
docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v %cd%/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest
|
||||
```
|
||||
|
||||
|
||||
@@ -7,15 +7,17 @@ import LockTools from './lockTools/lockTools.jsx';
|
||||
|
||||
const tabGroups = ['brew', 'notifications', 'authors', 'locks'];
|
||||
|
||||
const ADMIN_TAB = 'HB_adminPage_currentTab';
|
||||
|
||||
const Admin = ()=>{
|
||||
const [currentTab, setCurrentTab] = useState('');
|
||||
|
||||
useEffect(()=>{
|
||||
setCurrentTab(localStorage.getItem('hbAdminTab') || 'brew');
|
||||
setCurrentTab(localStorage.getItem(ADMIN_TAB) || 'brew');
|
||||
}, []);
|
||||
|
||||
useEffect(()=>{
|
||||
localStorage.setItem('hbAdminTab', currentTab);
|
||||
localStorage.setItem(ADMIN_TAB, currentTab);
|
||||
}, [currentTab]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,7 +2,8 @@ require('./splitPane.less');
|
||||
const React = require('react');
|
||||
const { useState, useEffect } = React;
|
||||
|
||||
const storageKey = 'naturalcrit-pane-split';
|
||||
const PANE_WIDTH_KEY = 'HB_editor_splitWidth';
|
||||
const LIVE_SCROLL_KEY = 'HB_editor_liveScroll';
|
||||
|
||||
const SplitPane = (props)=>{
|
||||
const {
|
||||
@@ -18,9 +19,9 @@ const SplitPane = (props)=>{
|
||||
const [liveScroll, setLiveScroll] = useState(false);
|
||||
|
||||
useEffect(()=>{
|
||||
const savedPos = window.localStorage.getItem(storageKey);
|
||||
const savedPos = window.localStorage.getItem(PANE_WIDTH_KEY);
|
||||
setDividerPos(savedPos ? limitPosition(savedPos, 0.1 * (window.innerWidth - 13), 0.9 * (window.innerWidth - 13)) : window.innerWidth / 2);
|
||||
setLiveScroll(window.localStorage.getItem('liveScroll') === 'true');
|
||||
setLiveScroll(window.localStorage.getItem(LIVE_SCROLL_KEY) === 'true');
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
return ()=>window.removeEventListener('resize', handleResize);
|
||||
@@ -29,13 +30,13 @@ const SplitPane = (props)=>{
|
||||
const limitPosition = (x, min = 1, max = window.innerWidth - 13)=>Math.round(Math.min(max, Math.max(min, x)));
|
||||
|
||||
//when resizing, the divider should grow smaller if less space is given, then grow back if the space is restored, to the original position
|
||||
const handleResize = ()=>setDividerPos(limitPosition(window.localStorage.getItem(storageKey), 0.1 * (window.innerWidth - 13), 0.9 * (window.innerWidth - 13)));
|
||||
const handleResize = ()=>setDividerPos(limitPosition(window.localStorage.getItem(PANE_WIDTH_KEY), 0.1 * (window.innerWidth - 13), 0.9 * (window.innerWidth - 13)));
|
||||
|
||||
const handleUp =(e)=>{
|
||||
e.preventDefault();
|
||||
if(isDragging) {
|
||||
onDragFinish(dividerPos);
|
||||
window.localStorage.setItem(storageKey, dividerPos);
|
||||
window.localStorage.setItem(PANE_WIDTH_KEY, dividerPos);
|
||||
}
|
||||
setIsDragging(false);
|
||||
};
|
||||
@@ -52,7 +53,7 @@ const SplitPane = (props)=>{
|
||||
};
|
||||
|
||||
const liveScrollToggle = ()=>{
|
||||
window.localStorage.setItem('liveScroll', String(!liveScroll));
|
||||
window.localStorage.setItem(LIVE_SCROLL_KEY, String(!liveScroll));
|
||||
setLiveScroll(!liveScroll);
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ const PAGEBREAK_REGEX_LEGACY = /\\page(?:break)?/m;
|
||||
const COLUMNBREAK_REGEX_LEGACY = /\\column(:?break)?/m;
|
||||
const PAGE_HEIGHT = 1056;
|
||||
|
||||
const TOOLBAR_STATE_KEY = 'HB_renderer_toolbarState';
|
||||
|
||||
const INITIAL_CONTENT = dedent`
|
||||
<!DOCTYPE html><html><head>
|
||||
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
||||
@@ -122,7 +124,7 @@ const BrewRenderer = (props)=>{
|
||||
|
||||
//useEffect to store or gather toolbar state from storage
|
||||
useEffect(()=>{
|
||||
const toolbarState = JSON.parse(window.localStorage.getItem('hb_toolbarState'));
|
||||
const toolbarState = JSON.parse(window.localStorage.getItem(TOOLBAR_STATE_KEY));
|
||||
toolbarState && setDisplayOptions(toolbarState);
|
||||
}, []);
|
||||
|
||||
@@ -284,7 +286,7 @@ const BrewRenderer = (props)=>{
|
||||
|
||||
const handleDisplayOptionsChange = (newDisplayOptions)=>{
|
||||
setDisplayOptions(newDisplayOptions);
|
||||
localStorage.setItem('hb_toolbarState', JSON.stringify(newDisplayOptions));
|
||||
localStorage.setItem(TOOLBAR_STATE_KEY, JSON.stringify(newDisplayOptions));
|
||||
};
|
||||
|
||||
const pagesStyle = {
|
||||
@@ -293,12 +295,6 @@ const BrewRenderer = (props)=>{
|
||||
rowGap : `${displayOptions.rowGap}px`
|
||||
};
|
||||
|
||||
const styleObject = {};
|
||||
|
||||
if(global.config.deployment) {
|
||||
styleObject.backgroundImage = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='40px' width='200px'><text x='0' y='15' fill='%23fff7' font-size='20'>${global.config.deployment}</text></svg>")`;
|
||||
}
|
||||
|
||||
const renderedStyle = useMemo(()=>renderStyle(), [props.style, props.themeBundle]);
|
||||
renderedPages = useMemo(()=>renderPages(), [props.text, displayOptions]);
|
||||
|
||||
@@ -327,10 +323,9 @@ const BrewRenderer = (props)=>{
|
||||
contentDidMount={frameDidMount}
|
||||
onClick={()=>{emitClick();}}
|
||||
>
|
||||
<div className={`brewRenderer ${global.config.deployment && 'deployment'}`}
|
||||
<div className='brewRenderer'
|
||||
onKeyDown={handleControlKeys}
|
||||
tabIndex={-1}
|
||||
style={ styleObject }
|
||||
>
|
||||
|
||||
{/* Apply CSS from Style tab and render pages from Markdown tab */}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
overflow-y : scroll;
|
||||
will-change : transform;
|
||||
&:has(.facing, .flow) { padding : 60px 30px; }
|
||||
&.deployment { background-color : darkred; }
|
||||
:where(.pages) {
|
||||
&.facing {
|
||||
display : grid;
|
||||
|
||||
@@ -9,6 +9,8 @@ import { Anchored, AnchoredBox, AnchoredTrigger } from '../../../components/Anch
|
||||
const MAX_ZOOM = 300;
|
||||
const MIN_ZOOM = 10;
|
||||
|
||||
const TOOLBAR_VISIBILITY = 'HB_renderer_toolbarVisibility';
|
||||
|
||||
const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPages, headerState, setHeaderState })=>{
|
||||
|
||||
const [pageNum, setPageNum] = useState(1);
|
||||
@@ -21,8 +23,8 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa
|
||||
}, [visiblePages]);
|
||||
|
||||
useEffect(()=>{
|
||||
const Visibility = localStorage.getItem('hb_toolbarVisibility');
|
||||
if (Visibility) setToolsVisible(Visibility === 'true');
|
||||
const Visibility = localStorage.getItem(TOOLBAR_VISIBILITY);
|
||||
if(Visibility) setToolsVisible(Visibility === 'true');
|
||||
|
||||
}, []);
|
||||
|
||||
@@ -100,7 +102,7 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa
|
||||
<div className='toggleButton'>
|
||||
<button title={`${toolsVisible ? 'Hide' : 'Show'} Preview Toolbar`} onClick={()=>{
|
||||
setToolsVisible(!toolsVisible);
|
||||
localStorage.setItem('hb_toolbarVisibility', !toolsVisible);
|
||||
localStorage.setItem(TOOLBAR_VISIBILITY, !toolsVisible);
|
||||
}}><i className='fas fa-glasses' /></button>
|
||||
<button title={`${headerState ? 'Hide' : 'Show'} Header Navigation`} onClick={()=>{setHeaderState(!headerState);}}><i className='fas fa-rectangle-list' /></button>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@ 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 EDITOR_THEME_KEY = 'HB_editor_theme';
|
||||
|
||||
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
|
||||
const SNIPPETBREAK_REGEX_V3 = /^\\snippet\ .*$/;
|
||||
@@ -140,7 +140,7 @@ const Editor = createClass({
|
||||
|
||||
handleViewChange : function(newView){
|
||||
this.props.setMoveArrows(newView === 'text');
|
||||
|
||||
|
||||
this.setState({
|
||||
view : newView
|
||||
}, ()=>{
|
||||
@@ -325,10 +325,10 @@ const Editor = createClass({
|
||||
const brewRenderer = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0];
|
||||
const currentPos = brewRenderer.scrollTop;
|
||||
const targetPos = window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).getBoundingClientRect().top;
|
||||
|
||||
const checkIfScrollComplete = ()=>{
|
||||
let scrollingTimeout;
|
||||
clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs
|
||||
|
||||
let scrollingTimeout;
|
||||
const checkIfScrollComplete = ()=>{ // Prevent interrupting a scroll in progress if user clicks multiple times
|
||||
clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs
|
||||
scrollingTimeout = setTimeout(()=>{
|
||||
isJumping = false;
|
||||
brewRenderer.removeEventListener('scroll', checkIfScrollComplete);
|
||||
@@ -369,8 +369,8 @@ const Editor = createClass({
|
||||
let currentY = this.codeEditor.current.codeMirror.getScrollInfo().top;
|
||||
let targetY = this.codeEditor.current.codeMirror.heightAtLine(targetLine, 'local', true);
|
||||
|
||||
const checkIfScrollComplete = ()=>{
|
||||
let scrollingTimeout;
|
||||
let scrollingTimeout;
|
||||
const checkIfScrollComplete = ()=>{ // Prevent interrupting a scroll in progress if user clicks multiple times
|
||||
clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs
|
||||
scrollingTimeout = setTimeout(()=>{
|
||||
isJumping = false;
|
||||
@@ -409,7 +409,6 @@ const Editor = createClass({
|
||||
|
||||
//Called when there are changes to the editor's dimensions
|
||||
update : function(){
|
||||
this.codeEditor.current?.updateSize();
|
||||
const snipHeight = document.querySelector('.editor > .snippetBar').offsetHeight;
|
||||
if(snipHeight !== this.state.snippetbarHeight)
|
||||
this.setState({ snippetbarHeight: snipHeight });
|
||||
|
||||
@@ -207,8 +207,6 @@ const MetadataEditor = createClass({
|
||||
},
|
||||
|
||||
renderThemeDropdown : function(){
|
||||
if(!global.enable_themes) return;
|
||||
|
||||
const mergedThemes = _.merge(Themes, this.props.userThemes);
|
||||
|
||||
const listThemes = (renderer)=>{
|
||||
@@ -307,8 +305,6 @@ const MetadataEditor = createClass({
|
||||
},
|
||||
|
||||
renderRenderOptions : function(){
|
||||
if(!global.enable_v3) return;
|
||||
|
||||
return <div className='field systems'>
|
||||
<label>Renderer</label>
|
||||
<div className='value'>
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
try {
|
||||
Boolean(new URL(value));
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return 'Must be a valid URL';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import './homebrew.less';
|
||||
import React from 'react';
|
||||
import { StaticRouter as Router, Route, Routes, useParams, useSearchParams } from 'react-router';
|
||||
|
||||
import { updateLocalStorage } from './utils/updateLocalStorage/updateLocalStorageKeys.js';
|
||||
|
||||
import HomePage from './pages/homePage/homePage.jsx';
|
||||
import EditPage from './pages/editPage/editPage.jsx';
|
||||
import UserPage from './pages/userPage/userPage.jsx';
|
||||
@@ -17,7 +19,6 @@ const WithRoute = ({ el: Element, ...rest })=>{
|
||||
const params = useParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
const queryParams = Object.fromEntries(searchParams?.entries() || []);
|
||||
|
||||
return <Element {...rest} {...params} query={queryParams} />;
|
||||
};
|
||||
|
||||
@@ -26,8 +27,6 @@ const Homebrew = (props)=>{
|
||||
url = '',
|
||||
version = '0.0.0',
|
||||
account = null,
|
||||
enable_v3 = false,
|
||||
enable_themes,
|
||||
config,
|
||||
brew = {
|
||||
title : '',
|
||||
@@ -44,13 +43,22 @@ const Homebrew = (props)=>{
|
||||
|
||||
global.account = account;
|
||||
global.version = version;
|
||||
global.enable_v3 = enable_v3;
|
||||
global.enable_themes = enable_themes;
|
||||
global.config = config;
|
||||
|
||||
const backgroundObject = ()=>{
|
||||
if(global.config.deployment || (config.local && config.development)){
|
||||
const bgText = global.config.deployment || 'Local';
|
||||
return {
|
||||
backgroundImage : `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='100px' width='200px'><text x='0' y='15' fill='%23fff7' font-size='20'>${bgText}</text></svg>")`
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
updateLocalStorage();
|
||||
|
||||
return (
|
||||
<Router location={url}>
|
||||
<div className='homebrew'>
|
||||
<div className={`homebrew${(config.deployment || config.local) ? ' deployment' : ''}`} style={backgroundObject()}>
|
||||
<Routes>
|
||||
<Route path='/edit/:id' element={<WithRoute el={EditPage} brew={brew} userThemes={userThemes}/>} />
|
||||
<Route path='/share/:id' element={<WithRoute el={SharePage} brew={brew} />} />
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
@import 'naturalcrit/styles/core.less';
|
||||
.homebrew {
|
||||
height : 100%;
|
||||
background-color:@steel;
|
||||
&.deployment { background-color : darkred; }
|
||||
|
||||
.sitePage {
|
||||
display : flex;
|
||||
flex-direction : column;
|
||||
height : 100%;
|
||||
overflow-y : hidden;
|
||||
background-color : @steel;
|
||||
.content {
|
||||
position : relative;
|
||||
flex : auto;
|
||||
|
||||
@@ -2,9 +2,9 @@ require('./error-navitem.less');
|
||||
const React = require('react');
|
||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||
|
||||
const ErrorNavItem = ({error = '', clearError})=>{
|
||||
const ErrorNavItem = ({ error = '', clearError })=>{
|
||||
const response = error.response;
|
||||
const errorCode = error.code
|
||||
const errorCode = error.code;
|
||||
const status = response?.status;
|
||||
const HBErrorCode = response?.body?.HBErrorCode;
|
||||
const message = response?.body?.message;
|
||||
@@ -15,7 +15,7 @@ const ErrorNavItem = ({error = '', clearError})=>{
|
||||
errMsg += `\`\`\`\n${error.stack}\n`;
|
||||
errMsg += `${JSON.stringify(response?.error, null, ' ')}\n\`\`\``;
|
||||
console.log(errMsg);
|
||||
} catch (e){}
|
||||
} catch {}
|
||||
|
||||
if(status === 409) {
|
||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||
@@ -112,6 +112,15 @@ const ErrorNavItem = ({error = '', clearError})=>{
|
||||
</Nav.item>;
|
||||
}
|
||||
|
||||
if(HBErrorCode === '13') {
|
||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||
Oops!
|
||||
<div className='errorContainer' onClick={clearError}>
|
||||
Server has lost connection to the database.
|
||||
</div>
|
||||
</Nav.item>;
|
||||
}
|
||||
|
||||
if(errorCode === 'ECONNABORTED') {
|
||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||
Oops!
|
||||
|
||||
@@ -37,7 +37,10 @@
|
||||
|
||||
&:has(.brewTitle) {
|
||||
flex-grow : 1;
|
||||
min-width : 300px;
|
||||
min-width : 300px;
|
||||
}
|
||||
>.brewTitle {
|
||||
cursor:auto;
|
||||
}
|
||||
}
|
||||
// "NaturalCrit" logo
|
||||
|
||||
@@ -34,8 +34,8 @@ const NewBrew = ()=>{
|
||||
}
|
||||
|
||||
const type = file.name.split('.').pop().toLowerCase();
|
||||
|
||||
alert(`This file is invalid: ${!type ? "Missing file extension" :`.${type} files are not supported`}. Only .txt files exported from the Homebrewery are allowed.`);
|
||||
|
||||
alert(`This file is invalid: ${!type ? 'Missing file extension' :`.${type} files are not supported`}. Only .txt files exported from the Homebrewery are allowed.`);
|
||||
|
||||
|
||||
console.log(file);
|
||||
|
||||
@@ -5,8 +5,8 @@ const Moment = require('moment');
|
||||
|
||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||
|
||||
const EDIT_KEY = 'homebrewery-recently-edited';
|
||||
const VIEW_KEY = 'homebrewery-recently-viewed';
|
||||
const EDIT_KEY = 'HB_nav_recentlyEdited';
|
||||
const VIEW_KEY = 'HB_nav_recentlyViewed';
|
||||
|
||||
|
||||
const RecentItems = createClass({
|
||||
|
||||
@@ -2,22 +2,22 @@ import React from 'react';
|
||||
import dedent from 'dedent-tabs';
|
||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||
|
||||
const getShareId = (brew)=>(
|
||||
brew.googleId && !brew.stubbed
|
||||
? brew.googleId + brew.shareId
|
||||
: brew.shareId
|
||||
);
|
||||
const getShareId = (brew)=>(
|
||||
brew.googleId && !brew.stubbed
|
||||
? brew.googleId + brew.shareId
|
||||
: brew.shareId
|
||||
);
|
||||
|
||||
const getRedditLink = (brew)=>{
|
||||
const text = dedent`
|
||||
const getRedditLink = (brew)=>{
|
||||
const text = dedent`
|
||||
Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
|
||||
|
||||
**[Homebrewery Link](${global.config.baseUrl}/share/${getShareId(brew)})**`;
|
||||
|
||||
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(brew.title.toWellFormed())}&text=${encodeURIComponent(text)}`;
|
||||
};
|
||||
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(brew.title.toWellFormed())}&text=${encodeURIComponent(text)}`;
|
||||
};
|
||||
|
||||
export default ({brew}) => (
|
||||
export default ({ brew })=>(
|
||||
<Nav.dropdown>
|
||||
<Nav.item color='teal' icon='fas fa-share-alt'>
|
||||
share
|
||||
|
||||
@@ -13,7 +13,7 @@ const AccountPage = (props)=>{
|
||||
// initialize save location from local storage based on user id
|
||||
React.useEffect(()=>{
|
||||
if(!saveLocation && accountDetails.username) {
|
||||
SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${accountDetails.username}`;
|
||||
SAVEKEY = `HB_editor_defaultSave_${accountDetails.username}`;
|
||||
// if no SAVEKEY in local storage, default save location to Google Drive if user has Google account.
|
||||
let saveLocation = window.localStorage.getItem(SAVEKEY);
|
||||
saveLocation = saveLocation ?? (accountDetails.googleId ? 'GOOGLE-DRIVE' : 'HOMEBREWERY');
|
||||
|
||||
@@ -7,7 +7,9 @@ const moment = require('moment');
|
||||
|
||||
const BrewItem = require('./brewItem/brewItem.jsx');
|
||||
|
||||
const USERPAGE_KEY_PREFIX = 'HOMEBREWERY-LISTPAGE';
|
||||
const USERPAGE_SORT_DIR = 'HB_listPage_sortDir';
|
||||
const USERPAGE_SORT_TYPE = 'HB_listPage_sortType';
|
||||
const USERPAGE_GROUP_VISIBILITY_PREFIX = 'HB_listPage_visibility_group';
|
||||
|
||||
const DEFAULT_SORT_TYPE = 'alpha';
|
||||
const DEFAULT_SORT_DIR = 'asc';
|
||||
@@ -50,12 +52,12 @@ const ListPage = createClass({
|
||||
|
||||
// LOAD FROM LOCAL STORAGE
|
||||
if(typeof window !== 'undefined') {
|
||||
const newSortType = (this.state.sortType ?? (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-SORTTYPE`) || DEFAULT_SORT_TYPE));
|
||||
const newSortDir = (this.state.sortDir ?? (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-SORTDIR`) || DEFAULT_SORT_DIR));
|
||||
const newSortType = (this.state.sortType ?? (localStorage.getItem(USERPAGE_SORT_TYPE) || DEFAULT_SORT_TYPE));
|
||||
const newSortDir = (this.state.sortDir ?? (localStorage.getItem(USERPAGE_SORT_DIR) || DEFAULT_SORT_DIR));
|
||||
this.updateUrl(this.state.filterString, newSortType, newSortDir);
|
||||
|
||||
const brewCollection = this.props.brewCollection.map((brewGroup)=>{
|
||||
brewGroup.visible = (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-VISIBILITY-${brewGroup.class}`) ?? 'true')=='true';
|
||||
brewGroup.visible = (localStorage.getItem(`${USERPAGE_GROUP_VISIBILITY_PREFIX}_${brewGroup.class}`) ?? 'true')=='true';
|
||||
return brewGroup;
|
||||
});
|
||||
|
||||
@@ -73,10 +75,10 @@ const ListPage = createClass({
|
||||
|
||||
saveToLocalStorage : function() {
|
||||
this.state.brewCollection.map((brewGroup)=>{
|
||||
localStorage.setItem(`${USERPAGE_KEY_PREFIX}-VISIBILITY-${brewGroup.class}`, `${brewGroup.visible}`);
|
||||
localStorage.setItem(`${USERPAGE_GROUP_VISIBILITY_PREFIX}_${brewGroup.class}`, `${brewGroup.visible}`);
|
||||
});
|
||||
localStorage.setItem(`${USERPAGE_KEY_PREFIX}-SORTTYPE`, this.state.sortType);
|
||||
localStorage.setItem(`${USERPAGE_KEY_PREFIX}-SORTDIR`, this.state.sortDir);
|
||||
localStorage.setItem(USERPAGE_SORT_TYPE, this.state.sortType);
|
||||
localStorage.setItem(USERPAGE_SORT_DIR, this.state.sortDir);
|
||||
},
|
||||
|
||||
renderBrews : function(brews){
|
||||
|
||||
@@ -1,48 +1,53 @@
|
||||
/* eslint-disable max-lines */
|
||||
import './editPage.less';
|
||||
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
// Common imports
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import request from '../../utils/request-middleware.js';
|
||||
import Markdown from 'naturalcrit/markdown.js';
|
||||
import _ from 'lodash';
|
||||
|
||||
import _ from 'lodash';;
|
||||
import { makePatches, stringifyPatches } from '@sanity/diff-match-patch';
|
||||
import { md5 } from 'hash-wasm';
|
||||
import { gzipSync, strToU8 } from 'fflate';
|
||||
import { Meta } from 'vitreum/headtags';
|
||||
import { DEFAULT_BREW_LOAD } from '../../../../server/brewDefaults.js';
|
||||
import { printCurrentBrew, fetchThemeBundle, splitTextStyleAndMetadata } from '../../../../shared/helpers.js';
|
||||
|
||||
import SplitPane from 'client/components/splitPane/splitPane.jsx';
|
||||
import Editor from '../../editor/editor.jsx';
|
||||
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
|
||||
|
||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||
import Navbar from '../../navbar/navbar.jsx';
|
||||
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
|
||||
import AccountNavItem from '../../navbar/account.navitem.jsx';
|
||||
import ShareNavItem from '../../navbar/share.navitem.jsx';
|
||||
import ErrorNavItem from '../../navbar/error-navitem.jsx';
|
||||
import HelpNavItem from '../../navbar/help.navitem.jsx';
|
||||
import VaultNavItem from '../../navbar/vault.navitem.jsx';
|
||||
import PrintNavItem from '../../navbar/print.navitem.jsx';
|
||||
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
|
||||
|
||||
import SplitPane from 'client/components/splitPane/splitPane.jsx';
|
||||
import Editor from '../../editor/editor.jsx';
|
||||
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
|
||||
// Page specific imports
|
||||
import { Meta } from 'vitreum/headtags';
|
||||
import { md5 } from 'hash-wasm';
|
||||
import { gzipSync, strToU8 } from 'fflate';
|
||||
import { makePatches, stringifyPatches } from '@sanity/diff-match-patch';
|
||||
|
||||
import ShareNavItem from '../../navbar/share.navitem.jsx';
|
||||
import LockNotification from './lockNotification/lockNotification.jsx';
|
||||
|
||||
import { DEFAULT_BREW_LOAD } from '../../../../server/brewDefaults.js';
|
||||
import { printCurrentBrew, fetchThemeBundle } from '../../../../shared/helpers.js';
|
||||
|
||||
import { updateHistory, versionHistoryGarbageCollection } from '../../utils/versionHistory.js';
|
||||
|
||||
import googleDriveIcon from '../../googleDrive.svg';
|
||||
|
||||
const SAVE_TIMEOUT = 10000;
|
||||
const UNSAVED_WARNING_TIMEOUT = 900000; //Warn user afer 15 minutes of unsaved changes
|
||||
const UNSAVED_WARNING_POPUP_TIMEOUT = 4000; //Show the warning for 4 seconds
|
||||
|
||||
const BREWKEY = 'homebrewery-new';
|
||||
const STYLEKEY = 'homebrewery-new-style';
|
||||
const SNIPKEY = 'homebrewery-new-snippets';
|
||||
const METAKEY = 'homebrewery-new-meta';
|
||||
|
||||
const AUTOSAVE_KEY = 'HB_editor_autoSaveOn';
|
||||
const BREWKEY = 'HB_newPage_content';
|
||||
const STYLEKEY = 'HB_newPage_style';
|
||||
const SNIPKEY = 'HB_newPage_snippets';
|
||||
const METAKEY = 'HB_newPage_meta';
|
||||
|
||||
const useLocalStorage = false;
|
||||
const neverSaved = false;
|
||||
|
||||
const EditPage = (props)=>{
|
||||
props = {
|
||||
@@ -74,10 +79,8 @@ const EditPage = (props)=>{
|
||||
const trySaveRef = useRef(trySave); // CTRL+S listener lives outside React and needs ref to use trySave with latest copy of brew
|
||||
const unsavedChangesRef = useRef(unsavedChanges); // Similarly, onBeforeUnload lives outside React and needs ref to unsavedChanges
|
||||
|
||||
const useLocalStorage = false;
|
||||
|
||||
useEffect(()=>{
|
||||
const autoSavePref = JSON.parse(localStorage.getItem('AUTOSAVE_ON') ?? true);
|
||||
const autoSavePref = JSON.parse(localStorage.getItem(AUTOSAVE_KEY) ?? true);
|
||||
setAutoSaveEnabled(autoSavePref);
|
||||
setWarnUnsavedChanges(!autoSavePref);
|
||||
setHTMLErrors(Markdown.validate(currentBrew.text));
|
||||
@@ -120,28 +123,16 @@ const EditPage = (props)=>{
|
||||
editorRef.current?.update();
|
||||
};
|
||||
|
||||
const handleEditorViewPageChange = (pageNumber)=>{
|
||||
setCurrentEditorViewPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleEditorCursorPageChange = (pageNumber)=>{
|
||||
setCurrentEditorCursorPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleBrewRendererPageChange = (pageNumber)=>{
|
||||
setCurrentBrewRendererPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleBrewChange = (field) => (value, subfield) => { //'text', 'style', 'snippets', 'metadata'
|
||||
if (subfield == 'renderer' || subfield == 'theme')
|
||||
const handleBrewChange = (field)=>(value, subfield)=>{ //'text', 'style', 'snippets', 'metadata'
|
||||
if(subfield == 'renderer' || subfield == 'theme')
|
||||
fetchThemeBundle(setError, setThemeBundle, value.renderer, value.theme);
|
||||
|
||||
//If there are HTML errors, run the validator on every change to give quick feedback
|
||||
if(HTMLErrors.length && (field == 'text' || field == 'snippets'))
|
||||
setHTMLErrors(Markdown.validate(value));
|
||||
|
||||
if(field == 'metadata') setCurrentBrew(prev => ({ ...prev, ...value }));
|
||||
else setCurrentBrew(prev => ({ ...prev, [field]: value }));
|
||||
if(field == 'metadata') setCurrentBrew((prev)=>({ ...prev, ...value }));
|
||||
else setCurrentBrew((prev)=>({ ...prev, [field]: value }));
|
||||
|
||||
if(useLocalStorage) {
|
||||
if(field == 'text') localStorage.setItem(BREWKEY, value);
|
||||
@@ -318,20 +309,24 @@ const EditPage = (props)=>{
|
||||
|
||||
// #3 - Unsaved changes exist, click to save, show SAVE NOW
|
||||
if(unsavedChanges)
|
||||
return <Nav.item className='save' onClick={()=>trySave(true)} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
|
||||
return <Nav.item className='save' onClick={()=>trySave(true)} color='blue' icon='fas fa-save'>save now</Nav.item>;
|
||||
|
||||
// #4 - No unsaved changes, autosave is ON, show AUTO-SAVED
|
||||
if(autoSaveEnabled)
|
||||
return <Nav.item className='save saved'>auto-saved.</Nav.item>;
|
||||
return <Nav.item className='save saved'>auto-saved</Nav.item>;
|
||||
|
||||
// #5 - No unsaved changes, and has never been saved, hide the button
|
||||
if(neverSaved)
|
||||
return <Nav.item className='save neverSaved'>save now</Nav.item>;
|
||||
|
||||
// DEFAULT - No unsaved changes, show SAVED
|
||||
return <Nav.item className='save saved'>saved.</Nav.item>;
|
||||
return <Nav.item className='save saved'>saved</Nav.item>;
|
||||
};
|
||||
|
||||
const toggleAutoSave = ()=>{
|
||||
clearTimeout(warnUnsavedTimeout.current);
|
||||
clearTimeout(saveTimeout.current);
|
||||
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(!autoSaveEnabled));
|
||||
localStorage.setItem(AUTOSAVE_KEY, JSON.stringify(!autoSaveEnabled));
|
||||
setAutoSaveEnabled(!autoSaveEnabled);
|
||||
setWarnUnsavedChanges(autoSaveEnabled);
|
||||
};
|
||||
@@ -361,11 +356,11 @@ const EditPage = (props)=>{
|
||||
{renderSaveButton()}
|
||||
{renderAutoSaveButton()}
|
||||
</Nav.dropdown>}
|
||||
<NewBrewItem/>
|
||||
<HelpNavItem/>
|
||||
<ShareNavItem brew={currentBrew} />
|
||||
<NewBrewItem />
|
||||
<PrintNavItem />
|
||||
<HelpNavItem />
|
||||
<VaultNavItem />
|
||||
<ShareNavItem brew={currentBrew} />
|
||||
<RecentNavItem brew={currentBrew} storageKey='edit' />
|
||||
<AccountNavItem/>
|
||||
</Nav.section>
|
||||
@@ -391,8 +386,8 @@ const EditPage = (props)=>{
|
||||
userThemes={props.userThemes}
|
||||
themeBundle={themeBundle}
|
||||
updateBrew={updateBrew}
|
||||
onCursorPageChange={handleEditorCursorPageChange}
|
||||
onViewPageChange={handleEditorViewPageChange}
|
||||
onCursorPageChange={setCurrentEditorCursorPageNum}
|
||||
onViewPageChange={setCurrentEditorViewPageNum}
|
||||
currentEditorViewPageNum={currentEditorViewPageNum}
|
||||
currentEditorCursorPageNum={currentEditorCursorPageNum}
|
||||
currentBrewRendererPageNum={currentBrewRendererPageNum}
|
||||
@@ -405,7 +400,7 @@ const EditPage = (props)=>{
|
||||
themeBundle={themeBundle}
|
||||
errors={HTMLErrors}
|
||||
lang={currentBrew.lang}
|
||||
onPageChange={handleBrewRendererPageChange}
|
||||
onPageChange={setCurrentBrewRendererPageNum}
|
||||
currentEditorViewPageNum={currentEditorViewPageNum}
|
||||
currentEditorCursorPageNum={currentEditorCursorPageNum}
|
||||
currentBrewRendererPageNum={currentBrewRendererPageNum}
|
||||
|
||||
@@ -196,6 +196,12 @@ const errorIndex = (props)=>{
|
||||
|
||||
**Brew ID:** ${props.brew.brewId}`,
|
||||
|
||||
// Database Connection Lost
|
||||
'13' : dedent`
|
||||
## Database connection has been lost.
|
||||
|
||||
The server could not communicate with the database.`,
|
||||
|
||||
//account page when account is not defined
|
||||
'50' : dedent`
|
||||
## You are not signed in
|
||||
|
||||
@@ -1,55 +1,79 @@
|
||||
/* eslint-disable max-lines */
|
||||
import './homePage.less';
|
||||
|
||||
import React from 'react';
|
||||
import { useEffect, useState, useRef } from 'react';
|
||||
import request from '../../utils/request-middleware.js';
|
||||
import Markdown from 'naturalcrit/markdown.js';
|
||||
import { Meta } from 'vitreum/headtags';
|
||||
// Common imports
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import request from '../../utils/request-middleware.js';
|
||||
import Markdown from 'naturalcrit/markdown.js';
|
||||
import _ from 'lodash';
|
||||
|
||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||
import Navbar from '../../navbar/navbar.jsx';
|
||||
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
|
||||
import HelpNavItem from '../../navbar/help.navitem.jsx';
|
||||
import VaultNavItem from '../../navbar/vault.navitem.jsx';
|
||||
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
|
||||
import AccountNavItem from '../../navbar/account.navitem.jsx';
|
||||
import ErrorNavItem from '../../navbar/error-navitem.jsx';
|
||||
import { fetchThemeBundle } from '../../../../shared/helpers.js';
|
||||
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
|
||||
import { printCurrentBrew, fetchThemeBundle, splitTextStyleAndMetadata } from '../../../../shared/helpers.js';
|
||||
|
||||
import SplitPane from 'client/components/splitPane/splitPane.jsx';
|
||||
import Editor from '../../editor/editor.jsx';
|
||||
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
|
||||
import SplitPane from 'client/components/splitPane/splitPane.jsx';
|
||||
import Editor from '../../editor/editor.jsx';
|
||||
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
|
||||
|
||||
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
|
||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||
import Navbar from '../../navbar/navbar.jsx';
|
||||
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
|
||||
import AccountNavItem from '../../navbar/account.navitem.jsx';
|
||||
import ErrorNavItem from '../../navbar/error-navitem.jsx';
|
||||
import HelpNavItem from '../../navbar/help.navitem.jsx';
|
||||
import VaultNavItem from '../../navbar/vault.navitem.jsx';
|
||||
import PrintNavItem from '../../navbar/print.navitem.jsx';
|
||||
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
|
||||
|
||||
// Page specific imports
|
||||
import { Meta } from 'vitreum/headtags';
|
||||
|
||||
const BREWKEY = 'homebrewery-new';
|
||||
const STYLEKEY = 'homebrewery-new-style';
|
||||
const SNIPKEY = 'homebrewery-new-snippets';
|
||||
const METAKEY = 'homebrewery-new-meta';
|
||||
|
||||
const useLocalStorage = false;
|
||||
const neverSaved = true;
|
||||
|
||||
const HomePage =(props)=>{
|
||||
props = {
|
||||
brew : DEFAULT_BREW,
|
||||
ver : '0.0.0',
|
||||
...props
|
||||
};
|
||||
...props
|
||||
};
|
||||
|
||||
const [currentBrew , setCurrentBrew] = useState(props.brew);
|
||||
const [welcomeText , setWelcomeText] = useState(props.brew.text);
|
||||
const [error , setError] = useState(undefined);
|
||||
const [HTMLErrors , setHTMLErrors ] = useState(Markdown.validate(props.brew.text));
|
||||
const [HTMLErrors , setHTMLErrors] = useState(Markdown.validate(props.brew.text));
|
||||
const [currentEditorViewPageNum , setCurrentEditorViewPageNum] = useState(1);
|
||||
const [currentEditorCursorPageNum, setCurrentEditorCursorPageNum] = useState(1);
|
||||
const [currentBrewRendererPageNum, setCurrentBrewRendererPageNum] = useState(1);
|
||||
const [themeBundle , setThemeBundle] = useState({});
|
||||
const [unsavedChanges , setUnsavedChanges] = useState(false);
|
||||
const [isSaving , setIsSaving] = useState(false);
|
||||
const [autoSaveEnabled , setAutoSaveEnable] = useState(false);
|
||||
|
||||
const editorRef = useRef(null);
|
||||
|
||||
const useLocalStorage = false;
|
||||
const editorRef = useRef(null);
|
||||
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
|
||||
|
||||
useEffect(()=>{
|
||||
fetchThemeBundle(setError, setThemeBundle, currentBrew.renderer, currentBrew.theme);
|
||||
|
||||
const handleControlKeys = (e)=>{
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
if(e.keyCode === 83) trySaveRef.current(true);
|
||||
if(e.keyCode === 80) printCurrentBrew();
|
||||
if([83, 80].includes(e.keyCode)) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('keydown', handleControlKeys);
|
||||
|
||||
return ()=>{
|
||||
document.removeEventListener('keydown', handleControlKeys);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const save = ()=>{
|
||||
@@ -65,32 +89,27 @@ const HomePage =(props)=>{
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
const hasChange = !_.isEqual(currentBrew, lastSavedBrew.current);
|
||||
setUnsavedChanges(hasChange);
|
||||
|
||||
if(autoSaveEnabled) trySave(false, hasChange);
|
||||
}, [currentBrew]);
|
||||
|
||||
const handleSplitMove = ()=>{
|
||||
editorRef.current.update();
|
||||
};
|
||||
|
||||
const handleEditorViewPageChange = (pageNumber)=>{
|
||||
setCurrentEditorViewPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleEditorCursorPageChange = (pageNumber)=>{
|
||||
setCurrentEditorCursorPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleBrewRendererPageChange = (pageNumber)=>{
|
||||
setCurrentBrewRendererPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleBrewChange = (field) => (value, subfield) => { //'text', 'style', 'snippets', 'metadata'
|
||||
if (subfield == 'renderer' || subfield == 'theme')
|
||||
const handleBrewChange = (field)=>(value, subfield)=>{ //'text', 'style', 'snippets', 'metadata'
|
||||
if(subfield == 'renderer' || subfield == 'theme')
|
||||
fetchThemeBundle(setError, setThemeBundle, value.renderer, value.theme);
|
||||
|
||||
//If there are HTML errors, run the validator on every change to give quick feedback
|
||||
if(HTMLErrors.length && (field == 'text' || field == 'snippets'))
|
||||
setHTMLErrors(Markdown.validate(value));
|
||||
|
||||
if(field == 'metadata') setCurrentBrew(prev => ({ ...prev, ...value }));
|
||||
else setCurrentBrew(prev => ({ ...prev, [field]: value }));
|
||||
if(field == 'metadata') setCurrentBrew((prev)=>({ ...prev, ...value }));
|
||||
else setCurrentBrew((prev)=>({ ...prev, [field]: value }));
|
||||
|
||||
if(useLocalStorage) {
|
||||
if(field == 'text') localStorage.setItem(BREWKEY, value);
|
||||
@@ -104,6 +123,41 @@ const HomePage =(props)=>{
|
||||
}
|
||||
};
|
||||
|
||||
const renderSaveButton = ()=>{
|
||||
// #1 - Currently saving, show SAVING
|
||||
if(isSaving)
|
||||
return <Nav.item className='save' icon='fas fa-spinner fa-spin'>saving...</Nav.item>;
|
||||
|
||||
// #2 - Unsaved changes exist, autosave is OFF and warning timer has expired, show AUTOSAVE WARNING
|
||||
// if(unsavedChanges && warnUnsavedChanges) {
|
||||
// resetWarnUnsavedTimer();
|
||||
// const elapsedTime = Math.round((new Date() - lastSavedTime) / 1000 / 60);
|
||||
// const text = elapsedTime === 0
|
||||
// ? 'Autosave is OFF.'
|
||||
// : `Autosave is OFF, and you haven't saved for ${elapsedTime} minutes.`;
|
||||
|
||||
// return <Nav.item className='save error' icon='fas fa-exclamation-circle'>
|
||||
// Reminder...
|
||||
// <div className='errorContainer'>{text}</div>
|
||||
// </Nav.item>;
|
||||
// }
|
||||
|
||||
// #3 - Unsaved changes exist, click to save, show SAVE NOW
|
||||
if(unsavedChanges)
|
||||
return <Nav.item className='save' onClick={save} color='blue' icon='fas fa-save'>save now</Nav.item>;
|
||||
|
||||
// #4 - No unsaved changes, autosave is ON, show AUTO-SAVED
|
||||
if(autoSaveEnabled)
|
||||
return <Nav.item className='save saved'>auto-saved</Nav.item>;
|
||||
|
||||
// #5 - No unsaved changes, and has never been saved, hide the button
|
||||
if(neverSaved)
|
||||
return <Nav.item className='save neverSaved'>save now</Nav.item>;
|
||||
|
||||
// DEFAULT - No unsaved changes, show SAVED
|
||||
return <Nav.item className='save saved'>saved</Nav.item>;
|
||||
};
|
||||
|
||||
const clearError = ()=>{
|
||||
setError(null);
|
||||
setIsSaving(false);
|
||||
@@ -112,11 +166,11 @@ const HomePage =(props)=>{
|
||||
const renderNavbar = ()=>{
|
||||
return <Navbar ver={props.ver}>
|
||||
<Nav.section>
|
||||
{error ?
|
||||
<ErrorNavItem error={error} clearError={clearError}></ErrorNavItem> :
|
||||
null
|
||||
}
|
||||
{error
|
||||
? <ErrorNavItem error={error} clearError={clearError} />
|
||||
: renderSaveButton()}
|
||||
<NewBrewItem />
|
||||
<PrintNavItem />
|
||||
<HelpNavItem />
|
||||
<VaultNavItem />
|
||||
<RecentNavItem />
|
||||
@@ -138,8 +192,8 @@ const HomePage =(props)=>{
|
||||
renderer={currentBrew.renderer}
|
||||
showEditButtons={false}
|
||||
themeBundle={themeBundle}
|
||||
onCursorPageChange={handleEditorCursorPageChange}
|
||||
onViewPageChange={handleEditorViewPageChange}
|
||||
onCursorPageChange={setCurrentEditorCursorPageNum}
|
||||
onViewPageChange={setCurrentEditorViewPageNum}
|
||||
currentEditorViewPageNum={currentEditorViewPageNum}
|
||||
currentEditorCursorPageNum={currentEditorCursorPageNum}
|
||||
currentBrewRendererPageNum={currentBrewRendererPageNum}
|
||||
@@ -148,7 +202,7 @@ const HomePage =(props)=>{
|
||||
text={currentBrew.text}
|
||||
style={currentBrew.style}
|
||||
renderer={currentBrew.renderer}
|
||||
onPageChange={handleBrewRendererPageChange}
|
||||
onPageChange={setCurrentBrewRendererPageNum}
|
||||
currentEditorViewPageNum={currentEditorViewPageNum}
|
||||
currentEditorCursorPageNum={currentEditorCursorPageNum}
|
||||
currentBrewRendererPageNum={currentBrewRendererPageNum}
|
||||
@@ -156,7 +210,7 @@ const HomePage =(props)=>{
|
||||
/>
|
||||
</SplitPane>
|
||||
</div>
|
||||
<div className={`floatingSaveButton${welcomeText !== currentBrew.text ? ' show' : ''}`} onClick={save}>
|
||||
<div className={`floatingSaveButton${unsavedChanges ? ' show' : ''}`} onClick={save}>
|
||||
Save current <i className='fas fa-save' />
|
||||
</div>
|
||||
|
||||
@@ -164,7 +218,7 @@ const HomePage =(props)=>{
|
||||
Create your own <i className='fas fa-magic' />
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = HomePage;
|
||||
|
||||
@@ -34,7 +34,13 @@
|
||||
}
|
||||
|
||||
.navItem.save {
|
||||
.fadeInRight();
|
||||
.transition(opacity);
|
||||
background-color : @orange;
|
||||
&:hover { background-color : @green; }
|
||||
&.neverSaved {
|
||||
.fadeOutRight();
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,44 @@
|
||||
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
||||
/* eslint-disable max-lines */
|
||||
import './newPage.less';
|
||||
|
||||
// Common imports
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import request from '../../utils/request-middleware.js';
|
||||
import Markdown from 'naturalcrit/markdown.js';
|
||||
import _ from 'lodash';
|
||||
|
||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||
import Navbar from '../../navbar/navbar.jsx';
|
||||
import AccountNavItem from '../../navbar/account.navitem.jsx';
|
||||
import ErrorNavItem from '../../navbar/error-navitem.jsx';
|
||||
import HelpNavItem from '../../navbar/help.navitem.jsx';
|
||||
import PrintNavItem from '../../navbar/print.navitem.jsx';
|
||||
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
|
||||
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
|
||||
import { printCurrentBrew, fetchThemeBundle, splitTextStyleAndMetadata } from '../../../../shared/helpers.js';
|
||||
|
||||
import SplitPane from 'client/components/splitPane/splitPane.jsx';
|
||||
import Editor from '../../editor/editor.jsx';
|
||||
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
|
||||
|
||||
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
|
||||
import { printCurrentBrew, fetchThemeBundle, splitTextStyleAndMetadata } from '../../../../shared/helpers.js';
|
||||
import Nav from 'naturalcrit/nav/nav.jsx';
|
||||
import Navbar from '../../navbar/navbar.jsx';
|
||||
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
|
||||
import AccountNavItem from '../../navbar/account.navitem.jsx';
|
||||
import ErrorNavItem from '../../navbar/error-navitem.jsx';
|
||||
import HelpNavItem from '../../navbar/help.navitem.jsx';
|
||||
import VaultNavItem from '../../navbar/vault.navitem.jsx';
|
||||
import PrintNavItem from '../../navbar/print.navitem.jsx';
|
||||
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
|
||||
|
||||
const BREWKEY = 'homebrewery-new';
|
||||
const STYLEKEY = 'homebrewery-new-style';
|
||||
const SNIPKEY = 'homebrewery-new-snippets';
|
||||
const METAKEY = 'homebrewery-new-meta';
|
||||
const SAVEKEYPREFIX = 'HOMEBREWERY-DEFAULT-SAVE-LOCATION-';
|
||||
// Page specific imports
|
||||
import { Meta } from 'vitreum/headtags';
|
||||
|
||||
const NewPage = (props) => {
|
||||
const BREWKEY = 'HB_newPage_content';
|
||||
const STYLEKEY = 'HB_newPage_style';
|
||||
const METAKEY = 'HB_newPage_metadata';
|
||||
const SNIPKEY = 'HB_newPage_snippets';
|
||||
const SAVEKEYPREFIX = 'HB_editor_defaultSave_';
|
||||
|
||||
const useLocalStorage = true;
|
||||
const neverSaved = true;
|
||||
|
||||
const NewPage = (props)=>{
|
||||
props = {
|
||||
brew: DEFAULT_BREW,
|
||||
brew : DEFAULT_BREW,
|
||||
...props
|
||||
};
|
||||
|
||||
@@ -41,17 +51,29 @@ const NewPage = (props) => {
|
||||
const [currentEditorCursorPageNum, setCurrentEditorCursorPageNum] = useState(1);
|
||||
const [currentBrewRendererPageNum, setCurrentBrewRendererPageNum] = useState(1);
|
||||
const [themeBundle , setThemeBundle ] = useState({});
|
||||
const [unsavedChanges , setUnsavedChanges ] = useState(false);
|
||||
const [autoSaveEnabled , setAutoSaveEnabled ] = useState(false);
|
||||
|
||||
const editorRef = useRef(null);
|
||||
const editorRef = useRef(null);
|
||||
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
|
||||
|
||||
const useLocalStorage = true;
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('keydown', handleControlKeys);
|
||||
useEffect(()=>{
|
||||
loadBrew();
|
||||
fetchThemeBundle(setError, setThemeBundle, currentBrew.renderer, currentBrew.theme);
|
||||
|
||||
return () => {
|
||||
const handleControlKeys = (e)=>{
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
if(e.keyCode === 83) trySaveRef.current(true);
|
||||
if(e.keyCode === 80) printCurrentBrew();
|
||||
if([83, 80].includes(e.keyCode)) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('keydown', handleControlKeys);
|
||||
|
||||
return ()=>{
|
||||
document.removeEventListener('keydown', handleControlKeys);
|
||||
};
|
||||
}, []);
|
||||
@@ -74,6 +96,7 @@ const NewPage = (props) => {
|
||||
const saveStorage = localStorage.getItem(SAVEKEY) || 'HOMEBREWERY';
|
||||
|
||||
setCurrentBrew(brew);
|
||||
lastSavedBrew.current = brew;
|
||||
setSaveGoogle(saveStorage == 'GOOGLE-DRIVE' && saveGoogle);
|
||||
|
||||
localStorage.setItem(BREWKEY, brew.text);
|
||||
@@ -84,44 +107,27 @@ const NewPage = (props) => {
|
||||
window.history.replaceState({}, window.location.title, '/new/');
|
||||
};
|
||||
|
||||
const handleControlKeys = (e) => {
|
||||
if (!(e.ctrlKey || e.metaKey)) return;
|
||||
const S_KEY = 83;
|
||||
const P_KEY = 80;
|
||||
if (e.keyCode === S_KEY) save();
|
||||
if (e.keyCode === P_KEY) printCurrentBrew();
|
||||
if (e.keyCode === S_KEY || e.keyCode === P_KEY) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
useEffect(()=>{
|
||||
const hasChange = !_.isEqual(currentBrew, lastSavedBrew.current);
|
||||
setUnsavedChanges(hasChange);
|
||||
|
||||
if(autoSaveEnabled) trySave(false, hasChange);
|
||||
}, [currentBrew]);
|
||||
|
||||
const handleSplitMove = ()=>{
|
||||
editorRef.current.update();
|
||||
};
|
||||
|
||||
const handleEditorViewPageChange = (pageNumber)=>{
|
||||
setCurrentEditorViewPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleEditorCursorPageChange = (pageNumber)=>{
|
||||
setCurrentEditorCursorPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleBrewRendererPageChange = (pageNumber)=>{
|
||||
setCurrentBrewRendererPageNum(pageNumber);
|
||||
};
|
||||
|
||||
const handleBrewChange = (field) => (value, subfield) => { //'text', 'style', 'snippets', 'metadata'
|
||||
if (subfield == 'renderer' || subfield == 'theme')
|
||||
const handleBrewChange = (field)=>(value, subfield)=>{ //'text', 'style', 'snippets', 'metadata'
|
||||
if(subfield == 'renderer' || subfield == 'theme')
|
||||
fetchThemeBundle(setError, setThemeBundle, value.renderer, value.theme);
|
||||
|
||||
//If there are HTML errors, run the validator on every change to give quick feedback
|
||||
if(HTMLErrors.length && (field == 'text' || field == 'snippets'))
|
||||
setHTMLErrors(Markdown.validate(value));
|
||||
|
||||
if(field == 'metadata') setCurrentBrew(prev => ({ ...prev, ...value }));
|
||||
else setCurrentBrew(prev => ({ ...prev, [field]: value }));
|
||||
if(field == 'metadata') setCurrentBrew((prev)=>({ ...prev, ...value }));
|
||||
else setCurrentBrew((prev)=>({ ...prev, [field]: value }));
|
||||
|
||||
if(useLocalStorage) {
|
||||
if(field == 'text') localStorage.setItem(BREWKEY, value);
|
||||
@@ -135,10 +141,10 @@ const NewPage = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
const save = async ()=>{
|
||||
setIsSaving(true);
|
||||
|
||||
let updatedBrew = { ...currentBrew };
|
||||
const updatedBrew = { ...currentBrew };
|
||||
splitTextStyleAndMetadata(updatedBrew);
|
||||
|
||||
const pageRegex = updatedBrew.renderer === 'legacy' ? /\\page/g : /^\\page$/gm;
|
||||
@@ -147,13 +153,13 @@ const NewPage = (props) => {
|
||||
const res = await request
|
||||
.post(`/api${saveGoogle ? '?saveToGoogle=true' : ''}`)
|
||||
.send(updatedBrew)
|
||||
.catch((err) => {
|
||||
.catch((err)=>{
|
||||
setIsSaving(false);
|
||||
setError(err);
|
||||
});
|
||||
|
||||
setIsSaving(false)
|
||||
if (!res) return;
|
||||
setIsSaving(false);
|
||||
if(!res) return;
|
||||
|
||||
const savedBrew = res.body;
|
||||
|
||||
@@ -164,15 +170,38 @@ const NewPage = (props) => {
|
||||
};
|
||||
|
||||
const renderSaveButton = ()=>{
|
||||
if(isSaving){
|
||||
return <Nav.item icon='fas fa-spinner fa-spin' className='save'>
|
||||
save...
|
||||
</Nav.item>;
|
||||
} else {
|
||||
return <Nav.item icon='fas fa-save' className='save' onClick={save}>
|
||||
save
|
||||
</Nav.item>;
|
||||
}
|
||||
// #1 - Currently saving, show SAVING
|
||||
if(isSaving)
|
||||
return <Nav.item className='save' icon='fas fa-spinner fa-spin'>saving...</Nav.item>;
|
||||
|
||||
// #2 - Unsaved changes exist, autosave is OFF and warning timer has expired, show AUTOSAVE WARNING
|
||||
// if(unsavedChanges && warnUnsavedChanges) {
|
||||
// resetWarnUnsavedTimer();
|
||||
// const elapsedTime = Math.round((new Date() - lastSavedTime) / 1000 / 60);
|
||||
// const text = elapsedTime === 0
|
||||
// ? 'Autosave is OFF.'
|
||||
// : `Autosave is OFF, and you haven't saved for ${elapsedTime} minutes.`;
|
||||
|
||||
// return <Nav.item className='save error' icon='fas fa-exclamation-circle'>
|
||||
// Reminder...
|
||||
// <div className='errorContainer'>{text}</div>
|
||||
// </Nav.item>;
|
||||
// }
|
||||
|
||||
// #3 - Unsaved changes exist, click to save, show SAVE NOW
|
||||
if(unsavedChanges)
|
||||
return <Nav.item className='save' onClick={save} color='blue' icon='fas fa-save'>save now</Nav.item>;
|
||||
|
||||
// #4 - No unsaved changes, autosave is ON, show AUTO-SAVED
|
||||
if(autoSaveEnabled)
|
||||
return <Nav.item className='save saved'>auto-saved</Nav.item>;
|
||||
|
||||
// #5 - No unsaved changes, and has never been saved, hide the button
|
||||
if(neverSaved)
|
||||
return <Nav.item className='save neverSaved'>save now</Nav.item>;
|
||||
|
||||
// DEFAULT - No unsaved changes, show SAVED
|
||||
return <Nav.item className='save saved'>saved</Nav.item>;
|
||||
};
|
||||
|
||||
const clearError = ()=>{
|
||||
@@ -180,7 +209,7 @@ const NewPage = (props) => {
|
||||
setIsSaving(false);
|
||||
};
|
||||
|
||||
const renderNavbar = () => (
|
||||
const renderNavbar = ()=>(
|
||||
<Navbar>
|
||||
<Nav.section>
|
||||
<Nav.item className='brewTitle'>{currentBrew.title}</Nav.item>
|
||||
@@ -190,8 +219,10 @@ const NewPage = (props) => {
|
||||
{error
|
||||
? <ErrorNavItem error={error} clearError={clearError} />
|
||||
: renderSaveButton()}
|
||||
<NewBrewItem />
|
||||
<PrintNavItem />
|
||||
<HelpNavItem />
|
||||
<VaultNavItem />
|
||||
<RecentNavItem />
|
||||
<AccountNavItem />
|
||||
</Nav.section>
|
||||
@@ -199,7 +230,7 @@ const NewPage = (props) => {
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='newPage sitePage'>
|
||||
<div className='newPage sitePage'>
|
||||
{renderNavbar()}
|
||||
<div className='content'>
|
||||
<SplitPane onDragFinish={handleSplitMove}>
|
||||
@@ -210,8 +241,8 @@ const NewPage = (props) => {
|
||||
renderer={currentBrew.renderer}
|
||||
userThemes={props.userThemes}
|
||||
themeBundle={themeBundle}
|
||||
onCursorPageChange={handleEditorCursorPageChange}
|
||||
onViewPageChange={handleEditorViewPageChange}
|
||||
onCursorPageChange={setCurrentEditorCursorPageNum}
|
||||
onViewPageChange={setCurrentEditorViewPageNum}
|
||||
currentEditorViewPageNum={currentEditorViewPageNum}
|
||||
currentEditorCursorPageNum={currentEditorCursorPageNum}
|
||||
currentBrewRendererPageNum={currentBrewRendererPageNum}
|
||||
@@ -224,7 +255,7 @@ const NewPage = (props) => {
|
||||
themeBundle={themeBundle}
|
||||
errors={HTMLErrors}
|
||||
lang={currentBrew.lang}
|
||||
onPageChange={handleBrewRendererPageChange}
|
||||
onPageChange={setCurrentBrewRendererPageNum}
|
||||
currentEditorViewPageNum={currentEditorViewPageNum}
|
||||
currentEditorCursorPageNum={currentEditorCursorPageNum}
|
||||
currentBrewRendererPageNum={currentBrewRendererPageNum}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
.newPage {
|
||||
.navItem.save {
|
||||
.fadeInRight();
|
||||
.transition(opacity);
|
||||
background-color : @orange;
|
||||
&:hover { background-color : @green; }
|
||||
&.neverSaved {
|
||||
.fadeOutRight();
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
.vaultPage {
|
||||
height : 100%;
|
||||
overflow-y : hidden;
|
||||
background-color : #2C3E50;
|
||||
|
||||
*:not(input) { user-select : none; }
|
||||
|
||||
.form {
|
||||
background:white;
|
||||
}
|
||||
|
||||
:where(.content .dataGroup) {
|
||||
width : 100%;
|
||||
height : 100%;
|
||||
background : white;
|
||||
|
||||
&.form .brewLookup {
|
||||
position : relative;
|
||||
@@ -171,7 +173,6 @@
|
||||
max-height : 100%;
|
||||
padding : 70px 50px;
|
||||
overflow-y : scroll;
|
||||
background-color : #2C3E50;
|
||||
container-type : inline-size;
|
||||
|
||||
h3 { font-size : 25px; }
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
const getLocalStorageMap = function(){
|
||||
const localStorageMap = {
|
||||
'AUTOSAVE_ON' : 'HB_editor_autoSaveOn',
|
||||
'HOMEBREWERY-EDITOR-THEME' : 'HB_editor_theme',
|
||||
'liveScroll' : 'HB_editor_liveScroll',
|
||||
'naturalcrit-pane-split' : 'HB_editor_splitWidth',
|
||||
|
||||
'HOMEBREWERY-LISTPAGE-SORTDIR' : 'HB_listPage_sortDir',
|
||||
'HOMEBREWERY-LISTPAGE-SORTTYPE' : 'HB_listPage_sortType',
|
||||
'HOMEBREWERY-LISTPAGE-VISIBILITY-published' : 'HB_listPage_visibility_group_published',
|
||||
'HOMEBREWERY-LISTPAGE-VISIBILITY-unpublished' : 'HB_listPage_visibility_group_unpublished',
|
||||
|
||||
'hbAdminTab' : 'HB_adminPage_currentTab',
|
||||
|
||||
'homebrewery-new' : 'HB_newPage_content',
|
||||
'homebrewery-new-meta' : 'HB_newPage_metadata',
|
||||
'homebrewery-new-style' : 'HB_newPage_style',
|
||||
|
||||
'homebrewery-recently-edited' : 'HB_nav_recentlyEdited',
|
||||
'homebrewery-recently-viewed' : 'HB_nav_recentlyViewed',
|
||||
|
||||
'hb_toolbarState' : 'HB_renderer_toolbarState',
|
||||
'hb_toolbarVisibility' : 'HB_renderer_toolbarVisibility'
|
||||
};
|
||||
|
||||
if(global?.account?.username){
|
||||
const username = global.account.username;
|
||||
localStorageMap[`HOMEBREWERY-DEFAULT-SAVE-LOCATION-${username}`] = `HB_editor_defaultSave_${username}`;
|
||||
}
|
||||
|
||||
return localStorageMap;
|
||||
};
|
||||
|
||||
export default getLocalStorageMap;
|
||||
@@ -0,0 +1,22 @@
|
||||
import getLocalStorageMap from './localStorageKeyMap.js';
|
||||
|
||||
const updateLocalStorage = function(){
|
||||
// Return if no window and thus no local storage
|
||||
if(typeof window === 'undefined') return;
|
||||
|
||||
const localStorageKeyMap = getLocalStorageMap();
|
||||
const storage = window.localStorage;
|
||||
|
||||
Object.keys(localStorageKeyMap).forEach((key)=>{
|
||||
if(storage[key]){
|
||||
if(!storage[localStorageKeyMap[key]]){
|
||||
const data = storage.getItem(key);
|
||||
storage.setItem(localStorageKeyMap[key], data);
|
||||
};
|
||||
storage.removeItem(key);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
export { updateLocalStorage };
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"development": true,
|
||||
"host" : "homebrewery.local.naturalcrit.com:8000",
|
||||
"naturalcrit_url" : "local.naturalcrit.com:8010",
|
||||
"secret" : "secret",
|
||||
"web_port" : 8000,
|
||||
"enable_v3" : true,
|
||||
"enable_themes" : true,
|
||||
"local_environments" : ["docker", "local"],
|
||||
"publicUrl" : "https://homebrewery.naturalcrit.com",
|
||||
"hb_images" : null,
|
||||
|
||||
992
package-lock.json
generated
992
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@@ -83,11 +83,11 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.27.1",
|
||||
"@babel/plugin-transform-runtime": "^7.28.0",
|
||||
"@babel/preset-env": "^7.28.0",
|
||||
"@babel/core": "^7.28.4",
|
||||
"@babel/plugin-transform-runtime": "^7.28.3",
|
||||
"@babel/preset-env": "^7.28.3",
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"@babel/runtime": "^7.27.6",
|
||||
"@babel/runtime": "^7.28.4",
|
||||
"@dmsnell/diff-match-patch": "^1.1.0",
|
||||
"@googleapis/drive": "^13.0.1",
|
||||
"@sanity/diff-match-patch": "^3.2.0",
|
||||
@@ -95,7 +95,7 @@
|
||||
"classnames": "^2.5.1",
|
||||
"codemirror": "^5.65.6",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"core-js": "^3.44.0",
|
||||
"core-js": "^3.46.0",
|
||||
"cors": "^2.8.5",
|
||||
"create-react-class": "^15.7.0",
|
||||
"dedent-tabs": "^0.10.3",
|
||||
@@ -104,7 +104,7 @@
|
||||
"express-async-handler": "^1.2.0",
|
||||
"express-static-gzip": "3.0.0",
|
||||
"fflate": "^0.8.2",
|
||||
"fs-extra": "11.3.0",
|
||||
"fs-extra": "11.3.2",
|
||||
"hash-wasm": "^4.12.0",
|
||||
"idb-keyval": "^6.2.2",
|
||||
"js-yaml": "^4.1.0",
|
||||
@@ -119,16 +119,16 @@
|
||||
"marked-gfm-heading-id": "^4.1.2",
|
||||
"marked-nonbreaking-spaces": "^1.0.1",
|
||||
"marked-smartypants-lite": "^1.0.3",
|
||||
"marked-subsuper-text": "^1.0.3",
|
||||
"marked-subsuper-text": "^1.0.4",
|
||||
"markedLegacy": "npm:marked@^0.3.19",
|
||||
"moment": "^2.30.1",
|
||||
"mongoose": "^8.16.3",
|
||||
"nanoid": "5.1.5",
|
||||
"mongoose": "^8.19.1",
|
||||
"nanoid": "5.1.6",
|
||||
"nconf": "^0.13.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-frame-component": "^4.1.3",
|
||||
"react-router": "^7.6.3",
|
||||
"react-router": "^7.9.4",
|
||||
"romans": "^3.1.0",
|
||||
"sanitize-filename": "1.6.3",
|
||||
"superagent": "^10.2.1",
|
||||
@@ -138,15 +138,15 @@
|
||||
"devDependencies": {
|
||||
"@stylistic/stylelint-plugin": "^4.0.0",
|
||||
"babel-plugin-transform-import-meta": "^2.3.3",
|
||||
"eslint": "^9.35.0",
|
||||
"eslint": "^9.37.0",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"globals": "^16.3.0",
|
||||
"jest": "^30.1.3",
|
||||
"globals": "^16.4.0",
|
||||
"jest": "^30.2.0",
|
||||
"jest-expect-message": "^1.1.3",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"postcss-less": "^6.0.0",
|
||||
"stylelint": "^16.24.0",
|
||||
"stylelint": "^16.25.0",
|
||||
"stylelint-config-recess-order": "^7.3.0",
|
||||
"stylelint-config-recommended": "^17.0.0",
|
||||
"supertest": "^7.1.4"
|
||||
|
||||
@@ -35,6 +35,7 @@ import contentNegotiation from './middleware/content-negotiation.js';
|
||||
import bodyParser from 'body-parser';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import forceSSL from './forcessl.mw.js';
|
||||
import dbCheck from './middleware/dbCheck.js';
|
||||
|
||||
|
||||
const sanitizeBrew = (brew, accessType)=>{
|
||||
@@ -274,7 +275,7 @@ app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
||||
app.get('/css/:id', asyncHandler(getBrew('share')), (req, res)=>{getCSS(req, res);});
|
||||
|
||||
//User Page
|
||||
app.get('/user/:username', async (req, res, next)=>{
|
||||
app.get('/user/:username', dbCheck, async (req, res, next)=>{
|
||||
const ownAccount = req.account && (req.account.username == req.params.username);
|
||||
|
||||
req.ogMeta = { ...defaultMetaTags,
|
||||
@@ -346,7 +347,7 @@ app.get('/user/:username', async (req, res, next)=>{
|
||||
});
|
||||
|
||||
//Change author name on brews
|
||||
app.put('/api/user/rename', async (req, res)=>{
|
||||
app.put('/api/user/rename', dbCheck, async (req, res)=>{
|
||||
const { username, newUsername } = req.body;
|
||||
const ownAccount = req.account && (req.account.username == newUsername);
|
||||
|
||||
@@ -432,7 +433,7 @@ app.get('/new', asyncHandler(async(req, res, next)=>{
|
||||
}));
|
||||
|
||||
//Share Page
|
||||
app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, res, next)=>{
|
||||
app.get('/share/:id', dbCheck, asyncHandler(getBrew('share')), asyncHandler(async (req, res, next)=>{
|
||||
const { brew } = req;
|
||||
req.ogMeta = { ...defaultMetaTags,
|
||||
title : `${req.brew.title || 'Untitled Brew'} - ${req.brew.authors[0] || 'No author.'}`,
|
||||
@@ -459,7 +460,7 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
|
||||
}));
|
||||
|
||||
//Account Page
|
||||
app.get('/account', asyncHandler(async (req, res, next)=>{
|
||||
app.get('/account', dbCheck, asyncHandler(async (req, res, next)=>{
|
||||
const data = {};
|
||||
data.title = 'Account Information Page';
|
||||
|
||||
@@ -562,8 +563,6 @@ const renderPage = async (req, res)=>{
|
||||
brews : req.brews,
|
||||
googleBrews : req.googleBrews,
|
||||
account : req.account,
|
||||
enable_v3 : config.get('enable_v3'),
|
||||
enable_themes : config.get('enable_themes'),
|
||||
config : configuration,
|
||||
ogMeta : req.ogMeta,
|
||||
userThemes : req.userThemes
|
||||
|
||||
12
server/db.js
12
server/db.js
@@ -22,6 +22,14 @@ const handleConnectionError = (error)=>{
|
||||
}
|
||||
};
|
||||
|
||||
const addListeners = (conn)=>{
|
||||
conn.connection.on('disconnecting', ()=>{console.log('Mongo disconnecting...');});
|
||||
conn.connection.on('disconnected', ()=>{console.log('Mongo disconnected!');});
|
||||
conn.connection.on('connecting', ()=>{console.log('Mongo connecting...');});
|
||||
conn.connection.on('connected', ()=>{console.log('Mongo connected!');});
|
||||
return conn;
|
||||
};
|
||||
|
||||
const disconnect = async ()=>{
|
||||
return await Mongoose.disconnect();
|
||||
};
|
||||
@@ -31,10 +39,12 @@ const connect = async (config)=>{
|
||||
retryWrites : false,
|
||||
autoIndex : (config.get('local_environments').includes(config.get('node_env')))
|
||||
})
|
||||
.catch((error)=>handleConnectionError(error));
|
||||
.then(addListeners(Mongoose))
|
||||
.catch((error)=>handleConnectionError(error));
|
||||
};
|
||||
|
||||
export default {
|
||||
connect,
|
||||
disconnect
|
||||
};
|
||||
|
||||
|
||||
@@ -8,11 +8,12 @@ import Markdown from '../shared/naturalcrit/markdown.js';
|
||||
import yaml from 'js-yaml';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import { nanoid } from 'nanoid';
|
||||
import {makePatches, applyPatches, stringifyPatches, parsePatch} from '@sanity/diff-match-patch';
|
||||
import { makePatches, applyPatches, stringifyPatches, parsePatch } from '@sanity/diff-match-patch';
|
||||
import { md5 } from 'hash-wasm';
|
||||
import { splitTextStyleAndMetadata,
|
||||
import { splitTextStyleAndMetadata,
|
||||
brewSnippetsToJSON, debugTextMismatch } from '../shared/helpers.js';
|
||||
import checkClientVersion from './middleware/check-client-version.js';
|
||||
import dbCheck from './middleware/dbCheck.js';
|
||||
|
||||
|
||||
const router = express.Router();
|
||||
@@ -377,14 +378,14 @@ const api = {
|
||||
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
|
||||
const patchedResult = decodeURI(applyPatches(patches, encodeURI(brewFromServer.text))[0]);
|
||||
if(patchedResult != brewFromClient.text)
|
||||
throw("Patches did not apply cleanly, text mismatch detected");
|
||||
throw ('Patches did not apply cleanly, text mismatch detected');
|
||||
// brew.text = applyPatches(patches, brewFromServer.text)[0];
|
||||
} catch (err) {
|
||||
//debugTextMismatch(brewFromClient.text, brewFromServer.text, `edit/${brewFromClient.editId}`);
|
||||
console.error('Failed to apply patches:', {
|
||||
//patches : brewFromClient.patches,
|
||||
brewId : brewFromClient.editId || 'unknown',
|
||||
error : err
|
||||
brewId : brewFromClient.editId || 'unknown',
|
||||
error : err
|
||||
});
|
||||
// While running in parallel, don't throw the error upstream.
|
||||
// throw err; // rethrow to preserve the 500 behavior
|
||||
@@ -480,6 +481,7 @@ const api = {
|
||||
await HomebrewModel.deleteOne({ editId: id });
|
||||
return next();
|
||||
}
|
||||
throw(err);
|
||||
}
|
||||
|
||||
let brew = req.brew;
|
||||
@@ -530,6 +532,8 @@ const api = {
|
||||
}
|
||||
};
|
||||
|
||||
router.use(dbCheck);
|
||||
|
||||
router.post('/api', checkClientVersion, asyncHandler(api.newBrew));
|
||||
router.put('/api/:id', checkClientVersion, asyncHandler(api.getBrew('edit', false)), asyncHandler(api.updateBrew));
|
||||
router.put('/api/update/:id', checkClientVersion, asyncHandler(api.getBrew('edit', false)), asyncHandler(api.updateBrew));
|
||||
|
||||
15
server/middleware/dbCheck.js
Normal file
15
server/middleware/dbCheck.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import mongoose from 'mongoose';
|
||||
import config from '../config.js';
|
||||
|
||||
export default (req, res, next)=>{
|
||||
// Bypass DB checks during testing
|
||||
if(config.get('node_env') == 'test') return next();
|
||||
|
||||
if(mongoose.connection.readyState == 1) return next();
|
||||
throw {
|
||||
HBErrorCode : '13',
|
||||
name : 'Database Connection Error',
|
||||
message : 'Unable to connect to database',
|
||||
status : mongoose.connection.readyState
|
||||
};
|
||||
};
|
||||
28
server/middleware/dbCheck.spec.js
Normal file
28
server/middleware/dbCheck.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import mongoose from 'mongoose';
|
||||
import dbCheck from './dbCheck.js';
|
||||
import config from '../config.js';
|
||||
|
||||
describe('dbCheck middleware', ()=>{
|
||||
const next = jest.fn();
|
||||
|
||||
afterEach(()=>jest.clearAllMocks());
|
||||
|
||||
it('should skip check in test mode', ()=>{
|
||||
config.get = jest.fn(()=>'test');
|
||||
expect(()=>dbCheck({}, {}, next)).not.toThrow();
|
||||
expect(next).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call next if readyState == 1', ()=>{
|
||||
config.get = jest.fn(()=>'production');
|
||||
mongoose.connection.readyState = 1;
|
||||
dbCheck({}, {}, next);
|
||||
expect(next).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should throw if readyState != 1', ()=>{
|
||||
config.get = jest.fn(()=>'production');
|
||||
mongoose.connection.readyState = 99;
|
||||
expect(()=>dbCheck({}, {}, next)).toThrow(/Unable to connect/);
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@ const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets=nul
|
||||
const mpAsSnippets = [];
|
||||
// Snippets from Themes first.
|
||||
if(themeBundleSnippets) {
|
||||
for (let themes of themeBundleSnippets) {
|
||||
for (const themes of themeBundleSnippets) {
|
||||
if(typeof themes !== 'string') {
|
||||
const userSnippets = [];
|
||||
const snipSplit = themes.snippets.trim().split(textSplit).slice(1);
|
||||
@@ -76,9 +76,9 @@ const yamlSnippetsToText = (yamlObj)=>{
|
||||
if(typeof yamlObj == 'string') return yamlObj;
|
||||
|
||||
let snippetsText = '';
|
||||
|
||||
for (let snippet of yamlObj) {
|
||||
for (let subSnippet of snippet.subsnippets) {
|
||||
|
||||
for (const snippet of yamlObj) {
|
||||
for (const subSnippet of snippet.subsnippets) {
|
||||
snippetsText = `${snippetsText}\\snippet ${subSnippet.name}\n${subSnippet.gen || ''}\n`;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
|
||||
const res = await request
|
||||
.get(`/api/theme/${renderer}/${theme}`)
|
||||
.catch((err)=>{
|
||||
setError(err)
|
||||
setError(err);
|
||||
});
|
||||
if(!res) {
|
||||
setThemeBundle({});
|
||||
@@ -133,14 +133,14 @@ const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
|
||||
setError(null);
|
||||
};
|
||||
|
||||
const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
|
||||
const debugTextMismatch = (clientTextRaw, serverTextRaw, label)=>{
|
||||
const clientText = clientTextRaw?.normalize('NFC') || '';
|
||||
const serverText = serverTextRaw?.normalize('NFC') || '';
|
||||
|
||||
const clientBuffer = Buffer.from(clientText, 'utf8');
|
||||
const serverBuffer = Buffer.from(serverText, 'utf8');
|
||||
|
||||
if (clientBuffer.equals(serverBuffer)) {
|
||||
if(clientBuffer.equals(serverBuffer)) {
|
||||
console.log(`✅ ${label} text matches byte-for-byte.`);
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
|
||||
|
||||
// Byte-level diff
|
||||
for (let i = 0; i < Math.min(clientBuffer.length, serverBuffer.length); i++) {
|
||||
if (clientBuffer[i] !== serverBuffer[i]) {
|
||||
if(clientBuffer[i] !== serverBuffer[i]) {
|
||||
console.log(`Byte mismatch at offset ${i}: client=0x${clientBuffer[i].toString(16)} server=0x${serverBuffer[i].toString(16)}`);
|
||||
break;
|
||||
}
|
||||
@@ -159,14 +159,14 @@ const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
|
||||
|
||||
// Char-level diff
|
||||
for (let i = 0; i < Math.min(clientText.length, serverText.length); i++) {
|
||||
if (clientText[i] !== serverText[i]) {
|
||||
if(clientText[i] !== serverText[i]) {
|
||||
console.log(`Char mismatch at index ${i}:`);
|
||||
console.log(` Client: '${clientText[i]}' (U+${clientText.charCodeAt(i).toString(16).toUpperCase()})`);
|
||||
console.log(` Server: '${serverText[i]}' (U+${serverText.charCodeAt(i).toString(16).toUpperCase()})`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
splitTextStyleAndMetadata,
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
animation-duration : 0.4s;
|
||||
}
|
||||
|
||||
.CodeMirror-search-field {
|
||||
width:25em !important;
|
||||
outline:1px inset #00000055 !important;
|
||||
}
|
||||
|
||||
//.cm-tab {
|
||||
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right;
|
||||
//}
|
||||
|
||||
@@ -435,7 +435,7 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) {
|
||||
|
||||
try {
|
||||
return mathParser.evaluate(replacedLabel);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return undefined; // Return undefined if invalid math result
|
||||
}
|
||||
}
|
||||
@@ -680,7 +680,7 @@ const tableTerminators = [
|
||||
|
||||
Marked.use(MarkedVariables());
|
||||
Marked.use(MarkedDefinitionLists());
|
||||
Marked.use({ extensions : [forcedParagraphBreaks, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||
Marked.use({ extensions: [forcedParagraphBreaks, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||
Marked.use(mustacheInjectBlock);
|
||||
Marked.use(MarkedAlignedParagraphs());
|
||||
Marked.use(MarkedSubSuperText());
|
||||
|
||||
@@ -49,7 +49,7 @@ const cleanUrl = function (sanitize, base, href) {
|
||||
prot = decodeURIComponent(unescape(href))
|
||||
.replace(nonWordAndColonTest, '')
|
||||
.toLowerCase();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
if(prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
||||
@@ -58,7 +58,7 @@ const cleanUrl = function (sanitize, base, href) {
|
||||
}
|
||||
try {
|
||||
href = encodeURI(href).replace(/%25/g, '%');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return href;
|
||||
|
||||
@@ -418,6 +418,7 @@
|
||||
color : var(--HB_Color_Footnotes);
|
||||
}
|
||||
.footnote {
|
||||
text-transform: uppercase;
|
||||
position : absolute;
|
||||
right : 80px;
|
||||
bottom : 32px;
|
||||
|
||||
@@ -611,3 +611,17 @@ h6,
|
||||
}
|
||||
.toc.wide li { break-inside : auto; }
|
||||
}
|
||||
|
||||
|
||||
/**********************************
|
||||
Firefox endruns
|
||||
**********************************/
|
||||
|
||||
@supports (-moz-user-select: none) { // This section will only apply to Firefox; it's the only browser that supports `-mos-xyz...`
|
||||
.page {
|
||||
blockquote, table {
|
||||
page-break-inside: auto;
|
||||
break-inside: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ const diceFont = {
|
||||
'df_d10_7' : 'df d10-7',
|
||||
'df_d10_8' : 'df d10-8',
|
||||
'df_d10_9' : 'df d10-9',
|
||||
'df_d10_0' : 'df d10-0',
|
||||
'df_d12' : 'df d12',
|
||||
'df_d12_1' : 'df d12-1',
|
||||
'df_d12_10' : 'df d12-10',
|
||||
@@ -90,7 +91,108 @@ const diceFont = {
|
||||
'df_solid_small_dot_d6_3' : 'df solid-small-dot-d6-3',
|
||||
'df_solid_small_dot_d6_4' : 'df solid-small-dot-d6-4',
|
||||
'df_solid_small_dot_d6_5' : 'df solid-small-dot-d6-5',
|
||||
'df_solid_small_dot_d6_6' : 'df solid-small-dot-d6-6'
|
||||
'df_solid_small_dot_d6_6' : 'df solid-small-dot-d6-6',
|
||||
'df_d10_00' : 'df d10-00',
|
||||
'df_d10_01' : 'df d10-01',
|
||||
'df_d10_02' : 'df d10-02',
|
||||
'df_d10_03' : 'df d10-03',
|
||||
'df_d10_04' : 'df d10-04',
|
||||
'df_d10_05' : 'df d10-05',
|
||||
'df_d10_06' : 'df d10-06',
|
||||
'df_d10_07' : 'df d10-07',
|
||||
'df_d10_08' : 'df d10-08',
|
||||
'df_d10_09' : 'df d10-09',
|
||||
'df_d10_10' : 'df d10-10',
|
||||
'df_d10_11' : 'df d10-11',
|
||||
'df_d10_12' : 'df d10-12',
|
||||
'df_d10_13' : 'df d10-13',
|
||||
'df_d10_14' : 'df d10-14',
|
||||
'df_d10_15' : 'df d10-15',
|
||||
'df_d10_16' : 'df d10-16',
|
||||
'df_d10_17' : 'df d10-17',
|
||||
'df_d10_18' : 'df d10-18',
|
||||
'df_d10_19' : 'df d10-19',
|
||||
'df_d10_20' : 'df d10-20',
|
||||
'df_d10_21' : 'df d10-21',
|
||||
'df_d10_22' : 'df d10-22',
|
||||
'df_d10_23' : 'df d10-23',
|
||||
'df_d10_24' : 'df d10-24',
|
||||
'df_d10_25' : 'df d10-25',
|
||||
'df_d10_26' : 'df d10-26',
|
||||
'df_d10_27' : 'df d10-27',
|
||||
'df_d10_28' : 'df d10-28',
|
||||
'df_d10_29' : 'df d10-29',
|
||||
'df_d10_30' : 'df d10-30',
|
||||
'df_d10_31' : 'df d10-31',
|
||||
'df_d10_32' : 'df d10-32',
|
||||
'df_d10_33' : 'df d10-33',
|
||||
'df_d10_34' : 'df d10-34',
|
||||
'df_d10_35' : 'df d10-35',
|
||||
'df_d10_36' : 'df d10-36',
|
||||
'df_d10_37' : 'df d10-37',
|
||||
'df_d10_38' : 'df d10-38',
|
||||
'df_d10_39' : 'df d10-39',
|
||||
'df_d10_40' : 'df d10-40',
|
||||
'df_d10_41' : 'df d10-41',
|
||||
'df_d10_42' : 'df d10-42',
|
||||
'df_d10_43' : 'df d10-43',
|
||||
'df_d10_44' : 'df d10-44',
|
||||
'df_d10_45' : 'df d10-45',
|
||||
'df_d10_46' : 'df d10-46',
|
||||
'df_d10_47' : 'df d10-47',
|
||||
'df_d10_48' : 'df d10-48',
|
||||
'df_d10_49' : 'df d10-49',
|
||||
'df_d10_50' : 'df d10-50',
|
||||
'df_d10_51' : 'df d10-51',
|
||||
'df_d10_52' : 'df d10-52',
|
||||
'df_d10_53' : 'df d10-53',
|
||||
'df_d10_54' : 'df d10-54',
|
||||
'df_d10_55' : 'df d10-55',
|
||||
'df_d10_56' : 'df d10-56',
|
||||
'df_d10_57' : 'df d10-57',
|
||||
'df_d10_58' : 'df d10-58',
|
||||
'df_d10_59' : 'df d10-59',
|
||||
'df_d10_60' : 'df d10-60',
|
||||
'df_d10_61' : 'df d10-61',
|
||||
'df_d10_62' : 'df d10-62',
|
||||
'df_d10_63' : 'df d10-63',
|
||||
'df_d10_64' : 'df d10-64',
|
||||
'df_d10_65' : 'df d10-65',
|
||||
'df_d10_66' : 'df d10-66',
|
||||
'df_d10_67' : 'df d10-67',
|
||||
'df_d10_68' : 'df d10-68',
|
||||
'df_d10_69' : 'df d10-69',
|
||||
'df_d10_70' : 'df d10-70',
|
||||
'df_d10_71' : 'df d10-71',
|
||||
'df_d10_72' : 'df d10-72',
|
||||
'df_d10_73' : 'df d10-73',
|
||||
'df_d10_74' : 'df d10-74',
|
||||
'df_d10_75' : 'df d10-75',
|
||||
'df_d10_76' : 'df d10-76',
|
||||
'df_d10_77' : 'df d10-77',
|
||||
'df_d10_78' : 'df d10-78',
|
||||
'df_d10_79' : 'df d10-79',
|
||||
'df_d10_80' : 'df d10-80',
|
||||
'df_d10_81' : 'df d10-81',
|
||||
'df_d10_82' : 'df d10-82',
|
||||
'df_d10_83' : 'df d10-83',
|
||||
'df_d10_84' : 'df d10-84',
|
||||
'df_d10_85' : 'df d10-85',
|
||||
'df_d10_86' : 'df d10-86',
|
||||
'df_d10_87' : 'df d10-87',
|
||||
'df_d10_88' : 'df d10-88',
|
||||
'df_d10_89' : 'df d10-89',
|
||||
'df_d10_90' : 'df d10-90',
|
||||
'df_d10_91' : 'df d10-91',
|
||||
'df_d10_92' : 'df d10-92',
|
||||
'df_d10_93' : 'df d10-93',
|
||||
'df_d10_94' : 'df d10-94',
|
||||
'df_d10_95' : 'df d10-95',
|
||||
'df_d10_96' : 'df d10-96',
|
||||
'df_d10_97' : 'df d10-97',
|
||||
'df_d10_98' : 'df d10-98',
|
||||
'df_d10_99' : 'df d10-99',
|
||||
'df_d10_100' : 'df d10-100'
|
||||
};
|
||||
|
||||
export default diceFont;
|
||||
@@ -6,6 +6,14 @@
|
||||
src : url('../../../fonts/iconFonts/diceFont.woff2');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family : 'DiceFontD100';
|
||||
src : url('../../../fonts/iconFonts/diceFontD100.woff2') format('woff2');
|
||||
font-weight : normal;
|
||||
font-style : normal;
|
||||
font-display : block;
|
||||
}
|
||||
|
||||
.df {
|
||||
display : inline;
|
||||
font-family : 'DiceFont';
|
||||
@@ -26,17 +34,6 @@
|
||||
&.F-plus::before { content : '\f192'; }
|
||||
&.F-zero::before { content : '\f193'; }
|
||||
&.d10::before { content : '\f194'; }
|
||||
&.d10-0::before { content : '\f100'; }
|
||||
&.d10-1::before { content : '\f101'; }
|
||||
&.d10-10::before { content : '\f102'; }
|
||||
&.d10-2::before { content : '\f103'; }
|
||||
&.d10-3::before { content : '\f104'; }
|
||||
&.d10-4::before { content : '\f105'; }
|
||||
&.d10-5::before { content : '\f106'; }
|
||||
&.d10-6::before { content : '\f107'; }
|
||||
&.d10-7::before { content : '\f108'; }
|
||||
&.d10-8::before { content : '\f109'; }
|
||||
&.d10-9::before { content : '\f10a'; }
|
||||
&.d12::before { content : '\f195'; }
|
||||
&.d12-1::before { content : '\f10b'; }
|
||||
&.d12-10::before { content : '\f10c'; }
|
||||
@@ -114,4 +111,568 @@
|
||||
&.solid-small-dot-d6-4::before { content : '\f18c'; }
|
||||
&.solid-small-dot-d6-5::before { content : '\f18d'; }
|
||||
&.solid-small-dot-d6-6::before { content : '\f18e'; }
|
||||
|
||||
// Replacement d10
|
||||
|
||||
&.d10-0::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e900';
|
||||
}
|
||||
|
||||
&.d10-1::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e901';
|
||||
}
|
||||
|
||||
&.d10-2::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e902';
|
||||
}
|
||||
|
||||
&.d10-3::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e903';
|
||||
}
|
||||
|
||||
&.d10-4::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e904';
|
||||
}
|
||||
|
||||
&.d10-5::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e905';
|
||||
}
|
||||
|
||||
&.d10-6::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e906';
|
||||
}
|
||||
|
||||
&.d10-7::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e907';
|
||||
}
|
||||
|
||||
&.d10-8::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e908';
|
||||
}
|
||||
|
||||
&.d10-9::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e909';
|
||||
}
|
||||
|
||||
&.d10-10::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e90a';
|
||||
}
|
||||
|
||||
// d100
|
||||
|
||||
&.d10-00::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e90b';
|
||||
}
|
||||
|
||||
&.d10-01::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e90c';
|
||||
}
|
||||
|
||||
&.d10-02::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e90d';
|
||||
}
|
||||
|
||||
&.d10-03::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e90e';
|
||||
}
|
||||
|
||||
&.d10-04::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e90f';
|
||||
}
|
||||
|
||||
&.d10-05::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e910';
|
||||
}
|
||||
|
||||
&.d10-06::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e911';
|
||||
}
|
||||
|
||||
&.d10-07::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e912';
|
||||
}
|
||||
|
||||
&.d10-08::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e913';
|
||||
}
|
||||
|
||||
&.d10-09::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e914';
|
||||
}
|
||||
|
||||
&.d10-10::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e915';
|
||||
}
|
||||
|
||||
&.d10-11::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e916';
|
||||
}
|
||||
|
||||
&.d10-12::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e917';
|
||||
}
|
||||
|
||||
&.d10-13::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e918';
|
||||
}
|
||||
|
||||
&.d10-14::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e919';
|
||||
}
|
||||
|
||||
&.d10-15::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e91a';
|
||||
}
|
||||
|
||||
&.d10-16::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e91b';
|
||||
}
|
||||
|
||||
&.d10-17::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e91c';
|
||||
}
|
||||
|
||||
&.d10-18::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e91d';
|
||||
}
|
||||
|
||||
&.d10-19::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e91e';
|
||||
}
|
||||
|
||||
&.d10-20::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e91f';
|
||||
}
|
||||
|
||||
&.d10-21::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e920';
|
||||
}
|
||||
|
||||
&.d10-22::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e921';
|
||||
}
|
||||
|
||||
&.d10-23::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e922';
|
||||
}
|
||||
|
||||
&.d10-24::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e923';
|
||||
}
|
||||
|
||||
&.d10-25::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e924';
|
||||
}
|
||||
|
||||
&.d10-26::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e925';
|
||||
}
|
||||
|
||||
&.d10-27::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e926';
|
||||
}
|
||||
|
||||
&.d10-28::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e927';
|
||||
}
|
||||
|
||||
&.d10-29::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e928';
|
||||
}
|
||||
|
||||
&.d10-30::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e929';
|
||||
}
|
||||
|
||||
&.d10-31::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e92a';
|
||||
}
|
||||
|
||||
&.d10-32::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e92b';
|
||||
}
|
||||
|
||||
&.d10-33::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e92c';
|
||||
}
|
||||
|
||||
&.d10-34::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e92d';
|
||||
}
|
||||
|
||||
&.d10-35::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e92e';
|
||||
}
|
||||
|
||||
&.d10-36::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e92f';
|
||||
}
|
||||
|
||||
&.d10-37::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e930';
|
||||
}
|
||||
|
||||
&.d10-38::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e931';
|
||||
}
|
||||
|
||||
&.d10-39::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e932';
|
||||
}
|
||||
|
||||
&.d10-40::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e933';
|
||||
}
|
||||
|
||||
&.d10-41::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e934';
|
||||
}
|
||||
|
||||
&.d10-42::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e935';
|
||||
}
|
||||
|
||||
&.d10-43::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e936';
|
||||
}
|
||||
|
||||
&.d10-44::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e937';
|
||||
}
|
||||
|
||||
&.d10-45::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e938';
|
||||
}
|
||||
|
||||
&.d10-46::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e939';
|
||||
}
|
||||
|
||||
&.d10-47::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e93a';
|
||||
}
|
||||
|
||||
&.d10-48::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e93b';
|
||||
}
|
||||
|
||||
&.d10-49::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e93c';
|
||||
}
|
||||
|
||||
&.d10-50::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e93d';
|
||||
}
|
||||
|
||||
&.d10-51::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e93e';
|
||||
}
|
||||
|
||||
&.d10-52::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e93f';
|
||||
}
|
||||
|
||||
&.d10-53::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e940';
|
||||
}
|
||||
|
||||
&.d10-54::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e941';
|
||||
}
|
||||
|
||||
&.d10-55::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e942';
|
||||
}
|
||||
|
||||
&.d10-56::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e943';
|
||||
}
|
||||
|
||||
&.d10-57::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e944';
|
||||
}
|
||||
|
||||
&.d10-58::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e945';
|
||||
}
|
||||
|
||||
&.d10-59::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e946';
|
||||
}
|
||||
|
||||
&.d10-60::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e947';
|
||||
}
|
||||
|
||||
&.d10-61::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e948';
|
||||
}
|
||||
|
||||
&.d10-62::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e949';
|
||||
}
|
||||
|
||||
&.d10-63::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e94a';
|
||||
}
|
||||
|
||||
&.d10-64::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e94b';
|
||||
}
|
||||
|
||||
&.d10-65::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e94c';
|
||||
}
|
||||
|
||||
&.d10-66::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e94d';
|
||||
}
|
||||
|
||||
&.d10-67::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e94e';
|
||||
}
|
||||
|
||||
&.d10-68::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e94f';
|
||||
}
|
||||
|
||||
&.d10-69::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e950';
|
||||
}
|
||||
|
||||
&.d10-70::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e951';
|
||||
}
|
||||
|
||||
&.d10-71::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e952';
|
||||
}
|
||||
|
||||
&.d10-72::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e953';
|
||||
}
|
||||
|
||||
&.d10-73::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e954';
|
||||
}
|
||||
|
||||
&.d10-74::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e955';
|
||||
}
|
||||
|
||||
&.d10-75::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e956';
|
||||
}
|
||||
|
||||
&.d10-76::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e957';
|
||||
}
|
||||
|
||||
&.d10-77::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e958';
|
||||
}
|
||||
|
||||
&.d10-78::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e959';
|
||||
}
|
||||
|
||||
&.d10-79::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e95a';
|
||||
}
|
||||
|
||||
&.d10-80::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e95b';
|
||||
}
|
||||
|
||||
&.d10-81::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e95c';
|
||||
}
|
||||
|
||||
&.d10-82::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e95d';
|
||||
}
|
||||
|
||||
&.d10-83::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e95e';
|
||||
}
|
||||
|
||||
&.d10-84::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e95f';
|
||||
}
|
||||
|
||||
&.d10-85::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e960';
|
||||
}
|
||||
|
||||
&.d10-86::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e961';
|
||||
}
|
||||
|
||||
&.d10-87::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e962';
|
||||
}
|
||||
|
||||
&.d10-88::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e963';
|
||||
}
|
||||
|
||||
&.d10-89::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e964';
|
||||
}
|
||||
|
||||
&.d10-90::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e965';
|
||||
}
|
||||
|
||||
&.d10-91::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e966';
|
||||
}
|
||||
|
||||
&.d10-92::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e967';
|
||||
}
|
||||
|
||||
&.d10-93::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e968';
|
||||
}
|
||||
|
||||
&.d10-94::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e969';
|
||||
}
|
||||
|
||||
&.d10-95::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e96a';
|
||||
}
|
||||
|
||||
&.d10-96::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e96b';
|
||||
}
|
||||
|
||||
&.d10-97::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e96c';
|
||||
}
|
||||
|
||||
&.d10-98::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e96d';
|
||||
}
|
||||
|
||||
&.d10-99::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e96e';
|
||||
}
|
||||
|
||||
&.d10-100::before {
|
||||
font-family : 'DiceFontD100';
|
||||
content : '\e96f';
|
||||
}
|
||||
}
|
||||
BIN
themes/fonts/iconFonts/diceFontD100.woff2
Normal file
BIN
themes/fonts/iconFonts/diceFontD100.woff2
Normal file
Binary file not shown.
Reference in New Issue
Block a user