Skip to content

Commit

Permalink
adding a link generator binder
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Jul 22, 2018
1 parent 01547d5 commit 38aa6bd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# nbgitpuller

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/data-8/nbgitpuller/master?urlpath=apps/binder%2Flink_generator.ipynb)

One-way synchronization of a remote git repository to a local git repository,
with automatic conflict resolution.

Expand Down Expand Up @@ -61,6 +63,9 @@ You should *not* use this when:

# Constructing the nbgitpuller URL

Launch this Binder for an interactive link generator
[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/data-8/nbgitpuller/master?urlpath=apps/binder%2Flink_generator.ipynb)

You can construct a working nbgitpuller URL like this:

```
Expand Down
62 changes: 62 additions & 0 deletions binder/link_generator.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Generate `nbgitpuller` links for your JupyterHub\n",
"\n",
"Below is an interactive widget that lets you compose interact links\n",
"with `nbgitpuller`. In the form below, input your JupyterHub\n",
"URL as well as the repository\n",
"URL and information for the content you wish to share, and your interact\n",
"link will be printed below."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import interact\n",
"\n",
"@interact\n",
"def make_nbgitpuller_link(hub_url='', repo_url='', branch='', subPath='', app=''):\n",
" \"\"\"Generate an ipywidget form that creates an interact link.\"\"\"\n",
" hub_url = hub_url.strip()\n",
" kwargs = {}\n",
" for name, val in [('repo', repo_url), ('branch', branch), ('subPath', subPath), ('app', app)]:\n",
" if len(val) > 1:\n",
" kwargs[name] = val.strip()\n",
" params = f'&'.join(['{}={}'.format(nm, val) for nm, val in kwargs.items()])\n",
" url = f'{hub_url}/hub/user-redirect/git-pull?{params}'\n",
" if len(app) > 0 and app not in ['notebook', 'lab']:\n",
" print('app must be one of [\"notebook\", \"lab\"]')\n",
" elif (len(hub_url) > 0) and (len(repo_url) > 0):\n",
" print(url)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
3 changes: 3 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
jupyter nbextension enable --py --sys-prefix appmode
jupyter serverextension enable --py --sys-prefix appmode
2 changes: 2 additions & 0 deletions binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ipywidgets
appmode

0 comments on commit 38aa6bd

Please sign in to comment.