update eslint and fix linting errors

This commit is contained in:
Cassie Tarakajian 2018-05-04 17:22:39 -07:00
parent 254bbacba2
commit c90dac55b7
35 changed files with 1230 additions and 1512 deletions

View File

@ -404,7 +404,8 @@ class Nav extends React.PureComponent {
onFocus={this.handleFocus.bind(this, 'help')}
onBlur={this.handleBlur}
onClick={this.setDropdown.bind(this, 'none')}
>Reference</a>
>Reference
</a>
</li>
<li className="nav__dropdown-item">
<Link

View File

@ -3,11 +3,9 @@ import { createDevTools } from 'redux-devtools';
import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';
export default createDevTools(
<DockMonitor
toggleVisibilityKey="ctrl-h"
changePositionKey="ctrl-w"
>
<LogMonitor />
</DockMonitor>
);
export default createDevTools(<DockMonitor
toggleVisibilityKey="ctrl-h"
changePositionKey="ctrl-w"
>
<LogMonitor />
</DockMonitor>);

View File

@ -273,9 +273,7 @@ export function setServeSecure(serveSecure, { redirect = true } = {}) {
if (redirect === true) {
dispatch(saveProject(false /* autosave */))
.then(
() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http)
);
.then(() => redirectToProtocol(serveSecure === true ? protocols.https : protocols.http));
}
return null;

View File

@ -41,36 +41,38 @@ export function dropzoneAcceptCallback(userId, file, done) {
file.content = result; // eslint-disable-line
done('Uploading plaintext file locally.');
})
.catch((result) => {
done(`Failed to download file ${file.name}: ${result}`);
console.warn(file);
});
.catch((result) => {
done(`Failed to download file ${file.name}: ${result}`);
console.warn(file);
});
} else {
file.postData = []; // eslint-disable-line
axios.post(`${ROOT_URL}/S3/sign`, {
name: file.name,
type: file.type,
size: file.size,
userId
axios.post(
`${ROOT_URL}/S3/sign`, {
name: file.name,
type: file.type,
size: file.size,
userId
// _csrf: document.getElementById('__createPostToken').value
},
},
{
withCredentials: true
})
.then((response) => {
}
)
.then((response) => {
file.custom_status = 'ready'; // eslint-disable-line
file.postData = response.data; // eslint-disable-line
file.s3 = response.data.key; // eslint-disable-line
file.previewTemplate.className += ' uploading'; // eslint-disable-line
done();
})
.catch((response) => {
done();
})
.catch((response) => {
file.custom_status = 'rejected'; // eslint-disable-line
if (response.data.responseText && response.data.responseText.message) {
done(response.data.responseText.message);
}
done('error preparing the upload');
});
if (response.data.responseText && response.data.responseText.message) {
done(response.data.responseText.message);
}
done('error preparing the upload');
});
}
};
}

View File

