Skip to content

Commit b8ba4eb

Browse files
committed
Merge branch 'develop' into refactor/update-to-axios
2 parents eb802e7 + aa51e20 commit b8ba4eb

File tree

6 files changed

+30
-22
lines changed

6 files changed

+30
-22
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/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
{

server/controllers/project.controller/deleteProject.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ function deleteFilesFromS3(files) {
1111
deleteObjectsFromS3(
1212
files
1313
.filter((file) => {
14-
if (file.url) {
14+
if (
15+
file.url &&
16+
(file.url.includes(process.env.S3_BUCKET_URL_BASE) ||
17+
file.url.includes(process.env.S3_BUCKET))
18+
) {
1519
if (
1620
!process.env.S3_DATE ||
1721
(process.env.S3_DATE &&

server/domain-objects/createDefaultFiles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function draw() {
99
const defaultHTML = `<!DOCTYPE html>
1010
<html>
1111
<head>
12-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
13-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
12+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/p5.js"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/addons/p5.sound.min.js"></script>
1414
<link rel="stylesheet" type="text/css" href="style.css">
1515
<meta charset="utf-8" />
1616

server/scripts/examples-ml5.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import axios from 'axios';
33
import Q from 'q';
44
import { ok } from 'assert';
55

6-
// TODO: Change branchName if necessary
7-
const branchName = 'release';
6+
const branchName = 'main';
87
const branchRef = `?ref=${branchName}`;
9-
const baseUrl = 'https://api.github.com/repos/ml5js/ml5-examples/contents';
8+
const baseUrl = 'https://api.github.com/repos/ml5js/ml5-library/contents';
109
const clientId = process.env.GITHUB_ID;
1110
const clientSecret = process.env.GITHUB_SECRET;
12-
const editorUsername = process.env.ML5_EXAMPLES_USERNAME;
11+
const editorUsername = process.env.ML5_LIBRARY_USERNAME;
1312
const personalAccessToken = process.env.EDITOR_API_ACCESS_TOKEN;
1413
const editorApiUrl = process.env.EDITOR_API_URL;
1514
const headers = {
@@ -18,7 +17,7 @@ const headers = {
1817

1918
ok(clientId, 'GITHUB_ID is required');
2019
ok(clientSecret, 'GITHUB_SECRET is required');
21-
ok(editorUsername, 'ML5_EXAMPLES_USERNAME is required');
20+
ok(editorUsername, 'ML5_LIBRARY_USERNAME is required');
2221
ok(personalAccessToken, 'EDITOR_API_ACCESS_TOKEN is required');
2322
ok(editorApiUrl, 'EDITOR_API_URL is required');
2423

@@ -85,14 +84,20 @@ async function fetchFileContent(item) {
8584
// NOTE: remove the URL property if there's content
8685
// Otherwise the p5 editor will try to pull from that url
8786
if (file.content !== null) delete file.url;
87+
88+
// Replace localhost references with references to the currently published version.
89+
file.content = file.content.replace(
90+
/http:\/\/localhost(:[0-9]+)\/ml5.js/g,
91+
'https://unpkg.com/ml5@latest/dist/ml5.min.js'
92+
);
8893
}
8994

9095
return file;
9196
// if it is NOT an html or js file
9297
}
9398

9499
if (file.url) {
95-
const cdnRef = `https://cdn.jsdelivr.net/gh/ml5js/ml5-examples@${branchName}${
100+
const cdnRef = `https://cdn.jsdelivr.net/gh/ml5js/ml5-library@${branchName}${
96101
file.url.split(branchName)[1]
97102
}`;
98103
file.url = cdnRef;
@@ -161,7 +166,7 @@ async function traverseSketchTree(parentObject) {
161166
if (parentObject.type !== 'dir') {
162167
return output;
163168
}
164-
// let options = `https://api.github.com/repos/ml5js/ml5-examples/contents/${sketches.path}${branchRef}`
169+
// let options = `https://api.github.com/repos/ml5js/ml5-library/contents/examples/p5js/${sketches.path}${branchRef}`
165170
const options = Object.assign({}, githubRequestOptions);
166171
options.url = `${options.url}${parentObject.path}${branchRef}`;
167172

@@ -366,7 +371,7 @@ async function createProjectsInP5User(filledProjectList, user) {
366371

367372
/**
368373
* MAKE
369-
* Get all the sketches from the ml5-examples repo
374+
* Get all the sketches from the ml5-library repo
370375
* Get the p5 examples
371376
* Dive down into each sketch and get all the files
372377
* Format the sketch files to be save to the db
@@ -391,7 +396,7 @@ async function make() {
391396

392397
/**
393398
* TEST - same as make except reads from file for testing purposes
394-
* Get all the sketches from the ml5-examples repo
399+
* Get all the sketches from the ml5-library repo
395400
* Get the p5 examples
396401
* Dive down into each sketch and get all the files
397402
* Format the sketch files to be save to the db
@@ -427,7 +432,7 @@ async function test() {
427432
*/
428433

429434
if (process.env.NODE_ENV === 'development') {
430-
// test()
435+
// test();
431436
make(); // replace with test() if you don't want to run all the fetch functions over and over
432437
} else {
433438
make();

server/scripts/examples.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import Project from '../models/project';
99
const defaultHTML = `<!DOCTYPE html>
1010
<html lang="en">
1111
<head>
12-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
13-
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
12+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/p5.js"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/addons/p5.sound.min.js"></script>
1414
<link rel="stylesheet" type="text/css" href="style.css">
1515
<meta charset="utf-8" />
1616
</head>

0 commit comments

Comments
 (0)