From 61afce46ed888ef4411d759f9d49315925f3ca9a Mon Sep 17 00:00:00 2001 From: Zach Rispoli Date: Thu, 1 Jun 2017 00:08:11 -0400 Subject: [PATCH 01/30] Server can serve individual assets from projects (fixes #212, fixes #219) --- server/controllers/project.controller.js | 26 ++++++++++++++++++++++++ server/routes/server.routes.js | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index 84b2afa1..9dae16b5 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -123,6 +123,32 @@ export function deleteProject(req, res) { }); } +export function getProjectAsset(req, res) { + Project.findById(req.params.project_id) + .populate('user', 'username') + .exec((err, project) => { + if (err) { + return res.status(404).send({ message: 'Project with that id does not exist' }); + } + + var assetURL = null; + var seekFilename = req.params.asset_path; + project.files.forEach((file) => { + if(file.name === seekFilename) { + assetURL = file.url; + } + }); + + if(!assetURL) { + return res.status(404).send({ message: 'Asset does not exist' }); + } else { + request({ method: 'GET', url: assetURL, encoding: null }, (err, response, body) => { + res.send(body); + }); + } + }); +} + export function getProjects(req, res) { if (req.user) { Project.find({ user: req.user._id }) // eslint-disable-line no-underscore-dangle diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js index 1b69dbda..d4f9f6cb 100644 --- a/server/routes/server.routes.js +++ b/server/routes/server.routes.js @@ -2,6 +2,7 @@ import { Router } from 'express'; import { renderIndex } from '../views/index'; import { get404Sketch } from '../views/404Page'; import { userExists } from '../controllers/user.controller'; +import { getProjectAsset } from '../controllers/project.controller'; const router = new Router(); @@ -24,6 +25,10 @@ router.route('/:username/sketches/:project_id').get((req, res) => { res.send(renderIndex()); }); +router.route('/:username/sketches/:project_id/:asset_path').get((req, res) => { + getProjectAsset(req,res); +}); + // router.route('/full/:project_id').get((req, res) => { // res.send(renderIndex()); // }); From 396fc701c7e18bc28900ecc53e6f0d9dd7e73e02 Mon Sep 17 00:00:00 2001 From: Zach Rispoli Date: Mon, 12 Jun 2017 13:49:45 -0400 Subject: [PATCH 02/30] Fix issue with serving assets inside folders --- client/modules/IDE/components/PreviewFrame.jsx | 5 +++-- server/controllers/project.controller.js | 4 +++- server/routes/server.routes.js | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/modules/IDE/components/PreviewFrame.jsx b/client/modules/IDE/components/PreviewFrame.jsx index 33af7507..55c79e7b 100644 --- a/client/modules/IDE/components/PreviewFrame.jsx +++ b/client/modules/IDE/components/PreviewFrame.jsx @@ -249,7 +249,8 @@ class PreviewFrame extends React.Component { let jsFileStrings = content.match(STRING_REGEX); jsFileStrings = jsFileStrings || []; jsFileStrings.forEach((jsFileString) => { - if (jsFileString.match(MEDIA_FILE_REGEX)) { + console.log(this.props.setBlobUrl); + /* if (jsFileString.match(MEDIA_FILE_REGEX)) { const filePath = jsFileString.substr(1, jsFileString.length - 2); const resolvedFile = resolvePathToFile(filePath, files); if (resolvedFile) { @@ -262,7 +263,7 @@ class PreviewFrame extends React.Component { newContent = newContent.replace(filePath, blobURL); } } - } + }*/ }); newContent = loopProtect(newContent); return newContent; diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index 9dae16b5..baa20df9 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -132,7 +132,9 @@ export function getProjectAsset(req, res) { } var assetURL = null; - var seekFilename = req.params.asset_path; + var seekPath = req.params[0]; // req.params.asset_path; + var seekPathSplit = seekPath.split('/'); + var seekFilename = seekPathSplit[seekPathSplit.length-1]; project.files.forEach((file) => { if(file.name === seekFilename) { assetURL = file.url; diff --git a/server/routes/server.routes.js b/server/routes/server.routes.js index d4f9f6cb..d5c6064e 100644 --- a/server/routes/server.routes.js +++ b/server/routes/server.routes.js @@ -25,7 +25,7 @@ router.route('/:username/sketches/:project_id').get((req, res) => { res.send(renderIndex()); }); -router.route('/:username/sketches/:project_id/:asset_path').get((req, res) => { +router.route('/:username/sketches/:project_id/*').get((req, res) => { getProjectAsset(req,res); }); From b194a2456460f8bb79c4c165e497a7ddc6559df4 Mon Sep 17 00:00:00 2001 From: Zach Rispoli Date: Wed, 26 Jul 2017 14:04:24 -0400 Subject: [PATCH 03/30] Re-enable serving text files as blobs + Remove comments --- client/modules/IDE/components/PreviewFrame.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/modules/IDE/components/PreviewFrame.jsx b/client/modules/IDE/components/PreviewFrame.jsx index 55c79e7b..33af7507 100644 --- a/client/modules/IDE/components/PreviewFrame.jsx +++ b/client/modules/IDE/components/PreviewFrame.jsx @@ -249,8 +249,7 @@ class PreviewFrame extends React.Component { let jsFileStrings = content.match(STRING_REGEX); jsFileStrings = jsFileStrings || []; jsFileStrings.forEach((jsFileString) => { - console.log(this.props.setBlobUrl); - /* if (jsFileString.match(MEDIA_FILE_REGEX)) { + if (jsFileString.match(MEDIA_FILE_REGEX)) { const filePath = jsFileString.substr(1, jsFileString.length - 2); const resolvedFile = resolvePathToFile(filePath, files); if (resolvedFile) { @@ -263,7 +262,7 @@ class PreviewFrame extends React.Component { newContent = newContent.replace(filePath, blobURL); } } - }*/ + } }); newContent = loopProtect(newContent); return newContent; From e111d3c020a4a56c33ee901a1afa1826a0edab7e Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 1 Aug 2017 15:03:48 -0400 Subject: [PATCH 04/30] fix line number for runtime errors --- client/modules/IDE/components/PreviewFrame.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/components/PreviewFrame.jsx b/client/modules/IDE/components/PreviewFrame.jsx index c29d2e54..314090c7 100644 --- a/client/modules/IDE/components/PreviewFrame.jsx +++ b/client/modules/IDE/components/PreviewFrame.jsx @@ -34,8 +34,8 @@ function getAllScriptOffsets(htmlFile) { } else { endFilenameInd = htmlFile.indexOf('.js', ind + startTag.length + 3); filename = htmlFile.substring(ind + startTag.length, endFilenameInd); - // the length of hijackConsoleErrorsScript is 35 lines, already needed a -1 offset. - lineOffset = htmlFile.substring(0, ind).split('\n').length + 34; + // the length of hijackConsoleErrorsScript is 31 lines + lineOffset = htmlFile.substring(0, ind).split('\n').length + 31; offs.push([lineOffset, filename]); lastInd = ind + 1; } From fcb89e2c2b092efcb2e693c3bf796e27c4f7c928 Mon Sep 17 00:00:00 2001 From: Saumya Balodi Date: Fri, 4 Aug 2017 02:39:25 +0530 Subject: [PATCH 05/30] Issue211 (#409) * Update Repository * Syntaxt Highlighting for dark and light themes --- .../components/_p5-dark-codemirror-theme.scss | 8 +++++--- .../components/_p5-light-codemirror-theme.scss | 15 ++++++++------- static/p5-interceptor | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/styles/components/_p5-dark-codemirror-theme.scss b/client/styles/components/_p5-dark-codemirror-theme.scss index 863855e3..e727b03f 100644 --- a/client/styles/components/_p5-dark-codemirror-theme.scss +++ b/client/styles/components/_p5-dark-codemirror-theme.scss @@ -21,6 +21,8 @@ $p5-dark-white: #FDFDFD; $p5-dark-orange: #EE9900; $p5-dark-lightgray: #E0D7D1; $p5-dark-darkgray: #666666; +$p5-dark-green: #58a10b; +$p5-dark-goldbrown: #b58317; $p5-dark-gutter: #f4f4f4; $p5-dark-number: #b5b5b5; @@ -41,7 +43,7 @@ $p5-dark-activeline: rgb(207, 207, 207); } .cm-s-p5-dark .cm-string { - color: $p5-dark-lightblue; + color: $p5-dark-green; } .cm-s-p5-dark .cm-string-2 { @@ -49,11 +51,11 @@ $p5-dark-activeline: rgb(207, 207, 207); } .cm-s-p5-dark .cm-number { - color: $p5-dark-pink; + color: $p5-dark-white; } .cm-s-p5-dark .cm-keyword { - color: $p5-light-green; + color: $p5-dark-goldbrown; } .cm-s-p5-dark .cm-variable { diff --git a/client/styles/components/_p5-light-codemirror-theme.scss b/client/styles/components/_p5-light-codemirror-theme.scss index b22edf26..0a5fcd78 100644 --- a/client/styles/components/_p5-light-codemirror-theme.scss +++ b/client/styles/components/_p5-light-codemirror-theme.scss @@ -12,7 +12,7 @@ $p5-light-lightbrown: #A67F59; $p5-light-brown: #704F21; -$p5-light-black: #333; +$p5-light-black: #333333; $p5-light-pink: #D9328F; $p5-light-gray: #A0A0A0; $p5-light-lightblue: #00A1D3; @@ -21,6 +21,7 @@ $p5-light-white: #FDFDFD; $p5-light-orange: #EE9900; $p5-light-lightgray: #E0D7D1; $p5-light-darkgray: #666666; +$p5-light-green: #58a10b; $p5-light-gutter: #f4f4f4; $p5-light-number: #b5b5b5; @@ -37,11 +38,11 @@ $p5-light-activeline: rgb(207, 207, 207); } .cm-s-p5-light .cm-def { - color: $p5-light-darkblue; + color: $p5-light-lightblue; } .cm-s-p5-light .cm-string { - color: $p5-light-lightblue; + color: $p5-light-green; } .cm-s-p5-light .cm-string-2 { @@ -49,7 +50,7 @@ $p5-light-activeline: rgb(207, 207, 207); } .cm-s-p5-light .cm-number { - color: $p5-light-pink; + color: $p5-light-black; } .cm-s-p5-light .cm-keyword { @@ -60,7 +61,7 @@ $p5-light-activeline: rgb(207, 207, 207); color: $p5-light-lightblue; } -.cm-s-p5-light .cm-variable-2 { +.cm-s-p5-light .cm-variable2 { color: $p5-light-black; } @@ -114,14 +115,14 @@ $p5-light-activeline: rgb(207, 207, 207); } .cm-s-p5-light .cm-attribute { - color: $p5-light-lightblue; + color: $p5-light-black; } .cm-s-p5-light .cm-p5-function { color: $p5-light-darkblue; + font-weight: bold; } .cm-s-p5-light .cm-p5-variable { color: $p5-light-pink; - font-weight: bold; } diff --git a/static/p5-interceptor b/static/p5-interceptor index 0958be54..a1c12672 160000 --- a/static/p5-interceptor +++ b/static/p5-interceptor @@ -1 +1 @@ -Subproject commit 0958be54482722821159cd3e07777988ee349f37 +Subproject commit a1c126721ac667f7750ec181c8ccf363f2658d8b From 1897ccdef2f80822edfc9db2e7b6bc187cce2037 Mon Sep 17 00:00:00 2001 From: Zach Rispoli Date: Thu, 3 Aug 2017 17:27:01 -0400 Subject: [PATCH 06/30] Change setting so that decomment library preserves spaces (#411) * Change setting so that decomment preserves spaces * Fix trailing spaces --- client/modules/IDE/components/PreviewFrame.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/modules/IDE/components/PreviewFrame.jsx b/client/modules/IDE/components/PreviewFrame.jsx index 314090c7..27725fb6 100644 --- a/client/modules/IDE/components/PreviewFrame.jsx +++ b/client/modules/IDE/components/PreviewFrame.jsx @@ -280,7 +280,10 @@ class PreviewFrame extends React.Component { } } }); - newContent = decomment(newContent, { ignore: /noprotect/g }); + newContent = decomment(newContent, { + ignore: /noprotect/g, + space: true + }); newContent = loopProtect(newContent); return newContent; } From cfd6bf75b20842a7fa05a40c7cd65ff8c4796bfa Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 29 Aug 2017 16:22:55 -0400 Subject: [PATCH 07/30] update p5 interceptor --- static/p5-interceptor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/p5-interceptor b/static/p5-interceptor index a1c12672..0958be54 160000 --- a/static/p5-interceptor +++ b/static/p5-interceptor @@ -1 +1 @@ -Subproject commit a1c126721ac667f7750ec181c8ccf363f2658d8b +Subproject commit 0958be54482722821159cd3e07777988ee349f37 From 677aa5865bfbd190fed053dd101183303699cf43 Mon Sep 17 00:00:00 2001 From: Joey Lee Date: Tue, 5 Sep 2017 23:54:41 +0200 Subject: [PATCH 08/30] replaced () with {} to fix implicit return error (#434) --- client/modules/IDE/pages/IDEView.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index ca6d22d3..e32c6e5f 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -300,8 +300,8 @@ class IDEView extends React.Component { (this.overlay.style.display = 'block')} - onDragFinished={() => (this.overlay.style.display = 'none')} + onChange={() => { this.overlay.style.display = 'block'; }} + onDragFinished={() => { this.overlay.style.display = 'none'; }} > Date: Wed, 6 Sep 2017 11:55:09 -0400 Subject: [PATCH 09/30] Accessibility (#436) * add p5 interceptor submodule * update package * remoce interceptor * update interceptor; * merge scripts * change postinstall script * refactor interceptor files * remove merge conflicts * change source files * add registry class * provide seperate outputs for text and grid * switch textOutput to boolean * make both modules usable together * update interceptor for safari * fix grid label * add sound output as well * change file strucure * change constants * change input lables * switch submodule branch * change variable name * change grid to table * remove role from table elements * switch submodule branch * change aria albels * revert submodule branch to master --- client/modules/IDE/components/GridOutput.jsx | 8 ++++---- static/p5-interceptor | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/modules/IDE/components/GridOutput.jsx b/client/modules/IDE/components/GridOutput.jsx index f1e855d9..3f7dcd1b 100644 --- a/client/modules/IDE/components/GridOutput.jsx +++ b/client/modules/IDE/components/GridOutput.jsx @@ -10,24 +10,24 @@ class GridOutput extends React.Component { id="gridOutput-content" ref={(element) => { this.GridOutputModal = element; }} > -

Grid Output

+

table Output

diff --git a/static/p5-interceptor b/static/p5-interceptor index 0958be54..442e266e 160000 --- a/static/p5-interceptor +++ b/static/p5-interceptor @@ -1 +1 @@ -Subproject commit 0958be54482722821159cd3e07777988ee349f37 +Subproject commit 442e266e7103ccad2046a64b88e399bdbd771b6e From 40fd0f9debef4d2fadbd4243bcb9eff992561743 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Wed, 6 Sep 2017 11:56:32 -0400 Subject: [PATCH 10/30] update p5-interceptor --- static/p5-interceptor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/p5-interceptor b/static/p5-interceptor index 442e266e..51087283 160000 --- a/static/p5-interceptor +++ b/static/p5-interceptor @@ -1 +1 @@ -Subproject commit 442e266e7103ccad2046a64b88e399bdbd771b6e +Subproject commit 51087283c090ab1f1f0f733a01fdf46ef1382544 From 4ea9f96d3f7cdd11f3cc9e56b15373d239b88b3b Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 14 Sep 2017 14:32:43 -0400 Subject: [PATCH 11/30] fix #430 --- client/modules/IDE/components/Editor.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 0d365c97..ebf0c119 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -78,7 +78,8 @@ class Editor extends React.Component { options: { 'asi': true, 'eqeqeq': false, - '-W041': false + '-W041': false, + 'esversion': 6 } } }); From 9eede0f728b618c2e32b630183fe930bb1f911e4 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 14 Sep 2017 14:51:36 -0400 Subject: [PATCH 12/30] fix #429 --- client/modules/App/components/Overlay.jsx | 5 +- client/modules/IDE/components/HTTPSModal.jsx | 24 ++++++++ client/modules/IDE/components/HelpModal.jsx | 61 -------------------- client/modules/IDE/pages/IDEView.jsx | 12 ++-- 4 files changed, 33 insertions(+), 69 deletions(-) create mode 100644 client/modules/IDE/components/HTTPSModal.jsx delete mode 100644 client/modules/IDE/components/HelpModal.jsx diff --git a/client/modules/App/components/Overlay.jsx b/client/modules/App/components/Overlay.jsx index 8951df64..aa016950 100644 --- a/client/modules/App/components/Overlay.jsx +++ b/client/modules/App/components/Overlay.jsx @@ -57,14 +57,15 @@ Overlay.propTypes = { closeOverlay: PropTypes.func, title: PropTypes.string, ariaLabel: PropTypes.string, - previousPath: PropTypes.string.isRequired + previousPath: PropTypes.string }; Overlay.defaultProps = { children: null, title: 'Modal', closeOverlay: null, - ariaLabel: 'modal' + ariaLabel: 'modal', + previousPath: '/' }; export default Overlay; diff --git a/client/modules/IDE/components/HTTPSModal.jsx b/client/modules/IDE/components/HTTPSModal.jsx new file mode 100644 index 00000000..6240dd51 --- /dev/null +++ b/client/modules/IDE/components/HTTPSModal.jsx @@ -0,0 +1,24 @@ +import React from 'react'; + +function HTTPSModal() { + return ( +
+
+
+

Use the checkbox to choose whether this sketch should be loaded using HTTPS or HTTP.

+

You should choose HTTPS if you need to:

+
    +
  • access a webcam or microphone
  • +
  • access an API served over HTTPS
  • +
+

Choose HTTP if you need to:

+
    +
  • access an API served over HTTP
  • +
+
+
+
+ ); +} + +export default HTTPSModal; diff --git a/client/modules/IDE/components/HelpModal.jsx b/client/modules/IDE/components/HelpModal.jsx deleted file mode 100644 index df0adf24..00000000 --- a/client/modules/IDE/components/HelpModal.jsx +++ /dev/null @@ -1,61 +0,0 @@ -import React, { PropTypes } from 'react'; -import InlineSVG from 'react-inlinesvg'; - -const exitUrl = require('../../../images/exit.svg'); - -const helpContent = { - serveSecure: { - title: 'Serve over HTTPS', - body: ( -
-

Use the checkbox to choose whether this sketch should be loaded using HTTPS or HTTP.

-

You should choose HTTPS if you need to:

-
    -
  • access a webcam or microphone
  • -
  • access an API served over HTTPS
  • -
-

Choose HTTP if you need to:

-
    -
  • access an API served over HTTP
  • -
-
- ) - } -}; - -const fallbackContent = { - title: 'No content for this topic', - body: null, -}; - -class HelpModal extends React.Component { - componentDidMount() { - this.shareModal.focus(); - } - render() { - const content = helpContent[this.props.type] == null ? - fallbackContent : - helpContent[this.props.type]; - - return ( -
{ this.shareModal = element; }} tabIndex="0"> -
-

{content.title}

- -
-
- {content.body} -
-
- ); - } -} - -HelpModal.propTypes = { - type: PropTypes.string.isRequired, - closeModal: PropTypes.func.isRequired, -}; - -export default HelpModal; diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index e32c6e5f..3929f8e5 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -15,7 +15,7 @@ import NewFolderModal from '../components/NewFolderModal'; import ShareModal from '../components/ShareModal'; import KeyboardShortcutModal from '../components/KeyboardShortcutModal'; import ErrorModal from '../components/ErrorModal'; -import HelpModal from '../components/HelpModal'; +import HTTPSModal from '../components/HTTPSModal'; import Nav from '../../../components/Nav'; import Console from '../components/Console'; import Toast from '../components/Toast'; @@ -516,11 +516,11 @@ class IDEView extends React.Component { {(() => { // eslint-disable-line if (this.props.ide.helpType) { return ( - - + + ); } From fd26279fed690f6dd0f2d2181a0afe16a9ff1992 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Mon, 17 Jul 2017 17:09:46 -0400 Subject: [PATCH 13/30] start to restyle nav --- client/components/Nav.jsx | 94 ++++++++++++++++++++++++++ client/images/down-filled-triangle.svg | 10 +++ client/images/p5js-logo-small.svg | 20 ++++++ client/styles/components/_nav.scss | 13 ++-- 4 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 client/images/down-filled-triangle.svg create mode 100644 client/images/p5js-logo-small.svg diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index 0a861e97..5b4aebcf 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -1,11 +1,105 @@ import React, { PropTypes } from 'react'; import { Link } from 'react-router'; +import InlineSVG from 'react-inlinesvg'; + +const triangleUrl = require('../images/down-filled-triangle.svg'); +const logoUrl = require('../images/p5js-logo-small.svg'); class Nav extends React.PureComponent { render() { return (