Skip to content
This repository has been archived by the owner. It is now read-only.

Commit ad0fd9f

Browse files
committed
added menu item, gulp to pull refrence, and ability execute a server for local files, trying to get the path to local ref
1 parent 6abfa02 commit ad0fd9f

File tree

399 files changed

+82714
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

399 files changed

+82714
-72
lines changed

app/main.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ var appConfig = {
301301
}).on('change', function(path) {
302302
if (Files.find(self.files, path).open === true) {
303303
if (self.justSaved) {
304-
self.justSaved = false;
304+
self.justSaved = false;
305305
} else {
306306
console.log(path);
307307
if (!self.temp) self.askReload = true;
@@ -381,7 +381,7 @@ var appConfig = {
381381
});
382382
},
383383

384-
384+
385385

386386
saveFile: function() {
387387
// if this is a new project then trigger a save-as
@@ -446,12 +446,12 @@ var appConfig = {
446446
}
447447
}
448448
},
449-
449+
450450
closeFile: function(path){
451451
// check to see if there are unsaved files
452452
var file = Files.find(this.files, path);
453453
if (!file) return false;
454-
454+
455455

456456
if(this.tabs.length==1){
457457
var win = gui.Window.get();
@@ -464,7 +464,7 @@ var appConfig = {
464464
}
465465
if (shouldClose) {
466466
file.open = false;
467-
file.contents = file.lastSavedContents;
467+
file.contents = file.lastSavedContents;
468468
this.$broadcast('close-file', file);
469469
return true;
470470
}
@@ -549,7 +549,12 @@ var appConfig = {
549549

550550
showHelp: function() {
551551
gui.Shell.openExternal(this.$options.mode.referenceURL);
552-
}
552+
},
553+
554+
offlineRef: function() {
555+
// $('#debug').html('');
556+
this.modeFunction('offlineRef');
557+
},
553558

554559
}
555560

app/menu.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ var fs = nodeRequire('fs');
2525
*/
2626
module.exports.setup = function(app) {
2727
if (isWin || isLinux) {
28-
//Setup menus for windows
29-
fileMenu.append(new gui.MenuItem({
28+
//Setup menus for windows
29+
fileMenu.append(new gui.MenuItem({
3030
label: 'New Project Ctrl+Shift+N',
3131
modifiers: 'shift-ctrl', key: 'n', click: function(){
3232
app.newWindow(app.windowURL);
3333
}}));
3434

35-
fileMenu.append(new gui.MenuItem({
35+
fileMenu.append(new gui.MenuItem({
3636
label: 'New File Ctrl+N',
3737
modifiers: 'ctrl', key: 'n', click: function(){
3838
app.newFile();
3939
}}));
4040

41-
fileMenu.append(new gui.MenuItem({
41+
fileMenu.append(new gui.MenuItem({
4242
label: 'New Folder',
4343
click: function(){
4444
app.newFolder();
4545
}}));
4646

47-
fileMenu.append(new gui.MenuItem({
47+
fileMenu.append(new gui.MenuItem({
4848
label: 'Open Ctrl+O',
4949
modifiers: 'ctrl', key: 'o', click: function(){
5050
$('#openFile').trigger('click');
@@ -54,25 +54,25 @@ module.exports.setup = function(app) {
5454
module.exports.updateRecentFiles(app);
5555
fileMenu.append(openRecent);
5656

57-
fileMenu.append(new gui.MenuItem({
57+
fileMenu.append(new gui.MenuItem({
5858
label: 'Close Ctrl+W',
5959
modifiers: 'ctrl', key: 'w', click: function(){
6060
app.closeProject();
6161
}}));
6262

63-
fileMenu.append(new gui.MenuItem({
63+
fileMenu.append(new gui.MenuItem({
6464
label: 'Save Ctrl+S',
6565
modifiers: 'ctrl', key: 's', click: function(){
6666
app.saveFile();
6767
}}));
6868

69-
// fileMenu.append(new gui.MenuItem({
69+
// fileMenu.append(new gui.MenuItem({
7070
// label: 'Save File As... Ctrl+Shift+S',
7171
// modifiers: 'shift-ctrl', key: 's', click: function(){
7272
// app.saveFileAs(app.currentFile.path);
7373
// }}));
7474

75-
fileMenu.append(new gui.MenuItem({
75+
fileMenu.append(new gui.MenuItem({
7676
label: 'Save As... Ctrl+Shift+S',
7777
modifiers: 'shift-ctrl', key: 's', click: function(){
7878
$('#saveProject').trigger('click');
@@ -107,49 +107,49 @@ module.exports.setup = function(app) {
107107

108108
fileMenu.append(new gui.MenuItem({ type: 'separator' }));
109109

110-
fileMenu.append(new gui.MenuItem({
110+
fileMenu.append(new gui.MenuItem({
111111
label: 'Run Ctrl+R',
112112
modifiers: 'ctrl', key: 'r', click: function(){
113113
app.run();
114114
}}));
115115

116-
view.append(new gui.MenuItem({
116+
view.append(new gui.MenuItem({
117117
label: 'Show Sketch Folder Ctrl+K',
118118
modifiers: 'ctrl', key: 'k', click: function(){
119119
gui.Shell.showItemInFolder(app.projectPath);
120120
}}));
121121

122122
view.append(new gui.MenuItem({ type: 'separator' }));
123123

124-
view.append(new gui.MenuItem({
124+
view.append(new gui.MenuItem({
125125
label: 'Reformat Ctrl+T',
126126
modifiers: 'ctrl', key: 't', click: function(){
127127
app.$.editor.reformat();
128128
}}));
129129

130130
view.append(new gui.MenuItem({ type: 'separator' }));
131131

132-
view.append(new gui.MenuItem({
132+
view.append(new gui.MenuItem({
133133
label: 'Toggle Settings Panel Ctrl+,',
134134
modifiers: 'ctrl', key: ',', click: function(){
135135
app.toggleSettingsPane();
136136
}}))
137137

138-
view.append(new gui.MenuItem({
138+
view.append(new gui.MenuItem({
139139
label: 'Toggle Sidebar Ctrl+.',
140140
modifiers: 'ctrl', key: '.', click: function(){
141141
app.toggleSidebar();
142142
}}))
143143

144144
view.append(new gui.MenuItem({ type: 'separator' }));
145145

146-
view.append(new gui.MenuItem({
146+
view.append(new gui.MenuItem({
147147
label: 'Increase Font Size Ctrl+=',
148148
modifiers: 'ctrl', key: '=', click: function(){
149149
app.changeFontSize(1);
150150
}}))
151151

152-
view.append(new gui.MenuItem({
152+
view.append(new gui.MenuItem({
153153
label: 'Decrease Font Size Ctrl+-',
154154
modifiers: 'ctrl', key: '-', click: function(){
155155
app.changeFontSize(-1);
@@ -248,7 +248,7 @@ module.exports.setup = function(app) {
248248
fileMenu.append(new gui.MenuItem({ label: 'Run',
249249
modifiers: 'cmd', key: 'r', click: function(){
250250
app.run();
251-
251+
252252
}}));
253253

254254
view.append(new gui.MenuItem({ label: 'Show Sketch Folder',
@@ -318,6 +318,10 @@ module.exports.setup = function(app) {
318318
app.showHelp();
319319
}}));
320320

321+
help.append(new gui.MenuItem({ label: 'Offline Reference', click: function(){
322+
app.offlineRef();
323+
}}));
324+
321325
if (isWin || isLinux) {
322326
menubar.append(new gui.MenuItem({ label: 'File', submenu: fileMenu}));
323327
menubar.append(new gui.MenuItem({ label: 'View', submenu: view}));
@@ -339,7 +343,7 @@ module.exports.setup = function(app) {
339343
var edit = new gui.Menu();
340344

341345
var undo = new gui.MenuItem(
342-
{ label: 'Undo Ctrl+Z',
346+
{ label: 'Undo Ctrl+Z',
343347
modifiers: 'ctrl', key: 'z', click: function(){
344348
}});
345349
undo.on('click', function(){
@@ -348,7 +352,7 @@ module.exports.setup = function(app) {
348352
edit.append(undo);
349353

350354
var redo = new gui.MenuItem(
351-
{ label: 'Redo Ctrl+Shift+Z',
355+
{ label: 'Redo Ctrl+Shift+Z',
352356
modifiers: 'shift-ctrl', key: 'z', click: function(){
353357
}});
354358
redo.on('click', function(){
@@ -359,7 +363,7 @@ module.exports.setup = function(app) {
359363
edit.append(new gui.MenuItem({ type: 'separator' }));
360364

361365
var cut = new gui.MenuItem(
362-
{ label: 'Cut Ctrl+X',
366+
{ label: 'Cut Ctrl+X',
363367
modifiers: 'ctrl', key: 'x', click: function(){
364368
}});
365369
cut.on('click', function(){
@@ -368,7 +372,7 @@ module.exports.setup = function(app) {
368372
edit.append(cut);
369373

370374
var copy = new gui.MenuItem(
371-
{ label: 'Copy Ctrl+C',
375+
{ label: 'Copy Ctrl+C',
372376
modifiers: 'ctrl', key: 'c', click: function(){
373377
}});
374378
copy.on('click', function(){
@@ -377,7 +381,7 @@ module.exports.setup = function(app) {
377381
edit.append(copy);
378382

379383
var paste = new gui.MenuItem(
380-
{ label: 'Paste Ctrl+V',
384+
{ label: 'Paste Ctrl+V',
381385
modifiers: 'ctrl', key: 'v', click: function(){
382386
}});
383387
paste.on('click', function(){
@@ -386,7 +390,7 @@ module.exports.setup = function(app) {
386390
edit.append(paste);
387391

388392
var del = new gui.MenuItem(
389-
{ label: 'Delete Ctrl+D',
393+
{ label: 'Delete Ctrl+D',
390394
modifiers: 'ctrl', key: 'd', click: function(){
391395
}});
392396
del.on('click', function(){
@@ -395,7 +399,7 @@ module.exports.setup = function(app) {
395399
edit.append(del);
396400

397401
var selAll = new gui.MenuItem(
398-
{ label: 'Select All Ctrl+A',
402+
{ label: 'Select All Ctrl+A',
399403
modifiers: 'ctrl', key: 'a', click: function(){
400404
}});
401405
selAll.on('click', function(){
@@ -406,7 +410,7 @@ module.exports.setup = function(app) {
406410
edit.append(new gui.MenuItem({ type: 'separator' }));
407411

408412
var findItem = new gui.MenuItem(
409-
{ label: 'Find Ctrl+F',
413+
{ label: 'Find Ctrl+F',
410414
modifiers: 'ctrl', key: 'f', click: function(){
411415
}});
412416
findItem.on('click', function(){

app/modes/p5/p5-mode.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,18 @@ module.exports = {
254254
});
255255
},
256256

257-
referenceURL: 'http://p5js.org/reference/'
258-
259-
};
257+
referenceURL: 'http://p5js.org/reference/',
258+
259+
offlineRef: function(){
260+
var path = window.location.pathname;
261+
path = path.substr(0, path.lastIndexOf('/'));
262+
var orDir = Path.join(path,'mode_assets', 'p5', 'p5-reference');
263+
console.log(orDir);
264+
startServer(orDir, this, function(url) {
265+
gui.Shell.openExternal(url);
266+
})
267+
}
268+
}
260269

261270
var running = false;
262271
var url = '';

gulpfile.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var Path = require('path');
1414
var fs = require('fs');
1515
var info = require('./package.json');
1616
var request = require('request');
17+
var unzip = require('unzip');
1718

1819
var isWin = process.platform === 'win32';
1920
var isMac = process.platform === 'darwin';
@@ -202,6 +203,19 @@ gulp.task('p5', function () {
202203

203204
});
204205

206+
gulp.task('getOfflineRefrence', function(){
207+
208+
// get latest .zip data from p5js website and unzip it.
209+
request('http://p5js.org/offline-reference/p5-reference.zip')
210+
// .pipe(fs.createWriteStream('./public/mode_assets/p5/p5-reference.zip'))
211+
.pipe(unzip.Extract({ path: './public/mode_assets/p5/p5-reference' }))
212+
.on('close', function () {
213+
console.log('offline-Refrence Retrieved!');
214+
});
215+
216+
217+
})
218+
205219
gulp.task('release', function(){
206220
build(function(){
207221
latest().pipe(release(info));

package.json

100755100644
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Sam Lavigne",
33
"name": "p5",
44
"description": "Javascript IDE for beginners",
5-
"version": "0.6.0",
5+
"version": "0.6.1",
66
"devDependencies": {
77
"autolinker": "^0.17.1",
88
"br-mousetrap": "~1.1.3",
@@ -34,5 +34,8 @@
3434
"repository": {
3535
"type": "git",
3636
"url": "git://github.com/antiboredom/jside.git"
37+
},
38+
"dependencies": {
39+
"unzip": "^0.1.11"
3740
}
3841
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* @name Brownian Motion
3+
* @description Recording random movement as a continuous line.
4+
* Port of original example from the Processing examples page.
5+
*/
6+
7+
var num = 2000;
8+
var range = 6;
9+
10+
var ax = [];
11+
var ay = [];
12+
13+
14+
function setup() {
15+
createCanvas(710, 400);
16+
for ( var i = 0; i < num; i++ ) {
17+
ax[i] = width / 2;
18+
ay[i] = height / 2;
19+
}
20+
frameRate(30);
21+
}
22+
23+
function draw() {
24+
background(51);
25+
26+
// Shift all elements 1 place to the left
27+
for ( var i = 1; i < num; i++ ) {
28+
ax[i - 1] = ax[i];
29+
ay[i - 1] = ay[i];
30+
}
31+
32+
// Put a new value at the end of the array
33+
ax[num - 1] += random(-range, range);
34+
ay[num - 1] += random(-range, range);
35+
36+
// Constrain all points to the screen
37+
ax[num - 1] = constrain(ax[num - 1], 0, width);
38+
ay[num - 1] = constrain(ay[num - 1], 0, height);
39+
40+
// Draw a line connecting the points
41+
for ( var j = 1; j < num; j++ ) {
42+
var val = j / num * 204.0 + 51;
43+
stroke(val);
44+
line(ax[j - 1], ay[j - 1], ax[j], ay[j]);
45+
}
46+
}

0 commit comments

Comments
 (0)