Skip to content

Commit

Permalink
✨ NEW: Add Deepnote launch option for notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubzitny committed Aug 24, 2021
1 parent a9f7415 commit e08298c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"binderhub_url": "https://mybinder.org",
# "jupyterhub_url": "https://datahub.berkeley.edu", # For testing
"colab_url": "https://colab.research.google.com/",
"deepnote_url": "https://deepnote.com/",
"notebook_interface": "jupyterlab",
"thebe": True,
},
Expand Down
13 changes: 13 additions & 0 deletions docs/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ html_theme_options = {
...
}
```
## Deepnote

To add [Deepnote](https://deepnote.com) links to your page, add the following configuration:

```python
html_theme_options = {
...
"launch_buttons": {
"deepnote_url": "https://deepnote.com"
},
...
}
```

## Live code cells with Thebe

Expand Down
5 changes: 5 additions & 0 deletions sphinx_book_theme/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def add_hub_urls(
jupyterhub_url = launch_buttons.get("jupyterhub_url")
binderhub_url = launch_buttons.get("binderhub_url")
colab_url = launch_buttons.get("colab_url")
deepnote_url = launch_buttons.get("deepnote_url")
if binderhub_url:
url = (
f"{binderhub_url}/v2/gh/{org}/{repo}/{branch}?"
Expand All @@ -113,6 +114,10 @@ def add_hub_urls(
url = f"{colab_url}/github/{org}/{repo}/blob/{branch}/{path_rel_repo}"
context["colab_url"] = url

if deepnote_url:
url = f"{deepnote_url}/launch?url=https%3A%2F%2Fgithub.com%2F{org}%2F{repo}%2Fblob%2F{branch}%2F{path_rel_repo}"
context["deepnote_url"] = url

# Add thebe flag in context
if launch_buttons.get("thebe", False):
context["use_thebe"] = True
Expand Down
1 change: 1 addition & 0 deletions sphinx_book_theme/static/images/logo_deepnote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion sphinx_book_theme/topbar/launchbuttons.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Launch buttons -->
{% if binder_url or jupyterhub_url or colab_url or use_thebe %}
{% if binder_url or jupyterhub_url or colab_url or deepnote_url or use_thebe %}
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn"
aria-label="Launch interactive content"><i class="fas fa-rocket"></i></button>
Expand All @@ -24,6 +24,12 @@
src="{{ pathto('_static/images/logo_colab.png', 1) }}"
alt="Interact on Colab">Colab</button></a>
{% endif %}
{% if deepnote_url and page_source_suffix==".ipynb" %}
<a class="colab-button" href="{{ deepnote_url }}"><button type="button" class="btn btn-secondary topbarbtn"
title="{{ translate('Launch') }} Deepnote" data-toggle="tooltip" data-placement="left"><img class="deepnote-button-logo"
src="{{ pathto('_static/images/logo_deepnote.svg', 1) }}"
alt="Interact in Deepnote">Deepnote</button></a>
{% endif %}
{% if use_thebe -%}
<button type="button" class="btn btn-secondary topbarbtn"
onclick="initThebeSBT()" title="{{ translate('Launch') }} Thebe" data-toggle="tooltip" data-placement="left"><i
Expand Down
1 change: 1 addition & 0 deletions tests/sites/base/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"binderhub_url": "https://mybinder.org",
"jupyterhub_url": "https://datahub.berkeley.edu",
"colab_url": "https://colab.research.google.com",
"deepnote_url": "https://deepnote.com",
"notebook_interface": "jupyterlab",
"thebe": True,
},
Expand Down

0 comments on commit e08298c

Please sign in to comment.