diff --git a/beetleblocks/beetleblocks/beetlecloud.js b/beetleblocks/beetleblocks/beetlecloud.js
index 04033858..30c2de7c 100644
--- a/beetleblocks/beetleblocks/beetlecloud.js
+++ b/beetleblocks/beetleblocks/beetlecloud.js
@@ -113,7 +113,7 @@ BeetleCloud.prototype.post = function (path, body, callBack, errorCall, errorMsg
};
BeetleCloud.prototype.getCurrentUser = function (callback, errorCallback) {
- this.get('/user', callback, errorCallback, 'Could not retrieve current user');
+ callback.call(null, {username:"user"});
};
BeetleCloud.prototype.checkCredentials = function (callback, errorCallback) {
@@ -170,9 +170,33 @@ BeetleCloud.prototype.saveProject = function (ide, callBack, errorCall) {
}
ide.showMessage('Uploading project...');
-
+ var data = {};
+ data.contents = pdata;
+ data.id = 0;
+ data.ispublic = false;
+ data.notes = ide.projectNotes;
+ data.projectname = ide.projectName;
+ var n = pdata.indexOf("")+11;
+ var m = pdata.indexOf("");
+ data.thumbnail = pdata.substr(n, m-n);
+ console.log(data.thumbnail);
+ var today = new Date();
+ var dd = today.getDate(), mm = today.getMonth()+1, yyyy = today.getFullYear();
+ if(dd<10)
+ dd = '0'+dd
+ if(mm<10)
+ mm = '0'+mm
+ data.updated = yyyy+'-'+mm+'-'+dd+' '+today.getHours()+':'+today.getMinutes()+':'+today.getSeconds();
+ data.user = myself.username
+ data = JSON.stringify(data);
+ saveDataToCloud(data, ide.projectName, "beetleblocks");
+ callBack.call(
+ null,
+ "project "+ide.projectName+" updated",
+ 'BeetleCloud'
+ );
//(path, body, callBack, errorCall, errorMsg)
- myself.post(
+ /*myself.post(
'/projects/save?projectname='
+ encodeURIComponent(ide.projectName)
+ '&username='
@@ -182,7 +206,7 @@ BeetleCloud.prototype.saveProject = function (ide, callBack, errorCall) {
callBack,
errorCall,
'Project could not be saved' // error message
- )
+ )*/
} else {
errorCall.call(this, 'You are not logged in', 'BeetleCloud');
@@ -270,7 +294,30 @@ BeetleCloud.prototype.getProjectList = function (callBack, errorCall) {
errorCall.call(this, 'You are not logged in', 'BeetleCloud');
return;
} else {
- myself.get(
+ var response = getAllCloudFilesJSON();
+ var tmp = {}, res = Array();
+ var i = 0;
+ if (Object.keys(response.DATA).length > 0) {
+ response.DATA.forEach(function(eachProject) {
+ if(eachProject.TOOLID == 21){
+ var data = JSON.parse(eachProject.FILE_PATH);
+ // This looks absurd, but PostgreSQL doesn't respect case
+ tmp.Public = data.ispublic ? 'true' : 'false'; // compatibility with old cloud
+ tmp.ProjectName = data.projectname;
+ tmp.Thumbnail = data.thumbnail;
+ tmp.Updated = data.updated;
+ tmp.Notes = data.notes;
+ tmp.Data = data.contents;
+ tmp.ProjectId = eachProject.ID;
+ res[i] = tmp;
+ i++;
+ }
+ });
+ callBack.call(null, res);
+ } else {
+ callBack.call(null, []);
+ }
+ /*myself.get(
'/users/'
+ encodeURIComponent(myself.username)
+ '/projects',
@@ -291,7 +338,7 @@ BeetleCloud.prototype.getProjectList = function (callBack, errorCall) {
},
errorCall,
'Could not fetch project list'
- );
+ );*/
}
},
errorCall
diff --git a/beetleblocks/beetleblocks/examples/EXAMPLES b/beetleblocks/beetleblocks/examples/EXAMPLES
new file mode 100644
index 00000000..db50f7ca
--- /dev/null
+++ b/beetleblocks/beetleblocks/examples/EXAMPLES
@@ -0,0 +1,21 @@
+artichoke lamp.xml artichoke lamp
+beetle.xml beetle
+bracelet.xml bracelet
+CDG.xml CDG
+chair.xml chair
+disco ball.xml disco ball
+geometry tool blocks.xml geometry tool blocks
+horns.xml horns
+nautilus.xml nautilus
+orthogonal tree.xml orthogonal tree
+pine tree.xml pine tree
+random walk sphere.xml random walk sphere
+recursive cubes.xml recursive cubes
+shell.xml shell
+simple code examples.xml simple code examples
+snail.xml snail
+spiral basket.xml spiral basket
+torus knot.xml torus knot
+tower.xml tower
+Tutorial 1.xml Tutorial 1
+wave surface.xml wave surface
\ No newline at end of file
diff --git a/beetleblocks/beetleblocks/gui.js b/beetleblocks/beetleblocks/gui.js
index 211daf93..d70c39ac 100644
--- a/beetleblocks/beetleblocks/gui.js
+++ b/beetleblocks/beetleblocks/gui.js
@@ -106,13 +106,14 @@ IDE_Morph.prototype.projectMenu = function () {
if (SnapCloud.username) {
menu.addLine();
- menu.addItem('My Profile', function () { window.open('/users/' + SnapCloud.username, true) });
- menu.addItem('My Projects', function () { window.open('/myprojects', true) });
+ menu.addItem('Load from cloud', 'openProjectsBrowser');
+ //menu.addItem('My Profile', function () { window.open('/users/' + SnapCloud.username, true) });
+ //menu.addItem('Load from cloud', function () { window.open('/myprojects', true) });
}
- menu.addItem(
+ /*menu.addItem(
'Migrate from the old cloud',
function () { window.open('/migration', true) },
- 'Attempt to perform an automatic\nmigration of all your projects\nin the old cloud');
+ 'Attempt to perform an automatic\nmigration of all your projects\nin the old cloud');*/
menu.addLine();
menu.addItem('Save Ctrl+S', 'save');
@@ -187,7 +188,7 @@ IDE_Morph.prototype.projectMenu = function () {
);
menu.addLine();
}
- if (!SnapCloud.username) {
+ /*if (!SnapCloud.username) {
menu.addItem(
'Login',
function () { window.open('/login'); }
@@ -205,7 +206,7 @@ IDE_Morph.prototype.projectMenu = function () {
localize('Logout') + ' / ' + SnapCloud.username,
'logout'
);
- }
+ }*/
menu.addItem(
'Start tutorial',
function () {
@@ -371,7 +372,12 @@ ProjectDialogMorph.prototype.deleteProject = function () {
) + '\n"' + proj.ProjectName + '"?',
'Delete Project',
function () {
- SnapCloud.deleteProject(
+ removeFile(proj.ProjectId);
+ myself.ide.hasChangedMedia = true;
+ idx = myself.projectList.indexOf(proj);
+ myself.projectList.splice(idx, 1);
+ myself.installCloudProjectList(myself.projectList);
+ /*SnapCloud.deleteProject(
proj.ProjectName,
function () {
myself.ide.hasChangedMedia = true;
@@ -382,7 +388,7 @@ ProjectDialogMorph.prototype.deleteProject = function () {
function (err, lbl) {
myself.ide.cloudError().call(null, err, lbl);
}
- );
+ );*/
}
);
}
@@ -422,8 +428,8 @@ ProjectDialogMorph.prototype.shareProject = function () {
proj.ProjectName,
function () {
proj.Public = 'true';
- myself.unshareButton.show();
- myself.shareButton.hide();
+ //myself.unshareButton.show();
+ //myself.shareButton.hide();
entry.label.isBold = true;
entry.label.drawNew();
entry.label.changed();
@@ -466,8 +472,8 @@ ProjectDialogMorph.prototype.unshareProject = function () {
proj.ProjectName,
function () {
proj.Public = 'false';
- myself.shareButton.show();
- myself.unshareButton.hide();
+ //myself.shareButton.show();
+ //myself.unshareButton.hide();
entry.label.isBold = false;
entry.label.drawNew();
entry.label.changed();
@@ -994,12 +1000,21 @@ IDE_Morph.prototype.setStageExtent = function (ext) {
this.stage.reRender();
};
+IDE_Morph.prototype.resourceURL = function () {
+ // Take in variadic inputs that represent an a nested folder structure.
+ // Method can be easily overridden if running in a custom location.
+ // Default Snap! simply returns a path (relative to snap.html)
+ var args = Array.prototype.slice.call(arguments, 0);
+ return args.join('/');
+};
+
// Examples now pulls from local
ProjectDialogMorph.prototype.getExamplesProjectList = function () {
- var dir,
+ return this.ide.getMediaList('beetleblocks/examples/EXAMPLES');
+ /*var dir,
projects = [];
- dir = JSON.parse(this.ide.getURL('https://api.github.com/repos/ericrosenbaum/BeetleBlocks/contents/run/beetleblocks/examples'));
+ dir = JSON.parse(this.ide.getURL('./examples'));
dir.forEach(function (each){
var dta = {
name: each.name.replace('.xml',''),
@@ -1012,7 +1027,7 @@ ProjectDialogMorph.prototype.getExamplesProjectList = function () {
projects.sort(function (x, y) {
return x.name < y.name ? -1 : 1;
});
- return projects;
+ return projects;*/
};
ProjectDialogMorph.prototype.setSource = function (source) {
@@ -1115,8 +1130,8 @@ ProjectDialogMorph.prototype.setSource = function (source) {
};
}
this.body.add(this.listField);
- this.shareButton.hide();
- this.unshareButton.hide();
+ //this.shareButton.hide();
+ //this.unshareButton.hide();
if (this.source === 'local') {
this.deleteButton.show();
} else { // examples
@@ -1173,6 +1188,9 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
ProjectDialogMorph.prototype.rawOpenCloudProject = function (proj) {
var myself = this;
+ myself.ide.source = 'cloud';
+ myself.ide.droppedText(proj.Data);
+ /*
SnapCloud.reconnect(
function () {
SnapCloud.callService(
@@ -1200,7 +1218,7 @@ ProjectDialogMorph.prototype.rawOpenCloudProject = function (proj) {
);
},
myself.ide.cloudError()
- );
+ );*/
this.destroy();
};
diff --git a/beetleblocks/gui.js b/beetleblocks/gui.js
index ff00b2f5..7d8207ef 100644
--- a/beetleblocks/gui.js
+++ b/beetleblocks/gui.js
@@ -2278,7 +2278,7 @@ IDE_Morph.prototype.cloudMenu = function () {
'Reset Password...',
'resetCloudPassword'
);
- } else {
+ }/* else {
menu.addItem(
localize('Logout') + ' ' + SnapCloud.username,
'logout'
@@ -2287,7 +2287,7 @@ IDE_Morph.prototype.cloudMenu = function () {
'Change Password...',
'changeCloudPassword'
);
- }
+ }*/
if (shiftClicked) {
menu.addLine();
menu.addItem(
@@ -2970,7 +2970,7 @@ IDE_Morph.prototype.getMediaList = function (dirname, callback) {
// based on the contents file.
// If no callback is specified, synchronously return the list of files
// Note: Synchronous fetching has been deprecated and should be switched
- var url = this.resourceURL(dirname, dirname.toUpperCase()),
+ var url = dirname,//this.resourceURL(dirname, dirname.toUpperCase()),
async = callback instanceof Function,
myself = this,
data;
@@ -3015,6 +3015,7 @@ IDE_Morph.prototype.parseResourceFile = function (text) {
items.push({
fileName: parts[0],
name: parts[1],
+ path: "beetleblocks/examples/"+parts[0],
description: parts.length > 2 ? parts[2] : ''
});
});
@@ -5340,8 +5341,8 @@ ProjectDialogMorph.prototype.init = function (ide, task) {
this.notesText = null;
this.notesField = null;
this.deleteButton = null;
- this.shareButton = null;
- this.unshareButton = null;
+ //this.shareButton = null;
+ //this.unshareButton = null;
// initialize inherited properties:
ProjectDialogMorph.uber.init.call(
@@ -5389,7 +5390,7 @@ ProjectDialogMorph.prototype.buildContents = function () {
}
this.addSourceButton('cloud', localize('Cloud'), 'cloud');
- this.addSourceButton('local', localize('Browser'), 'storage');
+ //this.addSourceButton('local', localize('Browser'), 'storage');
if (this.task === 'open') {
this.buildFilterField();
this.addSourceButton('examples', localize('Examples'), 'poster');
@@ -5482,10 +5483,10 @@ ProjectDialogMorph.prototype.buildContents = function () {
this.addButton('saveProject', 'Save');
this.action = 'saveProject';
}
- this.shareButton = this.addButton('shareProject', 'Share');
- this.unshareButton = this.addButton('unshareProject', 'Unshare');
- this.shareButton.hide();
- this.unshareButton.hide();
+ //this.shareButton = this.addButton('shareProject', 'Share');
+ //this.unshareButton = this.addButton('unshareProject', 'Unshare');
+ //this.shareButton.hide();
+ //this.unshareButton.hide();
this.deleteButton = this.addButton('deleteProject', 'Delete');
this.addButton('cancel', 'Cancel');
@@ -5768,8 +5769,8 @@ ProjectDialogMorph.prototype.setSource = function (source) {
};
}
this.body.add(this.listField);
- this.shareButton.hide();
- this.unshareButton.hide();
+ //this.shareButton.hide();
+ //this.unshareButton.hide();
if (this.source === 'local') {
this.deleteButton.show();
} else { // examples
@@ -5863,20 +5864,20 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) {
myself.preview.rightCenter().add(new Point(2, 0))
);
}
- if (item.Public === 'true') {
+ /*if (item.Public === 'true') {
myself.shareButton.hide();
myself.unshareButton.show();
} else {
myself.unshareButton.hide();
myself.shareButton.show();
- }
+ }*/
myself.buttons.fixLayout();
myself.fixLayout();
myself.edit();
};
this.body.add(this.listField);
- this.shareButton.show();
- this.unshareButton.hide();
+ //this.shareButton.show();
+ //this.unshareButton.hide();
this.deleteButton.show();
this.buttons.fixLayout();
this.fixLayout();
diff --git a/beetleblocks/index.html b/beetleblocks/index.html
index b7e11fcd..5d0bc83a 100644
--- a/beetleblocks/index.html
+++ b/beetleblocks/index.html
@@ -53,6 +53,14 @@
+
+
+
+
+
+
+
+