Merge branch 'feature' of git://github.com/siddhant1/p5.js-web-editor into siddhant1-feature
This commit is contained in:
commit
02e2a7b0ce
6 changed files with 65 additions and 36 deletions
|
@ -1,13 +1,13 @@
|
||||||
|
import format from 'date-fns/format';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import moment from 'moment';
|
|
||||||
import { Link, browserHistory } from 'react-router';
|
|
||||||
import InlineSVG from 'react-inlinesvg';
|
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import * as SketchActions from '../actions/projects';
|
import InlineSVG from 'react-inlinesvg';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { browserHistory, Link } from 'react-router';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
import * as ProjectActions from '../actions/project';
|
import * as ProjectActions from '../actions/project';
|
||||||
|
import * as SketchActions from '../actions/projects';
|
||||||
import * as ToastActions from '../actions/toast';
|
import * as ToastActions from '../actions/toast';
|
||||||
|
|
||||||
const trashCan = require('../../../images/trash-can.svg');
|
const trashCan = require('../../../images/trash-can.svg');
|
||||||
|
@ -73,8 +73,8 @@ class SketchList extends React.Component {
|
||||||
})()}
|
})()}
|
||||||
</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>{format(new Date(sketch.createdAt), 'MMM D, YYYY h:mm A')}</td>
|
||||||
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
|
<td>{format(new Date(sketch.updatedAt), 'MMM D, YYYY h:mm A')}</td>
|
||||||
</tr>)}
|
</tr>)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>}
|
</table>}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import differenceInMilliseconds from 'date-fns/difference_in_milliseconds';
|
||||||
|
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
class Timer extends React.Component {
|
class Timer extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -20,16 +21,19 @@ class Timer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
showSavedTime() {
|
showSavedTime() {
|
||||||
if (Math.abs(moment().diff(this.props.projectSavedTime)) < 10000) {
|
const now = new Date();
|
||||||
|
if (Math.abs(differenceInMilliseconds(now, this.props.projectSavedTime) < 10000)) {
|
||||||
return 'Saved: just now';
|
return 'Saved: just now';
|
||||||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 20000) {
|
} else if (differenceInMilliseconds(now, this.props.projectSavedTime) < 20000) {
|
||||||
return 'Saved: 15 seconds ago';
|
return 'Saved: 15 seconds ago';
|
||||||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 30000) {
|
} else if (differenceInMilliseconds(now, this.props.projectSavedTime) < 30000) {
|
||||||
return 'Saved: 25 seconds ago';
|
return 'Saved: 25 seconds ago';
|
||||||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 46000) {
|
} else if (differenceInMilliseconds(now, this.props.projectSavedTime) < 46000) {
|
||||||
return 'Saved: 35 seconds ago';
|
return 'Saved: 35 seconds ago';
|
||||||
}
|
}
|
||||||
return `Saved: ${moment(this.props.projectSavedTime).fromNow()}`;
|
return `Saved: ${distanceInWordsToNow(this.props.projectSavedTime, {
|
||||||
|
includeSeconds: true
|
||||||
|
})} ago`;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
46
package-lock.json
generated
46
package-lock.json
generated
|
@ -3442,6 +3442,11 @@
|
||||||
"semver": "^5.5.0"
|
"semver": "^5.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"date-fns": {
|
||||||
|
"version": "1.30.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz",
|
||||||
|
"integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw=="
|
||||||
|
},
|
||||||
"date-now": {
|
"date-now": {
|
||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
|
||||||
|
@ -5076,7 +5081,8 @@
|
||||||
},
|
},
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
@ -5094,11 +5100,13 @@
|
||||||
},
|
},
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
|
@ -5111,15 +5119,18 @@
|
||||||
},
|
},
|
||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
@ -5222,7 +5233,8 @@
|
||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
|
@ -5232,6 +5244,7 @@
|
||||||
"is-fullwidth-code-point": {
|
"is-fullwidth-code-point": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
|
@ -5244,17 +5257,20 @@
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
|
@ -5271,6 +5287,7 @@
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
|
@ -5343,7 +5360,8 @@
|
||||||
},
|
},
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
|
@ -5353,6 +5371,7 @@
|
||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
|
@ -5428,7 +5447,8 @@
|
||||||
},
|
},
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -5458,6 +5478,7 @@
|
||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
|
@ -5475,6 +5496,7 @@
|
||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -5513,11 +5535,13 @@
|
||||||
},
|
},
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"bundled": true
|
"bundled": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"csslint": "^0.10.0",
|
"csslint": "^0.10.0",
|
||||||
|
"date-fns": "^1.30.1",
|
||||||
"decomment": "^0.8.7",
|
"decomment": "^0.8.7",
|
||||||
"dotenv": "^2.0.0",
|
"dotenv": "^2.0.0",
|
||||||
"dropzone": "^4.3.0",
|
"dropzone": "^4.3.0",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import each from 'async/each';
|
import each from 'async/each';
|
||||||
import moment from 'moment';
|
import isBefore from 'date-fns/is_before';
|
||||||
|
|
||||||
import Project from '../models/project';
|
import Project from '../models/project';
|
||||||
import { resolvePathToFile } from '../utils/filePath';
|
import { resolvePathToFile } from '../utils/filePath';
|
||||||
import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
||||||
|
@ -56,7 +55,7 @@ function deleteMany(files, ids) {
|
||||||
each(ids, (id, cb) => {
|
each(ids, (id, cb) => {
|
||||||
if (files.id(id).url) {
|
if (files.id(id).url) {
|
||||||
if (!process.env.S3_DATE
|
if (!process.env.S3_DATE
|
||||||
|| (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(files.id(id).createdAt))) {
|
|| (process.env.S3_DATE && isBefore(new Date(process.env.S3_DATE), new Date(files.id(id).createdAt)))) {
|
||||||
const objectKey = getObjectKey(files.id(id).url);
|
const objectKey = getObjectKey(files.id(id).url);
|
||||||
objectKeys.push(objectKey);
|
objectKeys.push(objectKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import archiver from 'archiver';
|
import archiver from 'archiver';
|
||||||
import request from 'request';
|
import format from 'date-fns/format';
|
||||||
import moment from 'moment';
|
|
||||||
import isUrl from 'is-url';
|
import isUrl from 'is-url';
|
||||||
import slugify from 'slugify';
|
|
||||||
import jsdom, { serializeDocument } from 'jsdom';
|
import jsdom, { serializeDocument } from 'jsdom';
|
||||||
import { resolvePathToFile } from '../utils/filePath';
|
import isBefore from 'date-fns/is_before';
|
||||||
import generateFileSystemSafeName from '../utils/generateFileSystemSafeName';
|
import request from 'request';
|
||||||
|
import slugify from 'slugify';
|
||||||
import Project from '../models/project';
|
import Project from '../models/project';
|
||||||
import User from '../models/user';
|
import User from '../models/user';
|
||||||
|
import { resolvePathToFile } from '../utils/filePath';
|
||||||
|
import generateFileSystemSafeName from '../utils/generateFileSystemSafeName';
|
||||||
import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
||||||
|
|
||||||
export function createProject(req, res) {
|
export function createProject(req, res) {
|
||||||
|
@ -109,7 +110,7 @@ export function getProject(req, res) {
|
||||||
function deleteFilesFromS3(files) {
|
function deleteFilesFromS3(files) {
|
||||||
deleteObjectsFromS3(files.filter((file) => {
|
deleteObjectsFromS3(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 && isBefore(new Date(process.env.S3_DATE), new Date(file.createdAt)))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +292,7 @@ function buildZip(project, req, res) {
|
||||||
res.status(500).send({ error: err.message });
|
res.status(500).send({ error: err.message });
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentTime = moment().format('YYYY_MM_DD_HH_mm_ss');
|
const currentTime = format(new Date(), 'YYYY_MM_DD_HH_mm_ss');
|
||||||
project.slug = slugify(project.name, '_');
|
project.slug = slugify(project.name, '_');
|
||||||
res.attachment(`${generateFileSystemSafeName(project.slug)}_${currentTime}.zip`);
|
res.attachment(`${generateFileSystemSafeName(project.slug)}_${currentTime}.zip`);
|
||||||
zip.pipe(res);
|
zip.pipe(res);
|
||||||
|
|
Loading…
Reference in a new issue