Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub integration #1478

Closed
wants to merge 34 commits into from
Closed

GitHub integration #1478

wants to merge 34 commits into from

Conversation

wcyuan
Copy link

@wcyuan wcyuan commented Oct 27, 2016

This is more like a request for comment than a pull request. This change adds Github as a new source for loading and saving snap projects. It doesn't really make sense as is, since it's not suitable for beginners, but maybe it could become a hidden advanced feature. Currently, this change doesn't really tap into the power of git (no way to see or access past revisions, or branches or anything). It also only handles regular passwords (not two factor auth). With this level of auth, the file size limit is only 1 MB.

thanks,
Conan

wcyuan and others added 30 commits September 23, 2016 10:13
start to build the github button into the gui
start to implement getting the projects
Todo:
- having the user set the username/password
- save (not save as)
in particular, fix the edit function on the promptCredentials dialog
so that it doesn't try to edit the usr component, which doesn't
exist for 'github save as'
required moving github save functions from the dialog object to the
ide object in gui.js.
also remove the share and delete buttons for github
(at least until delete is implemented)
update todo list
currently, the path is like a property of the repo.
it would be better if the open/save dialog let you
traverse the repo like a normal file choosing dialog
but this is a start
but double-click on directories doesn't work...
Previously, double clicking on a directory would close the
window, now it opens the directory.

Previously, switching to github and then to local source,
the change repo button would still be there for local.  Now
it isn't, but the alignment is still screwy.

Update todo list
Strip ".xml" from project names when getting the project list from
Github.

Add comments and clean up github.js
@dekrain
Copy link
Contributor

dekrain commented Oct 27, 2016

WOW !!

@jmoenig
Copy link
Owner

jmoenig commented Oct 27, 2016

Interesting! Another idea would be to start with generic local git integration, as other IDEs do...

@wcyuan
Copy link
Author

wcyuan commented Oct 27, 2016

Another idea would be to start with generic local git integration,

Yes, that would be better in many ways, since it would work with any git setup not just Github. I like going directly to the cloud for students who may be on shared computers, but that might not matter since git is already not for beginners.

By the way, if you want to try it out, you can use wcyuan.github.io/snap-github

@brianharvey
Copy link
Collaborator

Imho our users would be much more interested in Google Drive integration, and then in second place Dropbox.

@dekrain
Copy link
Contributor

dekrain commented Oct 27, 2016

For JSON messages try to use:

var json = JSON.parse(xhr.responseText);
function jsonblock(blocks){
var block = new ReporterBlockMorph();
block.setSpec('JSON { %c }');
block.category = 'control';
(new ScriptsMorph()).add(block);
var curr;
if (blocks.length >= 1) {
 block.replaceInput(block.inputs()[0], (curr = blocks[0]));
 blocks.slice(1).forEach(function(blck){
  curr.nextBlock(blck));
  curr = blck;
 });
}
block.drawNew();
return block;
}
function fieldblock(name, value){
var block = new CommandBlockMorph();
block.setSpec('%s : %s');
block.category = 'operators';
(new ScriptsMorph()).add(block);
block.inputs()[0].setContents(name);
if (value && value instanceof ReporterBlockMorph) {
block.replaceInput(block.inputs()[1], value);
} else {
block.inputs()[1].setContents(value);
}
block.drawNew();
return block;
}
function json_to_blocks(data) {
var blcks = [];
for (var k in data) {
 var v = data[v];
 blcks.push(
  fieldblock(
   k, (v && typeof v === 'object') ? json_to_blocks(v) : v
  );
 );
}
return jsonblock(blcks);
}

// Show the block

For example:

(JSON {
[message] : [YAY!!]
[code]: [200]
[_meta]: (JSON {
[url]: [http://...]
})
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants