Skip to content

Commit 7d6ba6f

Browse files
committed
Merge branch 'develop' into feature/mobile-settings-screen
2 parents 58d8fc1 + ff658c7 commit 7d6ba6f

File tree

7 files changed

+39
-27
lines changed

7 files changed

+39
-27
lines changed

client/modules/IDE/actions/project.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,20 @@ export function saveProject(selectedFile = null, autosave = false) {
155155
if (!autosave) {
156156
if (state.ide.justOpenedProject && state.preferences.autosave) {
157157
dispatch(showToast(5500));
158-
dispatch(setToastText('Project saved.'));
158+
dispatch(setToastText('Sketch saved.'));
159159
setTimeout(() => dispatch(setToastText('Autosave enabled.')), 1500);
160160
dispatch(resetJustOpenedProject());
161161
} else {
162162
dispatch(showToast(1500));
163-
dispatch(setToastText('Project saved.'));
163+
dispatch(setToastText('Sketch saved.'));
164164
}
165165
}
166166
})
167167
.catch((error) => {
168168
const { response } = error;
169169
dispatch(endSavingProject());
170+
dispatch(setToastText('Failed to save sketch.'));
171+
dispatch(showToast(1500));
170172
if (response.status === 403) {
171173
dispatch(showErrorModal('staleSession'));
172174
} else if (response.status === 409) {
@@ -195,18 +197,20 @@ export function saveProject(selectedFile = null, autosave = false) {
195197
if (!autosave) {
196198
if (state.preferences.autosave) {
197199
dispatch(showToast(5500));
198-
dispatch(setToastText('Project saved.'));
200+
dispatch(setToastText('Sketch saved.'));
199201
setTimeout(() => dispatch(setToastText('Autosave enabled.')), 1500);
200202
dispatch(resetJustOpenedProject());
201203
} else {
202204
dispatch(showToast(1500));
203-
dispatch(setToastText('Project saved.'));
205+
dispatch(setToastText('Sketch saved.'));
204206
}
205207
}
206208
})
207209
.catch((error) => {
208210
const { response } = error;
209211
dispatch(endSavingProject());
212+
dispatch(setToastText('Failed to save sketch.'));
213+
dispatch(showToast(1500));
210214
if (response.status === 403) {
211215
dispatch(showErrorModal('staleSession'));
212216
} else {

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,18 @@ class PreviewFrame extends React.Component {
237237
jsFileStrings.forEach((jsFileString) => {
238238
if (jsFileString.match(MEDIA_FILE_QUOTED_REGEX)) {
239239
const filePath = jsFileString.substr(1, jsFileString.length - 2);
240+
const quoteCharacter = jsFileString.substr(0, 1);
240241
const resolvedFile = resolvePathToFile(filePath, files);
242+
241243
if (resolvedFile) {
242244
if (resolvedFile.url) {
243-
newContent = newContent.replace(filePath, resolvedFile.url);
245+
newContent = newContent.replace(jsFileString, quoteCharacter + resolvedFile.url + quoteCharacter);
244246
} else if (resolvedFile.name.match(PLAINTEXT_FILE_REGEX)) {
245247
// could also pull file from API instead of using bloburl
246248
const blobURL = getBlobUrl(resolvedFile);
247249
this.props.setBlobUrl(resolvedFile, blobURL);
248-
const filePathRegex = new RegExp(filePath, 'gi');
249-
newContent = newContent.replace(filePathRegex, blobURL);
250+
251+
newContent = newContent.replace(jsFileString, quoteCharacter + blobURL + quoteCharacter);
250252
}
251253
}
252254
}
@@ -262,10 +264,11 @@ class PreviewFrame extends React.Component {
262264
cssFileStrings.forEach((cssFileString) => {
263265
if (cssFileString.match(MEDIA_FILE_QUOTED_REGEX)) {
264266
const filePath = cssFileString.substr(1, cssFileString.length - 2);
267+
const quoteCharacter = cssFileString.substr(0, 1);
265268
const resolvedFile = resolvePathToFile(filePath, files);
266269
if (resolvedFile) {
267270
if (resolvedFile.url) {
268-
newContent = newContent.replace(filePath, resolvedFile.url);
271+
newContent = newContent.replace(cssFileString, quoteCharacter + resolvedFile.url + quoteCharacter);
269272
}
270273
}
271274
}

client/modules/IDE/pages/IDEView.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ import AddToCollectionList from '../components/AddToCollectionList';
3434
import Feedback from '../components/Feedback';
3535
import { CollectionSearchbar } from '../components/Searchbar';
3636

37+
function getTitle(props) {
38+
const { id } = props.project;
39+
return id ? `p5.js Web Editor | ${props.project.name}` : 'p5.js Web Editor';
40+
}
41+
42+
function isUserOwner(props) {
43+
return props.project.owner && props.project.owner.id === props.user.id;
44+
}
45+
3746
class IDEView extends React.Component {
3847
constructor(props) {
3948
super(props);
@@ -92,7 +101,7 @@ class IDEView extends React.Component {
92101
}
93102

94103
componentDidUpdate(prevProps) {
95-
if (this.isUserOwner() && this.props.project.id) {
104+
if (isUserOwner(this.props) && this.props.project.id) {
96105
if (this.props.preferences.autosave && this.props.ide.unsavedChanges && !this.props.ide.justOpenedProject) {
97106
if (
98107
this.props.selectedFile.name === prevProps.selectedFile.name &&
@@ -123,21 +132,12 @@ class IDEView extends React.Component {
123132
this.autosaveInterval = null;
124133
}
125134

126-
getTitle = () => {
127-
const { id } = this.props.project;
128-
return id ? `p5.js Web Editor | ${this.props.project.name}` : 'p5.js Web Editor';
129-
}
130-
131-
isUserOwner() {
132-
return this.props.project.owner && this.props.project.owner.id === this.props.user.id;
133-
}
134-
135135
handleGlobalKeydown(e) {
136136
// 83 === s
137137
if (e.keyCode === 83 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) {
138138
e.preventDefault();
139139
e.stopPropagation();
140-
if (this.isUserOwner() || (this.props.user.authenticated && !this.props.project.owner)) {
140+
if (isUserOwner(this.props) || (this.props.user.authenticated && !this.props.project.owner)) {
141141
this.props.saveProject(this.cmController.getContent());
142142
} else if (this.props.user.authenticated) {
143143
this.props.cloneProject();
@@ -208,7 +208,7 @@ class IDEView extends React.Component {
208208
return (
209209
<div className="ide">
210210
<Helmet>
211-
<title>{this.getTitle()}</title>
211+
<title>{getTitle(this.props)}</title>
212212
</Helmet>
213213
{this.props.toast.isVisible && <Toast />}
214214
<Nav
@@ -313,7 +313,7 @@ class IDEView extends React.Component {
313313
isExpanded={this.props.ide.sidebarIsExpanded}
314314
expandSidebar={this.props.expandSidebar}
315315
collapseSidebar={this.props.collapseSidebar}
316-
isUserOwner={this.isUserOwner()}
316+
isUserOwner={isUserOwner(this.props)}
317317
clearConsole={this.props.clearConsole}
318318
consoleEvents={this.props.console}
319319
showRuntimeErrorWarning={this.props.showRuntimeErrorWarning}

client/modules/IDE/selectors/collections.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const getSortedCollections = createSelector(
3737
return orderBy(collections, 'name', 'desc');
3838
}
3939
return orderBy(collections, 'name', 'asc');
40+
} else if (field === 'numItems') {
41+
if (direction === DIRECTION.DESC) {
42+
return orderBy(collections, 'items.length', 'desc');
43+
}
44+
return orderBy(collections, 'items.length', 'asc');
4045
}
4146
const sortedCollections = [...collections].sort((a, b) => {
4247
const result =

developer_docs/installation.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ Note that this is optional, unless you are working on the part of the applicatio
6969
If your S3 bucket is in the US East (N Virginia) region (us-east-1), you'll
7070
need to set a custom URL base for it, because it does not follow the standard
7171
naming pattern as the rest of the regions. Instead, add the following to your
72-
environment/.env file:
73-
74-
`S3_BUCKET_URL_BASE=https://s3.amazonaws.com`
72+
environment/.env file, changing `BUCKET_NAME` to your bucket name. This is necessary because this override is currently treated as the full path to the bucket rather than as a proper base url:
73+
`S3_BUCKET_URL_BASE=https://s3.amazonaws.com/{BUCKET_NAME}/`
7574

7675
If you've configured your S3 bucket and DNS records to use a custom domain
7776
name, you can also set it using this variable. I.e.:

server/controllers/embed.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function serveProject(req, res) {
3434
resolveScripts(sketchDoc, files);
3535
resolveStyles(sketchDoc, files);
3636

37+
res.setHeader('Cache-Control', 'public, max-age=0');
3738
res.send(serializeDocument(sketchDoc));
3839
});
3940
});

server/scripts/examples.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function getCategories() {
7373
function getSketchesInCategories(categories) {
7474
return Q.all(categories.map((category) => {
7575
const options = {
76-
url: `${category.url.replace('?ref=master', '')}?client_id=${clientId}&client_secret=${clientSecret}`,
76+
url: `${category.url.replace('?ref=main', '')}?client_id=${clientId}&client_secret=${clientSecret}`,
7777
method: 'GET',
7878
headers,
7979
json: true
@@ -107,7 +107,7 @@ function getSketchesInCategories(categories) {
107107
function getSketchContent(projectsInAllCategories) {
108108
return Q.all(projectsInAllCategories.map(projectsInOneCategory => Q.all(projectsInOneCategory.map((project) => {
109109
const options = {
110-
url: `${project.sketchUrl.replace('?ref=master', '')}?client_id=${clientId}&client_secret=${clientSecret}`,
110+
url: `${project.sketchUrl.replace('?ref=main', '')}?client_id=${clientId}&client_secret=${clientSecret}`,
111111
method: 'GET',
112112
headers
113113
};
@@ -264,7 +264,7 @@ function createProjectsInP5user(projectsInAllCategories) {
264264
const fileID = objectID().toHexString();
265265
newProject.files.push({
266266
name: assetName,
267-
url: `https://cdn.jsdelivr.net/gh/processing/p5.js-website@master/src/data/examples/assets/${assetName}`,
267+
url: `https://cdn.jsdelivr.net/gh/processing/p5.js-website@main/src/data/examples/assets/${assetName}`,
268268
id: fileID,
269269
_id: fileID,
270270
children: [],

0 commit comments

Comments
 (0)