@ -34,7 +34,8 @@ function About(props) {
rel="noopener noreferrer"
>
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Examples</a>
Examples
</a>
</p>
<p className="about__content-column-list">
<a
@ -43,7 +44,8 @@ function About(props) {
rel="noopener noreferrer"
>
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Learn</a>
Learn
</a>
</p>
</div>
<div className="about__content-column">
@ -55,7 +57,8 @@ function About(props) {
rel="noopener noreferrer"
>
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Libraries</a>
Libraries
</a>
</p>
<p className="about__content-column-list">
<a
@ -64,7 +67,8 @@ function About(props) {
rel="noopener noreferrer"
>
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Reference</a>
Reference
</a>
</p>
<p className="about__content-column-list">
<a
@ -73,7 +77,8 @@ function About(props) {
rel="noopener noreferrer"
>
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" />
Forum</a>
Forum
</a>
</p>
</div>
<div className="about__footer">
@ -82,21 +87,24 @@ function About(props) {
href="https://github.com/processing/p5.js-web-editor"
target="_blank"
rel="noopener noreferrer"
>Contribute</a>
>Contribute
</a>
</p>
<p className="about__footer-list">
<a
href="https://github.com/processing/p5.js-web-editor/issues/new"
target="_blank"
rel="noopener noreferrer"
>Report a bug</a>
>Report a bug
</a>
</p>
<p className="about__footer-list">
<a
href="https://twitter.com/p5xjs?lang=en"
target="_blank"
rel="noopener noreferrer"
>Twitter</a>
>Twitter
</a>
</p>
</div>
</div>

View File

@ -44,13 +44,12 @@ class AssetList extends React.Component {
</thead>
<tbody>
{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>{prettyBytes(asset.size)}</td>
<td><Link to={asset.url} target="_blank">View</Link></td>
<td><Link to={`/${this.props.username}/sketches/${asset.sketchId}`}>{asset.sketchName}</Link></td>
</tr>
)}
</tr>))}
</tbody>
</table>}
</div>

View File

@ -44,7 +44,7 @@ class Console extends React.Component {
if (Object.keys(args).length === 0) {
return (
<div key={consoleEvent.id} className="preview-console__undefined">
<span key={`${consoleEvent.id}-0`}>{'undefined'}</span>
<span key={`${consoleEvent.id}-0`}>undefined</span>
</div>
);
}
@ -58,7 +58,6 @@ class Console extends React.Component {
</div>
);
}
}
Console.propTypes = {

View File

@ -9,18 +9,14 @@ class EditorAccessibility extends React.Component {
const messages = [];
if (this.props.lintMessages.length > 0) {
this.props.lintMessages.forEach((lintMessage, i) => {
messages.push(
<li key={lintMessage.id}>
{lintMessage.severity} in line
{lintMessage.line} :
{lintMessage.message}
</li>
);
messages.push(<li key={lintMessage.id}>
{lintMessage.severity} in line
{lintMessage.line} :
{lintMessage.message}
</li>);
});
} else {
messages.push(
<li tabIndex="0" key={0}> There are no lint messages </li>
);
messages.push(<li tabIndex="0" key={0}> There are no lint messages </li>);
}
return (
<div className="editor-accessibility">

View File

@ -40,7 +40,8 @@ function Feedback(props) {
href="https://docs.google.com/forms/d/e/1FAIpQLSexU8W2EIhXjktl-_XzwjH6vgnelHirH4Yn4liN5BXltPWqBg/viewform"
target="_blank"
rel="noopener noreferrer"
>Go to Form</a>
>Go to Form
</a>
</p>
</div>
</div>

View File

@ -252,7 +252,7 @@ FileNode.defaultProps = {
};
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);
}

View File

@ -23,7 +23,6 @@ import { hijackConsole, hijackConsoleErrorsScript, startTag, getAllScriptOffsets
class PreviewFrame extends React.Component {
componentDidMount() {
if (this.props.isPlaying) {
this.renderFrameContents();
@ -144,9 +143,7 @@ class PreviewFrame extends React.Component {
hijackConsole
];
const accessiblelib = sketchDoc.createElement('script');
accessiblelib.setAttribute(
'src', 'https://cdn.rawgit.com/processing/p5.accessibility/v0.1.1/dist/p5-accessibility.js'
);
accessiblelib.setAttribute('src', 'https://cdn.rawgit.com/processing/p5.accessibility/v0.1.1/dist/p5-accessibility.js');
const accessibleOutputs = sketchDoc.createElement('section');
accessibleOutputs.setAttribute('id', 'accessible-outputs');
accessibleOutputs.setAttribute('aria-label', 'accessible-output');

View File

@ -55,28 +55,27 @@ class SketchList extends React.Component {
>
<td className="sketch-list__trash-column">
{(() => { // eslint-disable-line
if (this.props.username === this.props.user.username || this.props.username === undefined) {
return (
<button
className="sketch-list__trash-button"
onClick={(e) => {
e.stopPropagation();
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
this.props.deleteProject(sketch.id);
}
}}
>
<InlineSVG src={trashCan} alt="Delete Project" />
</button>
);
}
})()}
if (this.props.username === this.props.user.username || this.props.username === undefined) {
return (
<button
className="sketch-list__trash-button"
onClick={(e) => {
e.stopPropagation();
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
this.props.deleteProject(sketch.id);
}
}}
>
<InlineSVG src={trashCan} alt="Delete Project" />
</button>
);
}
})()}
</td>
<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.updatedAt).format('MMM D, YYYY h:mm A')}</td>
</tr>
)}
</tr>)}
</tbody>
</table>}
</div>

