Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascript bookmarklet to generate nbgitpuller links from GitHub repositories. Create a bookmark and replace the URL of the new bookmark with the code below.
javascript:(function(){var url=location.href;var res=url.split("/");var site=res[2];var user=res[3];var repo=res[4];var treeBlob=res[5];var branch=res[6];var nbgitpullerUrl="https://hub.callysto.ca/jupyter/hub/user-redirect/git-pull?repo=";if(site=="github.com"){if(treeBlob){var urlpath="notebooks/"+repo+url.substring(url.indexOf(branch)+branch.length);nbgitpullerUrl+="https://github.com/"+user+"/"+repo+"&branch="+branch+"&urlpath="+urlpath;}else{nbgitpullerUrl+=url;}}window.prompt("Callysto nbgitpuller link",nbgitpullerUrl);})();
@misterhay

This comment has been minimized.

Copy link
Owner Author

misterhay commented Sep 5, 2019

var url = location.href;
var res = url.split("/");
var site = res[2];
var user = res[3];
var repo = res[4];
var treeBlob = res[5];
var branch = res[6];
var nbgitpullerUrl = "https://hub.callysto.ca/jupyter/hub/user-redirect/git-pull?repo=";

if (site == "github.com") {
if (treeBlob) {
var urlpath = "notebooks/" + repo + url.substring(url.indexOf(branch)+branch.length);
nbgitpullerUrl += "https://github.com/" + user + "/" + repo + "&branch=" + branch + "&urlpath=" + urlpath;
}
else {nbgitpullerUrl += url;}
}

window.prompt("Callysto nbgitpuller link",nbgitpullerUrl);

@misterhay

This comment has been minimized.

Copy link
Owner Author

misterhay commented Oct 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.