Skip to content

Commit eb565aa

Browse files
authored
Merge branch 'develop' into chore/emmet-integration
2 parents 3b90c9e + 0e917dd commit eb565aa

21 files changed

+215
-262
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ EXAMPLE_USER_PASSWORD=hellop5js
1010
GG_EXAMPLES_USERNAME=generativedesign
1111
GG_EXAMPLES_EMAIL=benedikt.gross@generative-gestaltung.de
1212
GG_EXAMPLES_PASS=generativedesign
13-
ML5_EXAMPLES_USERNAME=ml5
14-
ML5_EXAMPLES_EMAIL=examples@ml5js.org
15-
ML5_EXAMPLES_PASS=helloml5
13+
ML5_LIBRARY_USERNAME=ml5
14+
ML5_LIBRARY_EMAIL=examples@ml5js.org
15+
ML5_LIBRARY_PASS=helloml5
1616
GITHUB_ID=<your-github-client-id>
1717
GITHUB_SECRET=<your-github-client-secret>
1818
GOOGLE_ID=<your-google-client-id> (use google+ api)

client/components/Nav.jsx

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class Nav extends React.PureComponent {
4242
this.handleFind = this.handleFind.bind(this);
4343
this.handleAddFile = this.handleAddFile.bind(this);
4444
this.handleAddFolder = this.handleAddFolder.bind(this);
45-
this.handleFindNext = this.handleFindNext.bind(this);
4645
this.handleRun = this.handleRun.bind(this);
47-
this.handleFindPrevious = this.handleFindPrevious.bind(this);
4846
this.handleReplace = this.handleReplace.bind(this);
4947
this.handleStop = this.handleStop.bind(this);
5048
this.handleStartAccessible = this.handleStartAccessible.bind(this);
@@ -128,16 +126,6 @@ class Nav extends React.PureComponent {
128126
this.setDropdown('none');
129127
}
130128

131-
handleFindNext() {
132-
this.props.cmController.findNext();
133-
this.setDropdown('none');
134-
}
135-
136-
handleFindPrevious() {
137-
this.props.cmController.findPrev();
138-
this.setDropdown('none');
139-
}
140-
141129
handleReplace() {
142130
this.props.cmController.showReplace();
143131
this.setDropdown('none');
@@ -434,7 +422,9 @@ class Nav extends React.PureComponent {
434422
onBlur={this.handleBlur}
435423
>
436424
{this.props.t('Nav.Edit.TidyCode')}
437-
<span className="nav__keyboard-shortcut">{'\u21E7'}+Tab</span>
425+
<span className="nav__keyboard-shortcut">
426+
{metaKeyName}+{'\u21E7'}+F
427+
</span>
438428
</button>
439429
</li>
440430
<li className="nav__dropdown-item">
@@ -447,28 +437,6 @@ class Nav extends React.PureComponent {
447437
<span className="nav__keyboard-shortcut">{metaKeyName}+F</span>
448438
</button>
449439
</li>
450-
<li className="nav__dropdown-item">
451-
<button
452-
onClick={this.handleFindNext}
453-
onFocus={this.handleFocusForEdit}
454-
onBlur={this.handleBlur}
455-
>
456-
{this.props.t('Nav.Edit.FindNext')}
457-
<span className="nav__keyboard-shortcut">{metaKeyName}+G</span>
458-
</button>
459-
</li>
460-
<li className="nav__dropdown-item">
461-
<button
462-
onClick={this.handleFindPrevious}
463-
onFocus={this.handleFocusForEdit}
464-
onBlur={this.handleBlur}
465-
>
466-
{this.props.t('Nav.Edit.FindPrevious')}
467-
<span className="nav__keyboard-shortcut">
468-
{'\u21E7'}+{metaKeyName}+G
469-
</span>
470-
</button>
471-
</li>
472440
<li className="nav__dropdown-item">
473441
<button
474442
onClick={this.handleReplace}

client/components/__test__/Nav.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ describe('Nav', () => {
4646
},
4747
t: jest.fn(),
4848
setLanguage: jest.fn(),
49-
language: 'en-US'
49+
language: 'en-US',
50+
isUserOwner: true
5051
};
5152

5253
it('renders correctly', () => {

client/components/__test__/__snapshots__/Nav.test.jsx.snap

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ exports[`Nav renders correctly 1`] = `
8585
<span
8686
class="nav__keyboard-shortcut"
8787
>
88-
⇧+Tab
88+
⌃+⇧+F
8989
</span>
9090
</button>
9191
</li>
@@ -100,28 +100,6 @@ exports[`Nav renders correctly 1`] = `
100100
</span>
101101
</button>
102102
</li>
103-
<li
104-
class="nav__dropdown-item"
105-
>
106-
<button>
107-
<span
108-
class="nav__keyboard-shortcut"
109-
>
110-
⌃+G
111-
</span>
112-
</button>
113-
</li>
114-
<li
115-
class="nav__dropdown-item"
116-
>
117-
<button>
118-
<span
119-
class="nav__keyboard-shortcut"
120-
>
121-
⇧+⌃+G
122-
</span>
123-
</button>
124-
</li>
125103
<li
126104
class="nav__dropdown-item"
127105
>

client/modules/IDE/components/Editor.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ const beautifyHTML = beautifyJS.html;
6565
window.JSHINT = JSHINT;
6666
window.CSSLint = CSSLint;
6767
window.HTMLHint = HTMLHint;
68-
delete CodeMirror.keyMap.sublime['Shift-Tab'];
6968

7069
const IS_TAB_INDENT = false;
7170
const INDENTATION_AMOUNT = 2;
@@ -179,8 +178,14 @@ class Editor extends React.Component {
179178
});
180179

181180
this._cm.on('keydown', (_cm, e) => {
182-
// 9 === Tab
183-
if (e.keyCode === 9 && e.shiftKey) {
181+
// 70 === f
182+
if (
183+
((metaKey === 'Cmd' && e.metaKey) ||
184+
(metaKey === 'Ctrl' && e.ctrlKey)) &&
185+
e.shiftKey &&
186+
e.keyCode === 70
187+
) {
188+
e.preventDefault();
184189
this.tidyCode();
185190
}
186191
});
@@ -295,7 +300,7 @@ class Editor extends React.Component {
295300
mode = 'javascript';
296301
} else if (fileName.match(/.+\.css$/i)) {
297302
mode = 'css';
298-
} else if (fileName.match(/.+\.html$/i)) {
303+
} else if (fileName.match(/.+\.(html|xml)$/i)) {
299304
mode = 'htmlmixed';
300305
} else if (fileName.match(/.+\.json$/i)) {
301306
mode = 'application/json';

client/modules/IDE/components/KeyboardShortcutModal.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ function KeyboardShortcutModal() {
2424
</p>
2525
<ul className="keyboard-shortcuts__list">
2626
<li className="keyboard-shortcut-item">
27-
<span className="keyboard-shortcut__command">{'\u21E7'} + Tab</span>
27+
<span className="keyboard-shortcut__command">
28+
{metaKeyName} + {'\u21E7'} + F
29+
</span>
2830
<span>{t('KeyboardShortcuts.CodeEditing.Tidy')}</span>
2931
</li>
3032
<li className="keyboard-shortcut-item">

client/modules/IDE/reducers/files.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ function draw() {
1212
const defaultHTML = `<!DOCTYPE html>
1313
<html lang="en">
1414
<head>
15-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
16-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
15+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/p5.js"></script>
16+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/addons/p5.sound.min.js"></script>
1717
<link rel="stylesheet" type="text/css" href="style.css">
1818
<meta charset="utf-8" />
1919
@@ -167,8 +167,7 @@ const files = (state, action) => {
167167
return [...action.files];
168168
case ActionTypes.RESET_PROJECT:
169169
return initialState();
170-
case ActionTypes.CREATE_FILE: // eslint-disable-line
171-
{
170+
case ActionTypes.CREATE_FILE: {
172171
const newState = [
173172
...updateParent(state, action),
174173
{

package-lock.json

Lines changed: 9 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@
217217
"redux-devtools-dock-monitor": "^1.1.3",
218218
"redux-devtools-log-monitor": "^1.4.0",
219219
"redux-thunk": "^2.3.0",
220-
"request": "^2.88.2",
221-
"request-promise": "^4.2.5",
222220
"reselect": "^4.0.0",
223221
"s3-policy-v4": "0.0.3",
224222
"sass-extract": "^2.1.0",

server/controllers/project.controller.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import format from 'date-fns/format';
33
import isUrl from 'is-url';
44
import jsdom, { serializeDocument } from 'jsdom';
55
import isAfter from 'date-fns/isAfter';
6-
import request from 'request';
6+
import axios from 'axios';
77
import slugify from 'slugify';
88
import Project from '../models/project';
99
import User from '../models/user';
@@ -125,7 +125,7 @@ export function getProjectsForUserId(userId) {
125125
export function getProjectAsset(req, res) {
126126
Project.findById(req.params.project_id)
127127
.populate('user', 'username')
128-
.exec((err, project) => { // eslint-disable-line
128+
.exec(async (err, project) => { // eslint-disable-line
129129
if (err) {
130130
return res
131131
.status(404)
@@ -145,15 +145,15 @@ export function getProjectAsset(req, res) {
145145
if (!resolvedFile.url) {
146146
return res.send(resolvedFile.content);
147147
}
148-
request(
149-
{ method: 'GET', url: resolvedFile.url, encoding: null },
150-
(innerErr, response, body) => {
151-
if (innerErr) {
152-
return res.status(404).send({ message: 'Asset does not exist' });
153-
}
154-
return res.send(body);
155-
}
156-
);
148+
149+
try {
150+
const { data } = await axios.get(resolvedFile.url, {
151+
responseType: 'arraybuffer'
152+
});
153+
res.send(data);
154+
} catch (error) {
155+
res.status(404).send({ message: 'Asset does not exist' });
156+
}
157157
});
158158
}
159159

@@ -198,7 +198,7 @@ function bundleExternalLibs(project, zip, callback) {
198198
let numScriptsResolved = 0;
199199
let numScriptTags = 0;
200200

201-
function resolveScriptTagSrc(scriptTag, document) {
201+
async function resolveScriptTagSrc(scriptTag, document) {
202202
const path = scriptTag.src.split('/');
203203
const filename = path[path.length - 1];
204204
const { src } = scriptTag;
@@ -212,23 +212,21 @@ function bundleExternalLibs(project, zip, callback) {
212212
return;
213213
}
214214

215-
request(
216-
{ method: 'GET', url: src, encoding: null },
217-
(err, response, body) => {
218-
if (err) {
219-
console.log(err);
220-
} else {
221-
zip.append(body, { name: filename });
222-
scriptTag.src = filename;
223-
}
215+
try {
216+
const { data } = await axios.get(src, {
217+
responseType: 'arraybuffer'
218+
});
219+
zip.append(data, { name: filename });
220+
scriptTag.src = filename;
221+
} catch (err) {
222+
console.log(err);
223+
}
224224

225-
numScriptsResolved += 1;
226-
if (numScriptsResolved === numScriptTags) {
227-
indexHtml.content = serializeDocument(document);
228-
callback();
229-
}
230-
}
231-
);
225+
numScriptsResolved += 1;
226+
if (numScriptsResolved === numScriptTags) {
227+
indexHtml.content = serializeDocument(document);
228+
callback();
229+
}
232230
}
233231

234232
jsdom.env(indexHtml.content, (innerErr, window) => {
@@ -264,7 +262,7 @@ function buildZip(project, req, res) {
264262
);
265263
zip.pipe(res);
266264

267-
function addFileToZip(file, path) {
265+
async function addFileToZip(file, path) {
268266
if (file.fileType === 'folder') {
269267
const newPath = file.name === 'root' ? path : `${path}${file.name}/`;
270268
file.children.forEach((fileId) => {
@@ -274,16 +272,18 @@ function buildZip(project, req, res) {
274272
})();
275273
});
276274
} else if (file.url) {
277-
request(
278-
{ method: 'GET', url: file.url, encoding: null },
279-
(err, response, body) => {
280-
zip.append(body, { name: `${path}${file.name}` });
281-
numCompletedFiles += 1;
282-
if (numCompletedFiles === numFiles) {
283-
zip.finalize();
284-
}
285-
}
286-
);
275+
try {
276+
const { data } = await axios.get(file.url, {
277+
responseType: 'arraybuffer'
278+
});
279+
zip.append(data, { name: `${path}${file.name}` });
280+
} catch (err) {
281+
console.log(err);
282+
}
283+
numCompletedFiles += 1;
284+
if (numCompletedFiles === numFiles) {
285+
zip.finalize();
286+
}
287287
} else {
288288
zip.append(file.content, { name: `${path}${file.name}` });
289289
numCompletedFiles += 1;

0 commit comments

Comments
 (0)