View File

@ -311,7 +311,7 @@ class IDEView extends React.Component {
/>
<SplitPane
split="vertical"
defaultSize={'50%'}
defaultSize="50%"
onChange={() => { this.overlay.style.display = 'block'; }}
onDragFinished={() => { this.overlay.style.display = 'none'; }}
resizerStyle={{ marginRight: '5px' }}
@ -376,15 +376,15 @@ class IDEView extends React.Component {
</div>
<div>
{(
(
(this.props.preferences.textOutput ||
(
(this.props.preferences.textOutput ||
this.props.preferences.gridOutput ||
this.props.preferences.soundOutput
) &&
) &&
this.props.ide.isPlaying
) ||
) ||
this.props.ide.isAccessibleOutputPlaying
)
)
}
</div>
<PreviewFrame
@ -691,16 +691,20 @@ function mapStateToProps(state) {
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(Object.assign({},
EditorAccessibilityActions,
FileActions,
ProjectActions,
IDEActions,
PreferencesActions,
UserActions,
ToastActions,
ConsoleActions),
dispatch);
return bindActionCreators(
Object.assign(
{},
EditorAccessibilityActions,
FileActions,
ProjectActions,
IDEActions,
PreferencesActions,
UserActions,
ToastActions,
ConsoleActions
),
dispatch
);
}
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IDEView));

View File

