Last active
August 16, 2022 17:16
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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);})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);