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

✨ NEW: Add Deepnote launch option for notebooks #385

Merged
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
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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
18 changes: 18 additions & 0 deletions docs/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ 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"
},
...
}
```
choldgraf marked this conversation as resolved.
Show resolved Hide resolved

```{warning}
This will create a new Deepnote project every time you click the launch button.
```


## Live code cells with Thebe

Expand Down
6 changes: 6 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,11 @@ def add_hub_urls(
url = f"{colab_url}/github/{org}/{repo}/blob/{branch}/{path_rel_repo}"
context["colab_url"] = url

if deepnote_url:
github_path = f"%2F{org}%2F{repo}%2Fblob%2F{branch}%2F{path_rel_repo}"
url = f"{deepnote_url}/launch?url=https%3A%2F%2Fgithub.com{github_path}"
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="deepnote-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
6 changes: 6 additions & 0 deletions tests/test_build/test_repo_custombranch.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
Colab
</button>
</a>
<a class="deepnote-button" href="https://deepnote.com/launch?url=https%3A%2F%2Fgithub.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Ffoo%2FTESTPATH/section1/ntbk.ipynb">
<button class="btn btn-secondary topbarbtn" data-placement="left" data-toggle="tooltip" title="Launch Deepnote" type="button">
<img alt="Interact in Deepnote" class="deepnote-button-logo" src="../_static/images/logo_deepnote.svg"/>
Deepnote
</button>
</a>
<button class="btn btn-secondary topbarbtn" data-placement="left" data-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe" type="button">
<i class="fas fa-play">
</i>
Expand Down
6 changes: 6 additions & 0 deletions tests/test_build/test_topbar_download_button_off.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
Colab
</button>
</a>
<a class="deepnote-button" href="https://deepnote.com/launch?url=https%3A%2F%2Fgithub.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Fmaster%2FTESTPATH/section1/ntbk.ipynb">
<button class="btn btn-secondary topbarbtn" data-placement="left" data-toggle="tooltip" title="Launch Deepnote" type="button">
<img alt="Interact in Deepnote" class="deepnote-button-logo" src="../_static/images/logo_deepnote.svg"/>
Deepnote
</button>
</a>
<button class="btn btn-secondary topbarbtn" data-placement="left" data-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe" type="button">
<i class="fas fa-play">
</i>
Expand Down
6 changes: 6 additions & 0 deletions tests/test_build/test_topbar_launchbtns.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
Colab
</button>
</a>
<a class="deepnote-button" href="https://deepnote.com/launch?url=https%3A%2F%2Fgithub.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Fmaster%2FTESTPATH/section1/ntbk.ipynb">
<button class="btn btn-secondary topbarbtn" data-placement="left" data-toggle="tooltip" title="Launch Deepnote" type="button">
<img alt="Interact in Deepnote" class="deepnote-button-logo" src="../_static/images/logo_deepnote.svg"/>
Deepnote
</button>
</a>
<button class="btn btn-secondary topbarbtn" data-placement="left" data-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe" type="button">
<i class="fas fa-play">
</i>
Expand Down