@ -10,8 +10,9 @@ const editorAccessibility = (state = initialState, action) => {
case ActionTypes.UPDATE_LINT_MESSAGE:
messageId += 1;
return Object.assign({}, state, {
lintMessages: state.lintMessages.concat(
{ severity: action.severity, line: action.line, message: action.message, id: messageId })
lintMessages: state.lintMessages.concat({
severity: action.severity, line: action.line, message: action.message, id: messageId
})
});
case ActionTypes.CLEAR_LINT_MESSAGE:
return Object.assign({}, state, { lintMessages: [] });

View File

@ -76,9 +76,9 @@ const initialState = () => {
function getAllDescendantIds(state, nodeId) {
return state.find(file => file.id === nodeId).children
.reduce((acc, childId) => (
[...acc, childId, ...getAllDescendantIds(state, childId)]
), []);
.reduce((acc, childId) => (
[...acc, childId, ...getAllDescendantIds(state, childId)]
), []);
}
function deleteChild(state, parentId, id) {
@ -135,24 +135,26 @@ const files = (state, action) => {
case ActionTypes.RESET_PROJECT:
return initialState();
case ActionTypes.CREATE_FILE: // eslint-disable-line
{
const newState = state.map((file) => {
if (file.id === action.parentId) {
const newFile = Object.assign({}, file);
newFile.children = [...newFile.children, action.id];
return newFile;
}
return file;
});
return [...newState,
{ name: action.name,
id: action.id,
_id: action._id,
content: action.content,
url: action.url,
children: action.children,
fileType: action.fileType || 'file' }];
}
{
const newState = state.map((file) => {
if (file.id === action.parentId) {
const newFile = Object.assign({}, file);
newFile.children = [...newFile.children, action.id];
return newFile;
}
return file;
});
return [...newState,
{
name: action.name,
id: action.id,
_id: action._id,
content: action.content,
url: action.url,
children: action.children,
fileType: action.fileType || 'file'
}];
}
case ActionTypes.SHOW_FILE_OPTIONS:
return state.map((file) => {
if (file.id !== action.id) {
@ -178,18 +180,18 @@ const files = (state, action) => {
return Object.assign({}, file, { name: action.name });
});
case ActionTypes.DELETE_FILE:
{
const newState = deleteMany(state, [action.id, ...getAllDescendantIds(state, action.id)]);
return deleteChild(newState, action.parentId, action.id);
// const newState = state.map((file) => {
// if (file.id === action.parentId) {
// const newChildren = file.children.filter(child => child !== action.id);
// return { ...file, children: newChildren };
// }
// return file;
// });
// return newState.filter(file => file.id !== action.id);
}
{
const newState = deleteMany(state, [action.id, ...getAllDescendantIds(state, action.id)]);
return deleteChild(newState, action.parentId, action.id);
// const newState = state.map((file) => {
// if (file.id === action.parentId) {
// const newChildren = file.children.filter(child => child !== action.id);
// return { ...file, children: newChildren };
// }
// return file;
// });
// return newState.filter(file => file.id !== action.id);
}
case ActionTypes.SHOW_EDIT_FILE_NAME:
return state.map((file) => {
if (file.id !== action.id) {

View File

@ -6,8 +6,7 @@ const sketches = (state = [], action) => {
return action.projects;
case ActionTypes.DELETE_PROJECT:
return state.filter(sketch =>
sketch.id !== action.id
);
sketch.id !== action.id);
default:
return state;
}

View File

@ -17,7 +17,8 @@ export function signUpUser(previousPath, formValues) {
return (dispatch) => {
axios.post(`${ROOT_URL}/signup`, formValues, { withCredentials: true })
.then((response) => {
dispatch({ type: ActionTypes.AUTH_USER,
dispatch({
type: ActionTypes.AUTH_USER,
user: response.data
});
dispatch(justOpenedProject());
@ -49,7 +50,8 @@ export function validateAndLoginUser(previousPath, formProps, dispatch) {
return new Promise((resolve, reject) => {
loginUser(formProps)
.then((response) => {
dispatch({ type: ActionTypes.AUTH_USER,
dispatch({
type: ActionTypes.AUTH_USER,
user: response.data
});
dispatch({

View File

@ -4,7 +4,9 @@ import { domOnlyProps } from '../../../utils/reduxFormUtils';
function AccountForm(props) {
const {
fields: { username, email, currentPassword, newPassword },
fields: {
username, email, currentPassword, newPassword
},
user,
handleSubmit,
initiateVerification,
@ -45,7 +47,8 @@ function AccountForm(props) {
<button
className="form__action"
onClick={handleInitiateVerification}
>Resend confirmation email</button>
>Resend confirmation email
</button>
)
}
</p>

View File

@ -3,7 +3,9 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils';
function LoginForm(props) {
const { fields: { email, password }, handleSubmit, submitting, pristine } = props;
const {
fields: { email, password }, handleSubmit, submitting, pristine
} = props;
return (
<form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}>
<p className="form__field">

View File

@ -3,7 +3,9 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils';
function NewPasswordForm(props) {
const { fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine } = props;
const {
fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine
} = props;
return (
<form className="form" onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}>
<p className="form__field">

View File

@ -3,7 +3,9 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils';
function ResetPasswordForm(props) {
const { fields: { email }, handleSubmit, submitting, invalid, pristine } = props;
const {
fields: { email }, handleSubmit, submitting, invalid, pristine
} = props;
return (
<form className="form" onSubmit={handleSubmit(props.initiateResetPassword.bind(this))}>
<p className="form__field">

View File

@ -3,7 +3,11 @@ import React from 'react';
import { domOnlyProps } from '../../../utils/reduxFormUtils';
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 (
<form className="form" onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}>
<p className="form__field">

View File

@ -3,8 +3,10 @@ import * as ActionTypes from '../../constants';
const user = (state = { authenticated: false }, action) => {
switch (action.type) {
case ActionTypes.AUTH_USER:
return { ...action.user,
authenticated: true };
return {
...action.user,
authenticated: true
};
case ActionTypes.UNAUTH_USER:
return {
authenticated: false

2226
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -36,11 +36,11 @@
"chunk-manifest-webpack-plugin": "^1.1.2",
"css-loader": "^0.23.1",
"cssnano": "^3.7.1",
"eslint": "^3.14.0",
"eslint-config-airbnb": "^14.0.0",
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.8.5",
"node-sass": "^4.5.3",

View File

@ -22,18 +22,18 @@ passport.deserializeUser((id, done) => {
*/
passport.use(new LocalStrategy({ usernameField: 'email' }, (email, password, done) => {
User.findByMailOrName(email.toLowerCase())
.then((user) => { // eslint-disable-line consistent-return
if (!user) {
return done(null, false, { msg: `Email ${email} not found.` });
}
user.comparePassword(password, (innerErr, isMatch) => {
if (isMatch) {
return done(null, user);
.then((user) => { // eslint-disable-line consistent-return
if (!user) {
return done(null, false, { msg: `Email ${email} not found.` });
}
return done(null, false, { msg: 'Invalid email or password.' });
});
})
.catch(err => done(null, false, { msg: err }));
user.comparePassword(password, (innerErr, isMatch) => {
if (isMatch) {
return done(null, user);
}
return done(null, false, { msg: 'Invalid email or password.' });
});
})
.catch(err => done(null, false, { msg: err }));
}));
/*

View File

@ -9,7 +9,8 @@ import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
// be fixed in mongoose soon
// https://github.com/Automattic/mongoose/issues/4049
export function createFile(req, res) {
Project.findByIdAndUpdate(req.params.project_id,
Project.findByIdAndUpdate(
req.params.project_id,
{
$push: {
files: req.body
@ -33,14 +34,15 @@ export function createFile(req, res) {
}
res.json(updatedProject.files[updatedProject.files.length - 1]);
});
});
}
);
}
function getAllDescendantIds(files, nodeId) {
return files.find(file => file.id === nodeId).children
.reduce((acc, childId) => (
[...acc, childId, ...getAllDescendantIds(files, childId)]
), []);
.reduce((acc, childId) => (
[...acc, childId, ...getAllDescendantIds(files, childId)]
), []);
}
function deleteMany(files, ids) {

View File

@ -20,7 +20,8 @@ export function createProject(req, res) {
res.json({ success: false });
return;
}
Project.populate(newProject,
Project.populate(
newProject,
{ path: 'user', select: 'username' },
(innerErr, newProjectWithUser) => {
if (innerErr) {
@ -28,7 +29,8 @@ export function createProject(req, res) {
return;
}
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.' });
// return;
// }
Project.findByIdAndUpdate(req.params.project_id,
Project.findByIdAndUpdate(
req.params.project_id,
{
$set: req.body
},
{
new: true
})
}
)
.populate('user', 'username')
.exec((updateProjectErr, updatedProject) => {
if (updateProjectErr) {
@ -86,13 +90,13 @@ export function getProject(req, res) {
return res.status(404).send({ message: 'Project with that id does not exist' });
} else if (!project) {
Project.findOne({ slug: projectId })
.populate('user', 'username')
.exec((innerErr, projectBySlug) => {
if (innerErr || !projectBySlug) {
return res.status(404).send({ message: 'Project with that id does not exist' });
}
return res.json(projectBySlug);
});
.populate('user', 'username')
.exec((innerErr, projectBySlug) => {
if (innerErr || !projectBySlug) {
return res.status(404).send({ message: 'Project with that id does not exist' });
}
return res.json(projectBySlug);
});
} else {
return res.json(project);
}
@ -100,15 +104,14 @@ export function getProject(req, res) {
}
function deleteFilesFromS3(files) {
deleteObjectsFromS3(
files.filter((file) => {
if (file.url) {
if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) {
return true;
}
deleteObjectsFromS3(files.filter((file) => {
if (file.url) {
if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) {
return true;
}
return false;
})
}
return false;
})
.map(file => getObjectKey(file.url)));
}

View File

@ -16,10 +16,12 @@ const random = (done) => {
};
export function findUserByUsername(username, cb) {
User.findOne({ username },
User.findOne(
{ username },
(err, user) => {
cb(user);
});
}
);
}
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,
});
User.findOne({ email: req.body.email },
(err, existingUser) => {
if (err) {
res.status(404).send({ error: err });
return;
}
if (existingUser) {
res.status(422).send({ error: 'Email is in use' });
return;
}
user.save((saveErr) => {
if (saveErr) {
next(saveErr);
User.findOne(
{ email: req.body.email },
(err, existingUser) => {
if (err) {
res.status(404).send({ error: err });
return;
}
req.logIn(user, (loginErr) => {
if (loginErr) {
next(loginErr);
if (existingUser) {
res.status(422).send({ error: 'Email is in use' });
return;
}
user.save((saveErr) => {
if (saveErr) {
next(saveErr);
return;
}
req.logIn(user, (loginErr) => {
if (loginErr) {
next(loginErr);
return;
}
const protocol = process.env.NODE_ENV === 'production' ? 'https' : 'http';
const mailOptions = renderEmailConfirmation({
body: {
domain: `${protocol}://${req.headers.host}`,
link: `${protocol}://${req.headers.host}/verify?t=${token}`
},
to: req.user.email,
});
const protocol = process.env.NODE_ENV === 'production' ? 'https' : 'http';
const mailOptions = renderEmailConfirmation({
body: {
domain: `${protocol}://${req.headers.host}`,
link: `${protocol}://${req.headers.host}/verify?t=${token}`
},
to: req.user.email,
});
mail.send(mailOptions, (mailErr, result) => { // eslint-disable-line no-unused-vars
res.json({
email: req.user.email,
username: req.user.username,
preferences: req.user.preferences,
verified: req.user.verified,
id: req.user._id
mail.send(mailOptions, (mailErr, result) => { // eslint-disable-line no-unused-vars
res.json({
email: req.user.email,
username: req.user.username,
preferences: req.user.preferences,
verified: req.user.verified,
id: req.user._id
});
});
});
});
});
});
}
);
});
}

View File

@ -137,7 +137,7 @@ function getSketchDirectories(sketchRootList) {
// console.log(sketchRootList);
return Q.all(sketchRootList.map((sketches) => {
// console.log(sketches)
// console.log(sketches)
const options = {
url: `https://api.github.com/repos/generative-design/Code-Package-p5.js/contents/${sketches.path}${branchRef}`,
qs: {
@ -156,9 +156,7 @@ function getSketchDirectories(sketchRootList) {
}).catch((err) => {
throw err;
});
})
).then((output) => {
})).then((output) => {
const sketchList = [];
output.forEach((l) => {
l.forEach((i) => {
@ -502,14 +500,14 @@ function getp5User() {
// .then(saveNewProjectsToFile)
.then(createProjectsInP5user);
}
// Run for production
// Run for production
return getCodePackage()
.then(getSketchDirectories)
.then(appendSketchItemLinks)
.then(getSketchItems)
.then(formatAllSketches)
.then(getAllSketchContent)
.then(createProjectsInP5user);
.then(getSketchDirectories)
.then(appendSketchItemLinks)
.then(getSketchItems)
.then(formatAllSketches)
.then(getAllSketchContent)
.then(createProjectsInP5user);
});
}
// Run the entire process

View File

@ -45,7 +45,7 @@ function getCategories() {
const categories = [];
const options = {
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',
headers,
json: true
@ -112,8 +112,10 @@ function getSketchContent(projectsInAllCategories) {
if (noNumberprojectName === 'Instance Mode : Instance Container ') {
for (let i = 0; i < 4; i += 1) {
const splitedRes = `${res.split('*/')[1].split('</html>')[i]}</html>\n`;
project.sketchContent = splitedRes.replace('p5.js',
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js');
project.sketchContent = splitedRes.replace(
'p5.js',
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js'
);
}
} else {
project.sketchContent = res;
@ -128,7 +130,7 @@ function getSketchContent(projectsInAllCategories) {
function createProjectsInP5user(projectsInAllCategories) {
const options = {
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',
headers,
json: true

View File

@ -12,9 +12,7 @@ export function resolvePathToFile(filePath, files) {
let foundChild = false;
const childFiles = currentFile.children.map(childFileId =>
files.find(file =>
file._id.valueOf().toString() === childFileId.valueOf()
)
);
file._id.valueOf().toString() === childFileId.valueOf()));
childFiles.some((childFile) => {
if (childFile.name === filePathSegment) {
currentFile = childFile;

View File

@ -100,15 +100,19 @@ export function get404Sketch(callback) {
htmlFile = html.join('</head>');
// Fix links to assets
htmlFile = htmlFile.replace(/'assets/g,
"'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/');
htmlFile = htmlFile.replace(
/'assets/g,
"'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
htmlFile = htmlFile.replace(/createCanvas\(\d+, ?\d+/g, instanceMode ?
'createCanvas(p.windowWidth, p.windowHeight'
:
:
'createCanvas(windowWidth, windowHeight');
callback(htmlFile);

View File

@ -11,7 +11,7 @@ export const renderResetPassword = (data) => {
link: data.body.link,
buttonText: 'Reset password',
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

View File

@ -8,7 +8,7 @@ export default ({
directLinkText,
noteText,
}) => (
`
`
<mjml>
<mj-body>
<mj-container>