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

Add basthon launch button #595

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 @@ -113,6 +113,7 @@
"binderhub_url": "https://mybinder.org",
"colab_url": "https://colab.research.google.com/",
"deepnote_url": "https://deepnote.com/",
"basthon_url": "https://notebook.basthon.fr/",
"notebook_interface": "jupyterlab",
"thebe": True,
# "jupyterhub_url": "https://datahub.berkeley.edu", # For testing
Expand Down
18 changes: 18 additions & 0 deletions docs/content/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ html_theme_options = {
...
}
```

## Deepnote

To add [Deepnote](https://deepnote.com) links to your page, add the following configuration:
Expand All @@ -85,6 +86,23 @@ html_theme_options = {
This will create a new Deepnote project every time you click the launch button.
```

## Basthon

To add [Basthon](https://basthon.fr/) links to your page, add the following configuration:

```python
html_theme_options = {
...
"launch_buttons": {
"basthon_url": "https://notebook.basthon.fr"
},
...
}
```

```{tip}
By default, a Python kernel is used. You can add "/sql" or "/ocaml" to basthon_url to run a notebook with another language.
```

## Live code cells with Thebe

Expand Down
14 changes: 14 additions & 0 deletions src/sphinx_book_theme/header_buttons/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def add_launch_buttons(
jupyterhub_url = launch_buttons.get("jupyterhub_url", "").strip("/")
binderhub_url = launch_buttons.get("binderhub_url", "").strip("/")
colab_url = launch_buttons.get("colab_url", "").strip("/")
basthon_url = launch_buttons.get("basthon_url", "").strip("/")
deepnote_url = launch_buttons.get("deepnote_url", "").strip("/")

# Loop through each provider and add a button for it if needed
Expand Down Expand Up @@ -188,6 +189,19 @@ def add_launch_buttons(
}
)

if basthon_url:
gh = "https://raw.githubusercontent.com"
url = f"{basthon_url}/?from={gh}/{org}/{repo}/{branch}/{path_rel_repo}"
launch_buttons_list.append(
{
"type": "link",
"text": "Basthon",
"tooltip": "Launch on Basthon",
"icon": "_static/images/logo_basthon.png",
"url": url,
}
)

# Add thebe flag in context
if launch_buttons.get("thebe", False):
launch_buttons_list.append(
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/sites/base/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"jupyterhub_url": "https://datahub.berkeley.edu",
"colab_url": "https://colab.research.google.com",
"deepnote_url": "https://deepnote.com",
"basthon_url": "https://notebook.basthon.fr",
"notebook_interface": "jupyterlab",
"thebe": True,
},
Expand Down
10 changes: 10 additions & 0 deletions tests/test_build/build__header-article.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
</span>
</a>
</li>
<li>
<a class="btn btn-sm dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" href="https://notebook.basthon.fr/?from=https://raw.githubusercontent.com/executablebooks/sphinx-book-theme/master/TESTPATH/section1/ntbk.ipynb" target="_blank" title="Launch on Basthon">
<span class="btn__icon-container">
<img src="../_static/images/logo_basthon.png"/>
</span>
<span class="btn__text-container">
Basthon
</span>
</a>
</li>
<li>
<button class="btn btn-sm btn-launch-thebe dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe">
<span class="btn__icon-container">
Expand Down
10 changes: 10 additions & 0 deletions tests/test_build/test_header_launchbtns.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
</span>
</a>
</li>
<li>
<a class="btn btn-sm dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" href="https://notebook.basthon.fr/?from=https://raw.githubusercontent.com/executablebooks/sphinx-book-theme/master/TESTPATH/section1/ntbk.ipynb" target="_blank" title="Launch on Basthon">
<span class="btn__icon-container">
<img src="../_static/images/logo_basthon.png"/>
</span>
<span class="btn__text-container">
Basthon
</span>
</a>
</li>
<li>
<button class="btn btn-sm btn-launch-thebe dropdown-item" data-bs-placement="left" data-bs-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe">
<span class="btn__icon-container">
Expand Down