Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a link generator binder #49

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.strip() 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