update eslint and fix linting errors
This commit is contained in:
parent
254bbacba2
commit
c90dac55b7
35 changed files with 1230 additions and 1512 deletions
|
@ -404,7 +404,8 @@ class Nav extends React.PureComponent {
|
||||||
onFocus={this.handleFocus.bind(this, 'help')}
|
onFocus={this.handleFocus.bind(this, 'help')}
|
||||||
onBlur={this.handleBlur}
|
onBlur={this.handleBlur}
|
||||||
onClick={this.setDropdown.bind(this, 'none')}
|
onClick={this.setDropdown.bind(this, 'none')}
|
||||||
>Reference</a>
|
>Reference
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li className="nav__dropdown-item">
|
<li className="nav__dropdown-item">
|
||||||
<Link
|
<Link
|
||||||
|
|
|
@ -3,11 +3,9 @@ import { createDevTools } from 'redux-devtools';
|
||||||
import LogMonitor from 'redux-devtools-log-monitor';
|
import LogMonitor from 'redux-devtools-log-monitor';
|
||||||
import DockMonitor from 'redux-devtools-dock-monitor';
|
import DockMonitor from 'redux-devtools-dock-monitor';
|
||||||
|
|
||||||
export default createDevTools(
|
export default createDevTools(<DockMonitor
|
||||||
<DockMonitor
|
toggleVisibilityKey="ctrl-h"
|
||||||
toggleVisibilityKey="ctrl-h"
|
changePositionKey="ctrl-w"
|
||||||
changePositionKey="ctrl-w"
|
>
|
||||||
>
|
<LogMonitor />
|
||||||
<LogMonitor />
|
</DockMonitor>);
|
||||||
</DockMonitor>
|
|
||||||
);
|
|
||||||
|
|
|
@ -273,9 +273,7 @@ export function setServeSecure(serveSecure, { redirect = true } = {}) {
|
||||||
|
|
||||||
if (redirect === true) {
|
if (redirect === true) {
|
||||||
dispatch(saveProject(false /* autosave */))
|
dispatch(saveProject(false /* autosave */))
|
||||||
.then(
|
.then(() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http));
|
||||||
() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -41,36 +41,38 @@ export function dropzoneAcceptCallback(userId, file, done) {
|
||||||
file.content = result; // eslint-disable-line
|
file.content = result; // eslint-disable-line
|
||||||
done('Uploading plaintext file locally.');
|
done('Uploading plaintext file locally.');
|
||||||
})
|
})
|
||||||
.catch((result) => {
|
.catch((result) => {
|
||||||
done(`Failed to download file ${file.name}: ${result}`);
|
done(`Failed to download file ${file.name}: ${result}`);
|
||||||
console.warn(file);
|
console.warn(file);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
file.postData = []; // eslint-disable-line
|
file.postData = []; // eslint-disable-line
|
||||||
axios.post(`${ROOT_URL}/S3/sign`, {
|
axios.post(
|
||||||
name: file.name,
|
`${ROOT_URL}/S3/sign`, {
|
||||||
type: file.type,
|
name: file.name,
|
||||||
size: file.size,
|
type: file.type,
|
||||||
userId
|
size: file.size,
|
||||||
|
userId
|
||||||
// _csrf: document.getElementById('__createPostToken').value
|
// _csrf: document.getElementById('__createPostToken').value
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
})
|
}
|
||||||
.then((response) => {
|
)
|
||||||
|
.then((response) => {
|
||||||
file.custom_status = 'ready'; // eslint-disable-line
|
file.custom_status = 'ready'; // eslint-disable-line
|
||||||
file.postData = response.data; // eslint-disable-line
|
file.postData = response.data; // eslint-disable-line
|
||||||
file.s3 = response.data.key; // eslint-disable-line
|
file.s3 = response.data.key; // eslint-disable-line
|
||||||
file.previewTemplate.className += ' uploading'; // eslint-disable-line
|
file.previewTemplate.className += ' uploading'; // eslint-disable-line
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
file.custom_status = 'rejected'; // eslint-disable-line
|
file.custom_status = 'rejected'; // eslint-disable-line
|
||||||
if (response.data.responseText && response.data.responseText.message) {
|
if (response.data.responseText && response.data.responseText.message) {
|
||||||
done(response.data.responseText.message);
|
done(response.data.responseText.message);
|
||||||
}
|
}
|
||||||
done('error preparing the upload');
|
done('error preparing the upload');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ function About(props) {
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
||||||
Examples</a>
|
Examples
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p className="about__content-column-list">
|
<p className="about__content-column-list">
|
||||||
<a
|
<a
|
||||||
|
@ -43,7 +44,8 @@ function About(props) {
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
||||||
Learn</a>
|
Learn
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="about__content-column">
|
<div className="about__content-column">
|
||||||
|
@ -55,7 +57,8 @@ function About(props) {
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
||||||
Libraries</a>
|
Libraries
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p className="about__content-column-list">
|
<p className="about__content-column-list">
|
||||||
<a
|
<a
|
||||||
|
@ -64,7 +67,8 @@ function About(props) {
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
||||||
Reference</a>
|
Reference
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p className="about__content-column-list">
|
<p className="about__content-column-list">
|
||||||
<a
|
<a
|
||||||
|
@ -73,7 +77,8 @@ function About(props) {
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
|
||||||
Forum</a>
|
Forum
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="about__footer">
|
<div className="about__footer">
|
||||||
|
@ -82,21 +87,24 @@ function About(props) {
|
||||||
href="https://github.com/processing/p5.js-web-editor"
|
href="https://github.com/processing/p5.js-web-editor"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>Contribute</a>
|
>Contribute
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p className="about__footer-list">
|
<p className="about__footer-list">
|
||||||
<a
|
<a
|
||||||
href="https://github.com/processing/p5.js-web-editor/issues/new"
|
href="https://github.com/processing/p5.js-web-editor/issues/new"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>Report a bug</a>
|
>Report a bug
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p className="about__footer-list">
|
<p className="about__footer-list">
|
||||||
<a
|
<a
|
||||||
href="https://twitter.com/p5xjs?lang=en"
|
href="https://twitter.com/p5xjs?lang=en"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>Twitter</a>
|
>Twitter
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,13 +44,12 @@ class AssetList extends React.Component {
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{this.props.assets.map(asset =>
|
{this.props.assets.map(asset =>
|
||||||
<tr className="asset-table__row" key={asset.key}>
|
(<tr className="asset-table__row" key={asset.key}>
|
||||||
<td>{asset.name}</td>
|
<td>{asset.name}</td>
|
||||||
<td>{prettyBytes(asset.size)}</td>
|
<td>{prettyBytes(asset.size)}</td>
|
||||||
<td><Link to={asset.url} target="_blank">View</Link></td>
|
<td><Link to={asset.url} target="_blank">View</Link></td>
|
||||||
<td><Link to={`/${this.props.username}/sketches/${asset.sketchId}`}>{asset.sketchName}</Link></td>
|
<td><Link to={`/${this.props.username}/sketches/${asset.sketchId}`}>{asset.sketchName}</Link></td>
|
||||||
</tr>
|
</tr>))}
|
||||||
)}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>}
|
</table>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Console extends React.Component {
|
||||||
if (Object.keys(args).length === 0) {
|
if (Object.keys(args).length === 0) {
|
||||||
return (
|
return (
|
||||||
<div key={consoleEvent.id} className="preview-console__undefined">
|
<div key={consoleEvent.id} className="preview-console__undefined">
|
||||||
<span key={`${consoleEvent.id}-0`}>{'undefined'}</span>
|
<span key={`${consoleEvent.id}-0`}>undefined</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ class Console extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.propTypes = {
|
Console.propTypes = {
|
||||||
|
|
|
@ -9,18 +9,14 @@ class EditorAccessibility extends React.Component {
|
||||||
const messages = [];
|
const messages = [];
|
||||||
if (this.props.lintMessages.length > 0) {
|
if (this.props.lintMessages.length > 0) {
|
||||||
this.props.lintMessages.forEach((lintMessage, i) => {
|
this.props.lintMessages.forEach((lintMessage, i) => {
|
||||||
messages.push(
|
messages.push(<li key={lintMessage.id}>
|
||||||
<li key={lintMessage.id}>
|
{lintMessage.severity} in line
|
||||||
{lintMessage.severity} in line
|
{lintMessage.line} :
|
||||||
{lintMessage.line} :
|
{lintMessage.message}
|
||||||
{lintMessage.message}
|
</li>);
|
||||||
</li>
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
messages.push(
|
messages.push(<li tabIndex="0" key={0}> There are no lint messages </li>);
|
||||||
<li tabIndex="0" key={0}> There are no lint messages </li>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="editor-accessibility">
|
<div className="editor-accessibility">
|
||||||
|
|
|
@ -40,7 +40,8 @@ function Feedback(props) {
|
||||||
href="https://docs.google.com/forms/d/e/1FAIpQLSexU8W2EIhXjktl-_XzwjH6vgnelHirH4Yn4liN5BXltPWqBg/viewform"
|
href="https://docs.google.com/forms/d/e/1FAIpQLSexU8W2EIhXjktl-_XzwjH6vgnelHirH4Yn4liN5BXltPWqBg/viewform"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>Go to Form</a>
|
>Go to Form
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -252,7 +252,7 @@ FileNode.defaultProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function mapStateToProps(state, ownProps) {
|
function mapStateToProps(state, ownProps) {
|
||||||
// this is a hack, state is updated before ownProps
|
// this is a hack, state is updated before ownProps
|
||||||
return state.files.find(file => file.id === ownProps.id) || { ...ownProps, name: 'test', fileType: 'file' };
|
return state.files.find(file => file.id === ownProps.id) || { ...ownProps, name: 'test', fileType: 'file' };
|
||||||
// return state.files.find(file => file.id === ownProps.id);
|
// return state.files.find(file => file.id === ownProps.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import { hijackConsole, hijackConsoleErrorsScript, startTag, getAllScriptOffsets
|
||||||
|
|
||||||
|
|
||||||
class PreviewFrame extends React.Component {
|
class PreviewFrame extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (this.props.isPlaying) {
|
if (this.props.isPlaying) {
|
||||||
this.renderFrameContents();
|
this.renderFrameContents();
|
||||||
|
@ -144,9 +143,7 @@ class PreviewFrame extends React.Component {
|
||||||
hijackConsole
|
hijackConsole
|
||||||
];
|
];
|
||||||
const accessiblelib = sketchDoc.createElement('script');
|
const accessiblelib = sketchDoc.createElement('script');
|
||||||
accessiblelib.setAttribute(
|
accessiblelib.setAttribute('src', 'https://cdn.rawgit.com/processing/p5.accessibility/v0.1.1/dist/p5-accessibility.js');
|
||||||
'src', 'https://cdn.rawgit.com/processing/p5.accessibility/v0.1.1/dist/p5-accessibility.js'
|
|
||||||
);
|
|
||||||
const accessibleOutputs = sketchDoc.createElement('section');
|
const accessibleOutputs = sketchDoc.createElement('section');
|
||||||
accessibleOutputs.setAttribute('id', 'accessible-outputs');
|
accessibleOutputs.setAttribute('id', 'accessible-outputs');
|
||||||
accessibleOutputs.setAttribute('aria-label', 'accessible-output');
|
accessibleOutputs.setAttribute('aria-label', 'accessible-output');
|
||||||
|
|
|
@ -55,28 +55,27 @@ class SketchList extends React.Component {
|
||||||
>
|
>
|
||||||
<td className="sketch-list__trash-column">
|
<td className="sketch-list__trash-column">
|
||||||
{(() => { // eslint-disable-line
|
{(() => { // eslint-disable-line
|
||||||
if (this.props.username === this.props.user.username || this.props.username === undefined) {
|
if (this.props.username === this.props.user.username || this.props.username === undefined) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="sketch-list__trash-button"
|
className="sketch-list__trash-button"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
|
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
|
||||||
this.props.deleteProject(sketch.id);
|
this.props.deleteProject(sketch.id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<InlineSVG src={trashCan} alt="Delete Project" />
|
<InlineSVG src={trashCan} alt="Delete Project" />
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
</td>
|
</td>
|
||||||
<th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th>
|
<th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th>
|
||||||
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
|
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
|
||||||
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
|
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
|
||||||
</tr>
|
</tr>)}
|
||||||
)}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>}
|
</table>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -311,7 +311,7 @@ class IDEView extends React.Component {
|
||||||
/>
|
/>
|
||||||
<SplitPane
|
<SplitPane
|
||||||
split="vertical"
|
split="vertical"
|
||||||
defaultSize={'50%'}
|
defaultSize="50%"
|
||||||
onChange={() => { this.overlay.style.display = 'block'; }}
|
onChange={() => { this.overlay.style.display = 'block'; }}
|
||||||
onDragFinished={() => { this.overlay.style.display = 'none'; }}
|
onDragFinished={() => { this.overlay.style.display = 'none'; }}
|
||||||
resizerStyle={{ marginRight: '5px' }}
|
resizerStyle={{ marginRight: '5px' }}
|
||||||
|
@ -376,15 +376,15 @@ class IDEView extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{(
|
{(
|
||||||
(
|
(
|
||||||
(this.props.preferences.textOutput ||
|
(this.props.preferences.textOutput ||
|
||||||
this.props.preferences.gridOutput ||
|
this.props.preferences.gridOutput ||
|
||||||
this.props.preferences.soundOutput
|
this.props.preferences.soundOutput
|
||||||
) &&
|
) &&
|
||||||
this.props.ide.isPlaying
|
this.props.ide.isPlaying
|
||||||
) ||
|
) ||
|
||||||
this.props.ide.isAccessibleOutputPlaying
|
this.props.ide.isAccessibleOutputPlaying
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<PreviewFrame
|
<PreviewFrame
|
||||||
|
@ -691,16 +691,20 @@ function mapStateToProps(state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps(dispatch) {
|
function mapDispatchToProps(dispatch) {
|
||||||
return bindActionCreators(Object.assign({},
|
return bindActionCreators(
|
||||||
EditorAccessibilityActions,
|
Object.assign(
|
||||||
FileActions,
|
{},
|
||||||
ProjectActions,
|
EditorAccessibilityActions,
|
||||||
IDEActions,
|
FileActions,
|
||||||
PreferencesActions,
|
ProjectActions,
|
||||||
UserActions,
|
IDEActions,
|
||||||
ToastActions,
|
PreferencesActions,
|
||||||
ConsoleActions),
|
UserActions,
|
||||||
dispatch);
|
ToastActions,
|
||||||
|
ConsoleActions
|
||||||
|
),
|
||||||
|
dispatch
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IDEView));
|
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IDEView));
|
||||||
|
|
|
@ -10,8 +10,9 @@ const editorAccessibility = (state = initialState, action) => {
|
||||||
case ActionTypes.UPDATE_LINT_MESSAGE:
|
case ActionTypes.UPDATE_LINT_MESSAGE:
|
||||||
messageId += 1;
|
messageId += 1;
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
lintMessages: state.lintMessages.concat(
|
lintMessages: state.lintMessages.concat({
|
||||||
{ severity: action.severity, line: action.line, message: action.message, id: messageId })
|
severity: action.severity, line: action.line, message: action.message, id: messageId
|
||||||
|
})
|
||||||
});
|
});
|
||||||
case ActionTypes.CLEAR_LINT_MESSAGE:
|
case ActionTypes.CLEAR_LINT_MESSAGE:
|
||||||
return Object.assign({}, state, { lintMessages: [] });
|
return Object.assign({}, state, { lintMessages: [] });
|
||||||
|
|
|
@ -76,9 +76,9 @@ const initialState = () => {
|
||||||
|
|
||||||
function getAllDescendantIds(state, nodeId) {
|
function getAllDescendantIds(state, nodeId) {
|
||||||
return state.find(file => file.id === nodeId).children
|
return state.find(file => file.id === nodeId).children
|
||||||
.reduce((acc, childId) => (
|
.reduce((acc, childId) => (
|
||||||
[...acc, childId, ...getAllDescendantIds(state, childId)]
|
[...acc, childId, ...getAllDescendantIds(state, childId)]
|
||||||
), []);
|
), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteChild(state, parentId, id) {
|
function deleteChild(state, parentId, id) {
|
||||||
|
@ -135,24 +135,26 @@ const files = (state, action) => {
|
||||||
case ActionTypes.RESET_PROJECT:
|
case ActionTypes.RESET_PROJECT:
|
||||||
return initialState();
|
return initialState();
|
||||||
case ActionTypes.CREATE_FILE: // eslint-disable-line
|
case ActionTypes.CREATE_FILE: // eslint-disable-line
|
||||||
{
|
{
|
||||||
const newState = state.map((file) => {
|
const newState = state.map((file) => {
|
||||||
if (file.id === action.parentId) {
|
if (file.id === action.parentId) {
|
||||||
const newFile = Object.assign({}, file);
|
const newFile = Object.assign({}, file);
|
||||||
newFile.children = [...newFile.children, action.id];
|
newFile.children = [...newFile.children, action.id];
|
||||||
return newFile;
|
return newFile;
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
});
|
});
|
||||||
return [...newState,
|
return [...newState,
|
||||||
{ name: action.name,
|
{
|
||||||
id: action.id,
|
name: action.name,
|
||||||
_id: action._id,
|
id: action.id,
|
||||||
content: action.content,
|
_id: action._id,
|
||||||
url: action.url,
|
content: action.content,
|
||||||
children: action.children,
|
url: action.url,
|
||||||
fileType: action.fileType || 'file' }];
|
children: action.children,
|
||||||
}
|
fileType: action.fileType || 'file'
|
||||||
|
}];
|
||||||
|
}
|
||||||
case ActionTypes.SHOW_FILE_OPTIONS:
|
case ActionTypes.SHOW_FILE_OPTIONS:
|
||||||
return state.map((file) => {
|
return state.map((file) => {
|
||||||
if (file.id !== action.id) {
|
if (file.id !== action.id) {
|
||||||
|
@ -178,18 +180,18 @@ const files = (state, action) => {
|
||||||
return Object.assign({}, file, { name: action.name });
|
return Object.assign({}, file, { name: action.name });
|
||||||
});
|
});
|
||||||
case ActionTypes.DELETE_FILE:
|
case ActionTypes.DELETE_FILE:
|
||||||
{
|
{
|
||||||
const newState = deleteMany(state, [action.id, ...getAllDescendantIds(state, action.id)]);
|
const newState = deleteMany(state, [action.id, ...getAllDescendantIds(state, action.id)]);
|
||||||
return deleteChild(newState, action.parentId, action.id);
|
return deleteChild(newState, action.parentId, action.id);
|
||||||
// const newState = state.map((file) => {
|
// const newState = state.map((file) => {
|
||||||
// if (file.id === action.parentId) {
|
// if (file.id === action.parentId) {
|
||||||
// const newChildren = file.children.filter(child => child !== action.id);
|
// const newChildren = file.children.filter(child => child !== action.id);
|
||||||
// return { ...file, children: newChildren };
|
// return { ...file, children: newChildren };
|
||||||
// }
|
// }
|
||||||
// return file;
|
// return file;
|
||||||
// });
|
// });
|
||||||
// return newState.filter(file => file.id !== action.id);
|
// return newState.filter(file => file.id !== action.id);
|
||||||
}
|
}
|
||||||
case ActionTypes.SHOW_EDIT_FILE_NAME:
|
case ActionTypes.SHOW_EDIT_FILE_NAME:
|
||||||
return state.map((file) => {
|
return state.map((file) => {
|
||||||
if (file.id !== action.id) {
|
if (file.id !== action.id) {
|
||||||
|
|
|
@ -6,8 +6,7 @@ const sketches = (state = [], action) => {
|
||||||
return action.projects;
|
return action.projects;
|
||||||
case ActionTypes.DELETE_PROJECT:
|
case ActionTypes.DELETE_PROJECT:
|
||||||
return state.filter(sketch =>
|
return state.filter(sketch =>
|
||||||
sketch.id !== action.id
|
sketch.id !== action.id);
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ export function signUpUser(previousPath, formValues) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
axios.post(`${ROOT_URL}/signup`, formValues, { withCredentials: true })
|
axios.post(`${ROOT_URL}/signup`, formValues, { withCredentials: true })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
dispatch({ type: ActionTypes.AUTH_USER,
|
dispatch({
|
||||||
|
type: ActionTypes.AUTH_USER,
|
||||||
user: response.data
|
user: response.data
|
||||||
});
|
});
|
||||||
dispatch(justOpenedProject());
|
dispatch(justOpenedProject());
|
||||||
|
@ -49,7 +50,8 @@ export function validateAndLoginUser(previousPath, formProps, dispatch) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
loginUser(formProps)
|
loginUser(formProps)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
dispatch({ type: ActionTypes.AUTH_USER,
|
dispatch({
|
||||||
|
type: ActionTypes.AUTH_USER,
|
||||||
user: response.data
|
user: response.data
|
||||||
});
|
});
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -4,7 +4,9 @@ import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
||||||
|
|
||||||
function AccountForm(props) {
|
function AccountForm(props) {
|
||||||
const {
|
const {
|
||||||
fields: { username, email, currentPassword, newPassword },
|
fields: {
|
||||||
|
username, email, currentPassword, newPassword
|
||||||
|
},
|
||||||
user,
|
user,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
initiateVerification,
|
initiateVerification,
|
||||||
|
@ -45,7 +47,8 @@ function AccountForm(props) {
|
||||||
<button
|
<button
|
||||||
className="form__action"
|
className="form__action"
|
||||||
onClick={handleInitiateVerification}
|
onClick={handleInitiateVerification}
|
||||||
>Resend confirmation email</button>
|
>Resend confirmation email
|
||||||
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -3,7 +3,9 @@ import React from 'react';
|
||||||
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
||||||
|
|
||||||
function LoginForm(props) {
|
function LoginForm(props) {
|
||||||
const { fields: { email, password }, handleSubmit, submitting, pristine } = props;
|
const {
|
||||||
|
fields: { email, password }, handleSubmit, submitting, pristine
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}>
|
<form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}>
|
||||||
<p className="form__field">
|
<p className="form__field">
|
||||||
|
|
|
@ -3,7 +3,9 @@ import React from 'react';
|
||||||
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
||||||
|
|
||||||
function NewPasswordForm(props) {
|
function NewPasswordForm(props) {
|
||||||
const { fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine } = props;
|
const {
|
||||||
|
fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<form className="form" onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}>
|
<form className="form" onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}>
|
||||||
<p className="form__field">
|
<p className="form__field">
|
||||||
|
|
|
@ -3,7 +3,9 @@ import React from 'react';
|
||||||
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
||||||
|
|
||||||
function ResetPasswordForm(props) {
|
function ResetPasswordForm(props) {
|
||||||
const { fields: { email }, handleSubmit, submitting, invalid, pristine } = props;
|
const {
|
||||||
|
fields: { email }, handleSubmit, submitting, invalid, pristine
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<form className="form" onSubmit={handleSubmit(props.initiateResetPassword.bind(this))}>
|
<form className="form" onSubmit={handleSubmit(props.initiateResetPassword.bind(this))}>
|
||||||
<p className="form__field">
|
<p className="form__field">
|
||||||
|
|
|
@ -3,7 +3,11 @@ import React from 'react';
|
||||||
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
||||||
|
|
||||||
function SignupForm(props) {
|
function SignupForm(props) {
|
||||||
const { fields: { username, email, password, confirmPassword }, handleSubmit, submitting, invalid, pristine } = props;
|
const {
|
||||||
|
fields: {
|
||||||
|
username, email, password, confirmPassword
|
||||||
|
}, handleSubmit, submitting, invalid, pristine
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<form className="form" onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}>
|
<form className="form" onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}>
|
||||||
<p className="form__field">
|
<p className="form__field">
|
||||||
|
|
|
@ -3,8 +3,10 @@ import * as ActionTypes from '../../constants';
|
||||||
const user = (state = { authenticated: false }, action) => {
|
const user = (state = { authenticated: false }, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.AUTH_USER:
|
case ActionTypes.AUTH_USER:
|
||||||
return { ...action.user,
|
return {
|
||||||
authenticated: true };
|
...action.user,
|
||||||
|
authenticated: true
|
||||||
|
};
|
||||||
case ActionTypes.UNAUTH_USER:
|
case ActionTypes.UNAUTH_USER:
|
||||||
return {
|
return {
|
||||||
authenticated: false
|
authenticated: false
|
||||||
|
|
2226
package-lock.json
generated
2226
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -36,11 +36,11 @@
|
||||||
"chunk-manifest-webpack-plugin": "^1.1.2",
|
"chunk-manifest-webpack-plugin": "^1.1.2",
|
||||||
"css-loader": "^0.23.1",
|
"css-loader": "^0.23.1",
|
||||||
"cssnano": "^3.7.1",
|
"cssnano": "^3.7.1",
|
||||||
"eslint": "^3.14.0",
|
"eslint": "^4.9.0",
|
||||||
"eslint-config-airbnb": "^14.0.0",
|
"eslint-config-airbnb": "^16.1.0",
|
||||||
"eslint-plugin-import": "^2.2.0",
|
"eslint-plugin-import": "^2.2.0",
|
||||||
"eslint-plugin-jsx-a11y": "^3.0.2",
|
"eslint-plugin-jsx-a11y": "^6.0.3",
|
||||||
"eslint-plugin-react": "^6.9.0",
|
"eslint-plugin-react": "^7.7.0",
|
||||||
"extract-text-webpack-plugin": "^3.0.2",
|
"extract-text-webpack-plugin": "^3.0.2",
|
||||||
"file-loader": "^0.8.5",
|
"file-loader": "^0.8.5",
|
||||||
"node-sass": "^4.5.3",
|
"node-sass": "^4.5.3",
|
||||||
|
|
|
@ -22,18 +22,18 @@ passport.deserializeUser((id, done) => {
|
||||||
*/
|
*/
|
||||||
passport.use(new LocalStrategy({ usernameField: 'email' }, (email, password, done) => {
|
passport.use(new LocalStrategy({ usernameField: 'email' }, (email, password, done) => {
|
||||||
User.findByMailOrName(email.toLowerCase())
|
User.findByMailOrName(email.toLowerCase())
|
||||||
.then((user) => { // eslint-disable-line consistent-return
|
.then((user) => { // eslint-disable-line consistent-return
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return done(null, false, { msg: `Email ${email} not found.` });
|
return done(null, false, { msg: `Email ${email} not found.` });
|
||||||
}
|
|
||||||
user.comparePassword(password, (innerErr, isMatch) => {
|
|
||||||
if (isMatch) {
|
|
||||||
return done(null, user);
|
|
||||||
}
|
}
|
||||||
return done(null, false, { msg: 'Invalid email or password.' });
|
user.comparePassword(password, (innerErr, isMatch) => {
|
||||||
});
|
if (isMatch) {
|
||||||
})
|
return done(null, user);
|
||||||
.catch(err => done(null, false, { msg: err }));
|
}
|
||||||
|
return done(null, false, { msg: 'Invalid email or password.' });
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => done(null, false, { msg: err }));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -9,7 +9,8 @@ import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
||||||
// be fixed in mongoose soon
|
// be fixed in mongoose soon
|
||||||
// https://github.com/Automattic/mongoose/issues/4049
|
// https://github.com/Automattic/mongoose/issues/4049
|
||||||
export function createFile(req, res) {
|
export function createFile(req, res) {
|
||||||
Project.findByIdAndUpdate(req.params.project_id,
|
Project.findByIdAndUpdate(
|
||||||
|
req.params.project_id,
|
||||||
{
|
{
|
||||||
$push: {
|
$push: {
|
||||||
files: req.body
|
files: req.body
|
||||||
|
@ -33,14 +34,15 @@ export function createFile(req, res) {
|
||||||
}
|
}
|
||||||
res.json(updatedProject.files[updatedProject.files.length - 1]);
|
res.json(updatedProject.files[updatedProject.files.length - 1]);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllDescendantIds(files, nodeId) {
|
function getAllDescendantIds(files, nodeId) {
|
||||||
return files.find(file => file.id === nodeId).children
|
return files.find(file => file.id === nodeId).children
|
||||||
.reduce((acc, childId) => (
|
.reduce((acc, childId) => (
|
||||||
[...acc, childId, ...getAllDescendantIds(files, childId)]
|
[...acc, childId, ...getAllDescendantIds(files, childId)]
|
||||||
), []);
|
), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteMany(files, ids) {
|
function deleteMany(files, ids) {
|
||||||
|
|
|
@ -20,7 +20,8 @@ export function createProject(req, res) {
|
||||||
res.json({ success: false });
|
res.json({ success: false });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Project.populate(newProject,
|
Project.populate(
|
||||||
|
newProject,
|
||||||
{ path: 'user', select: 'username' },
|
{ path: 'user', select: 'username' },
|
||||||
(innerErr, newProjectWithUser) => {
|
(innerErr, newProjectWithUser) => {
|
||||||
if (innerErr) {
|
if (innerErr) {
|
||||||
|
@ -28,7 +29,8 @@ export function createProject(req, res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.json(newProjectWithUser);
|
res.json(newProjectWithUser);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +44,15 @@ export function updateProject(req, res) {
|
||||||
// res.status(409).send({ success: false, message: 'Attempted to save stale version of project.' });
|
// res.status(409).send({ success: false, message: 'Attempted to save stale version of project.' });
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
Project.findByIdAndUpdate(req.params.project_id,
|
Project.findByIdAndUpdate(
|
||||||
|
req.params.project_id,
|
||||||
{
|
{
|
||||||
$set: req.body
|
$set: req.body
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new: true
|
new: true
|
||||||
})
|
}
|
||||||
|
)
|
||||||
.populate('user', 'username')
|
.populate('user', 'username')
|
||||||
.exec((updateProjectErr, updatedProject) => {
|
.exec((updateProjectErr, updatedProject) => {
|
||||||
if (updateProjectErr) {
|
if (updateProjectErr) {
|
||||||
|
@ -86,13 +90,13 @@ export function getProject(req, res) {
|
||||||
return res.status(404).send({ message: 'Project with that id does not exist' });
|
return res.status(404).send({ message: 'Project with that id does not exist' });
|
||||||
} else if (!project) {
|
} else if (!project) {
|
||||||
Project.findOne({ slug: projectId })
|
Project.findOne({ slug: projectId })
|
||||||
.populate('user', 'username')
|
.populate('user', 'username')
|
||||||
.exec((innerErr, projectBySlug) => {
|
.exec((innerErr, projectBySlug) => {
|
||||||
if (innerErr || !projectBySlug) {
|
if (innerErr || !projectBySlug) {
|
||||||
return res.status(404).send({ message: 'Project with that id does not exist' });
|
return res.status(404).send({ message: 'Project with that id does not exist' });
|
||||||
}
|
}
|
||||||
return res.json(projectBySlug);
|
return res.json(projectBySlug);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return res.json(project);
|
return res.json(project);
|
||||||
}
|
}
|
||||||
|
@ -100,15 +104,14 @@ export function getProject(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFilesFromS3(files) {
|
function deleteFilesFromS3(files) {
|
||||||
deleteObjectsFromS3(
|
deleteObjectsFromS3(files.filter((file) => {
|
||||||
files.filter((file) => {
|
if (file.url) {
|
||||||
if (file.url) {
|
if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) {
|
||||||
if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
})
|
return false;
|
||||||
|
})
|
||||||
.map(file => getObjectKey(file.url)));
|
.map(file => getObjectKey(file.url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,12 @@ const random = (done) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function findUserByUsername(username, cb) {
|
export function findUserByUsername(username, cb) {
|
||||||
User.findOne({ username },
|
User.findOne(
|
||||||
|
{ username },
|
||||||
(err, user) => {
|
(err, user) => {
|
||||||
cb(user);
|
cb(user);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const EMAIL_VERIFY_TOKEN_EXPIRY_TIME = Date.now() + (3600000 * 24); // 24 hours
|
const EMAIL_VERIFY_TOKEN_EXPIRY_TIME = Date.now() + (3600000 * 24); // 24 hours
|
||||||
|
@ -35,49 +37,51 @@ export function createUser(req, res, next) {
|
||||||
verifiedTokenExpires: EMAIL_VERIFY_TOKEN_EXPIRY_TIME,
|
verifiedTokenExpires: EMAIL_VERIFY_TOKEN_EXPIRY_TIME,
|
||||||
});
|
});
|
||||||
|
|
||||||
User.findOne({ email: req.body.email },
|
User.findOne(
|
||||||
(err, existingUser) => {
|
{ email: req.body.email },
|
||||||
if (err) {
|
(err, existingUser) => {
|
||||||
res.status(404).send({ error: err });
|
if (err) {
|
||||||
return;
|
res.status(404).send({ error: err });
|
||||||
}
|
|
||||||
|
|
||||||
if (existingUser) {
|
|
||||||
res.status(422).send({ error: 'Email is in use' });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
user.save((saveErr) => {
|
|
||||||
if (saveErr) {
|
|
||||||
next(saveErr);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req.logIn(user, (loginErr) => {
|
|
||||||
if (loginErr) {
|
if (existingUser) {
|
||||||
next(loginErr);
|
res.status(422).send({ error: 'Email is in use' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user.save((saveErr) => {
|
||||||
|
if (saveErr) {
|
||||||
|
next(saveErr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
req.logIn(user, (loginErr) => {
|
||||||
|
if (loginErr) {
|
||||||
|
next(loginErr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const protocol = process.env.NODE_ENV === 'production' ? 'https' : 'http';
|
const protocol = process.env.NODE_ENV === 'production' ? 'https' : 'http';
|
||||||
const mailOptions = renderEmailConfirmation({
|
const mailOptions = renderEmailConfirmation({
|
||||||
body: {
|
body: {
|
||||||
domain: `${protocol}://${req.headers.host}`,
|
domain: `${protocol}://${req.headers.host}`,
|
||||||
link: `${protocol}://${req.headers.host}/verify?t=${token}`
|
link: `${protocol}://${req.headers.host}/verify?t=${token}`
|
||||||
},
|
},
|
||||||
to: req.user.email,
|
to: req.user.email,
|
||||||
});
|
});
|
||||||
|
|
||||||
mail.send(mailOptions, (mailErr, result) => { // eslint-disable-line no-unused-vars
|
mail.send(mailOptions, (mailErr, result) => { // eslint-disable-line no-unused-vars
|
||||||
res.json({
|
res.json({
|
||||||
email: req.user.email,
|
email: req.user.email,
|
||||||
username: req.user.username,
|
username: req.user.username,
|
||||||
preferences: req.user.preferences,
|
preferences: req.user.preferences,
|
||||||
verified: req.user.verified,
|
verified: req.user.verified,
|
||||||
id: req.user._id
|
id: req.user._id
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ function getSketchDirectories(sketchRootList) {
|
||||||
// console.log(sketchRootList);
|
// console.log(sketchRootList);
|
||||||
|
|
||||||
return Q.all(sketchRootList.map((sketches) => {
|
return Q.all(sketchRootList.map((sketches) => {
|
||||||
// console.log(sketches)
|
// console.log(sketches)
|
||||||
const options = {
|
const options = {
|
||||||
url: `https://api.github.com/repos/generative-design/Code-Package-p5.js/contents/${sketches.path}${branchRef}`,
|
url: `https://api.github.com/repos/generative-design/Code-Package-p5.js/contents/${sketches.path}${branchRef}`,
|
||||||
qs: {
|
qs: {
|
||||||
|
@ -156,9 +156,7 @@ function getSketchDirectories(sketchRootList) {
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
})
|
})).then((output) => {
|
||||||
|
|
||||||
).then((output) => {
|
|
||||||
const sketchList = [];
|
const sketchList = [];
|
||||||
output.forEach((l) => {
|
output.forEach((l) => {
|
||||||
l.forEach((i) => {
|
l.forEach((i) => {
|
||||||
|
@ -502,14 +500,14 @@ function getp5User() {
|
||||||
// .then(saveNewProjectsToFile)
|
// .then(saveNewProjectsToFile)
|
||||||
.then(createProjectsInP5user);
|
.then(createProjectsInP5user);
|
||||||
}
|
}
|
||||||
// Run for production
|
// Run for production
|
||||||
return getCodePackage()
|
return getCodePackage()
|
||||||
.then(getSketchDirectories)
|
.then(getSketchDirectories)
|
||||||
.then(appendSketchItemLinks)
|
.then(appendSketchItemLinks)
|
||||||
.then(getSketchItems)
|
.then(getSketchItems)
|
||||||
.then(formatAllSketches)
|
.then(formatAllSketches)
|
||||||
.then(getAllSketchContent)
|
.then(getAllSketchContent)
|
||||||
.then(createProjectsInP5user);
|
.then(createProjectsInP5user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Run the entire process
|
// Run the entire process
|
||||||
|
|
|
@ -45,7 +45,7 @@ function getCategories() {
|
||||||
const categories = [];
|
const categories = [];
|
||||||
const options = {
|
const options = {
|
||||||
url: `https://api.github.com/repos/processing/p5.js-website/contents/dist/assets/examples/en?client_id=${
|
url: `https://api.github.com/repos/processing/p5.js-website/contents/dist/assets/examples/en?client_id=${
|
||||||
clientId}&client_secret=${clientSecret}`,
|
clientId}&client_secret=${clientSecret}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers,
|
headers,
|
||||||
json: true
|
json: true
|
||||||
|
@ -112,8 +112,10 @@ function getSketchContent(projectsInAllCategories) {
|
||||||
if (noNumberprojectName === 'Instance Mode : Instance Container ') {
|
if (noNumberprojectName === 'Instance Mode : Instance Container ') {
|
||||||
for (let i = 0; i < 4; i += 1) {
|
for (let i = 0; i < 4; i += 1) {
|
||||||
const splitedRes = `${res.split('*/')[1].split('</html>')[i]}</html>\n`;
|
const splitedRes = `${res.split('*/')[1].split('</html>')[i]}</html>\n`;
|
||||||
project.sketchContent = splitedRes.replace('p5.js',
|
project.sketchContent = splitedRes.replace(
|
||||||
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js');
|
'p5.js',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
project.sketchContent = res;
|
project.sketchContent = res;
|
||||||
|
@ -128,7 +130,7 @@ function getSketchContent(projectsInAllCategories) {
|
||||||
function createProjectsInP5user(projectsInAllCategories) {
|
function createProjectsInP5user(projectsInAllCategories) {
|
||||||
const options = {
|
const options = {
|
||||||
url: `https://api.github.com/repos/processing/p5.js-website/contents/dist/assets/examples/assets?client_id=${
|
url: `https://api.github.com/repos/processing/p5.js-website/contents/dist/assets/examples/assets?client_id=${
|
||||||
clientId}&client_secret=${clientSecret}`,
|
clientId}&client_secret=${clientSecret}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers,
|
headers,
|
||||||
json: true
|
json: true
|
||||||
|
|
|
@ -12,9 +12,7 @@ export function resolvePathToFile(filePath, files) {
|
||||||
let foundChild = false;
|
let foundChild = false;
|
||||||
const childFiles = currentFile.children.map(childFileId =>
|
const childFiles = currentFile.children.map(childFileId =>
|
||||||
files.find(file =>
|
files.find(file =>
|
||||||
file._id.valueOf().toString() === childFileId.valueOf()
|
file._id.valueOf().toString() === childFileId.valueOf()));
|
||||||
)
|
|
||||||
);
|
|
||||||
childFiles.some((childFile) => {
|
childFiles.some((childFile) => {
|
||||||
if (childFile.name === filePathSegment) {
|
if (childFile.name === filePathSegment) {
|
||||||
currentFile = childFile;
|
currentFile = childFile;
|
||||||
|
|
|
@ -100,15 +100,19 @@ export function get404Sketch(callback) {
|
||||||
htmlFile = html.join('</head>');
|
htmlFile = html.join('</head>');
|
||||||
|
|
||||||
// Fix links to assets
|
// Fix links to assets
|
||||||
htmlFile = htmlFile.replace(/'assets/g,
|
htmlFile = htmlFile.replace(
|
||||||
"'https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/");
|
/'assets/g,
|
||||||
htmlFile = htmlFile.replace(/"assets/g,
|
"'https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/"
|
||||||
'"https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/');
|
);
|
||||||
|
htmlFile = htmlFile.replace(
|
||||||
|
/"assets/g,
|
||||||
|
'"https://rawgit.com/processing/p5.js-website/master/dist/assets/examples/assets/'
|
||||||
|
);
|
||||||
|
|
||||||
// Change canvas size
|
// Change canvas size
|
||||||
htmlFile = htmlFile.replace(/createCanvas\(\d+, ?\d+/g, instanceMode ?
|
htmlFile = htmlFile.replace(/createCanvas\(\d+, ?\d+/g, instanceMode ?
|
||||||
'createCanvas(p.windowWidth, p.windowHeight'
|
'createCanvas(p.windowWidth, p.windowHeight'
|
||||||
:
|
:
|
||||||
'createCanvas(windowWidth, windowHeight');
|
'createCanvas(windowWidth, windowHeight');
|
||||||
|
|
||||||
callback(htmlFile);
|
callback(htmlFile);
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const renderResetPassword = (data) => {
|
||||||
link: data.body.link,
|
link: data.body.link,
|
||||||
buttonText: 'Reset password',
|
buttonText: 'Reset password',
|
||||||
directLinkText: 'Or copy and paste the URL into your browser:',
|
directLinkText: 'Or copy and paste the URL into your browser:',
|
||||||
noteText: 'If you did not request this, please ignore this email and your password will remain unchanged. Thanks for using the p5.js Web Editor!', // eslint-disable-line max-len
|
noteText: 'If you did not request this, please ignore this email and your password will remain unchanged. Thanks for using the p5.js Web Editor!', // eslint-disable-line max-len
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return MJML string
|
// Return MJML string
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default ({
|
||||||
directLinkText,
|
directLinkText,
|
||||||
noteText,
|
noteText,
|
||||||
}) => (
|
}) => (
|
||||||
`
|
`
|
||||||
<mjml>
|
<mjml>
|
||||||
<mj-body>
|
<mj-body>
|
||||||
<mj-container>
|
<mj-container>
|
||||||
|
|
Loading…
Reference in a new issue