Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial draft of open in binder extension.
This is still really early prototype as it will not handle many case.
Though if you are in GitHub repository and press the Binder Logo in your
toolbar, it should open the current repository with MyBinder.org.

Nothing configurable, active on all pages, so plenty to be done.
  • Loading branch information
Carreau committed Nov 20, 2017
0 parents commit a4daaea
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
29 changes: 29 additions & 0 deletions LICENSE
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2017-Present Project Jupyter Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 changes: 73 additions & 0 deletions assets/binder_logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions content_scripts/binderify.js
@@ -0,0 +1,27 @@
(function() {
function handleClick(){
browser.tabs.query({active: true, currentWindow: true})
.then((tabs) => {return tabs[0]})
.then((tab) => {
let url = new URL(tab.url);
if (url.hostname != 'github.com'){
console.warn('Open in binder only works on GitHub repositories for now.');
return;
};
let parts = url.pathname.split('/');
if (parts.length < 3){
console.warn('While you are on GitHub, You do not appear to be in a github repository. Aborting.');
return;
}
let my_binder_url = 'https://mybinder.org/v2/gh/'+parts[1] +'/'+parts[2] +'/master';
console.info('Opening ' + url + 'using mybinder.org... enjoy !')
browser.tabs.create({'url':my_binder_url});
})

}
console.info('(Re) loading open-in-binder extension.');
browser.browserAction.onClicked.addListener(handleClick);

console.info('❤️ If you are reading this then you know about binder and javascript. ❤️');
console.info('❤️ So you\'re skilled enough to contribute ! We\'re waiting for you on https://github.com/jupyterhub/ ❤️');
})()
27 changes: 27 additions & 0 deletions manifest.json
@@ -0,0 +1,27 @@
{

"manifest_version": 2,
"name": "Open with MyBinder",
"version": "0.1",

"description": "Add a Binderify icon to the toolbar to launch current Github repository on Binder.",
"homepage_url": "https://github.com/",
"icons": {
"48": "binder_logo.svg"
},

"permissions": [
"activeTab"
],

"background": {
"scripts": ["content_scripts/binderify.js"]
},

"browser_action": {
"browser_style" : true,
"default_icon": "assets/binder_logo.svg",
"default_title": "Binderify"
}

}

0 comments on commit a4daaea

Please sign in to comment.