Skip to content

Instantly share code, notes, and snippets.

@misterhay
Last active August 16, 2022 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterhay/99230efa6ab967a6fefb1dfe03e9efce to your computer and use it in GitHub Desktop.
Save misterhay/99230efa6ab967a6fefb1dfe03e9efce to your computer and use it in GitHub Desktop.
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 nbgitputllerUrl="https://hub.callysto.ca/jupyter/hub/user-redirect/git-pull?repo=";if(site=="github.com"){if(treeBlob){var subPath=url.substring(url.indexOf(branch)+branch.length+1);nbgitputllerUrl+=encodeURIComponent("https://github.com/"+user+"/")+repo+"&branch="+branch+"&subPath="+subPath+"&depth=1";}else{nbgitputllerUrl+=url;}}window.prompt("Callysto nbgitpuller link",nbgitputllerUrl);})();
@misterhay
Copy link
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 += encodeURIComponent("https://github.com/" + user + "/") + repo + "&branch=" + branch + "&urlpath=" + urlpath + "&depth=1;
}
else {nbgitpullerUrl += url;}
}

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

@misterhay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment