Skip to content

Commit 1eb93c2

Browse files
committed
Add basthon launch button
1 parent 9ed62f5 commit 1eb93c2

File tree

7 files changed

+116
-0
lines changed

7 files changed

+116
-0
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"binderhub_url": "https://mybinder.org",
112112
"colab_url": "https://colab.research.google.com/",
113113
"deepnote_url": "https://deepnote.com/",
114+
"basthon_url": "https://notebook.basthon.fr/",
114115
"notebook_interface": "jupyterlab",
115116
"thebe": True,
116117
# "jupyterhub_url": "https://datahub.berkeley.edu", # For testing

docs/launch.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ html_theme_options = {
6767
...
6868
}
6969
```
70+
7071
## Deepnote
7172

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

89+
## Basthon
90+
91+
To add Basthon links to your page, add the following configuration:
92+
93+
```python
94+
html_theme_options = {
95+
...
96+
"launch_buttons": {
97+
"basthon_url": "https://notebook.basthon.fr"
98+
},
99+
...
100+
}
101+
```
102+
103+
```{tip}
104+
By default, a Python kernel is used. You can add "/sql" or "/ocaml" to basthon_url to run a notebook with another language.
105+
```
88106

89107
## Live code cells with Thebe
90108

src/sphinx_book_theme/header_buttons/launch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def add_launch_buttons(
102102
jupyterhub_url = launch_buttons.get("jupyterhub_url", "").strip("/")
103103
binderhub_url = launch_buttons.get("binderhub_url", "").strip("/")
104104
colab_url = launch_buttons.get("colab_url", "").strip("/")
105+
basthon_url = launch_buttons.get("basthon_url", "").strip("/")
105106
deepnote_url = launch_buttons.get("deepnote_url", "").strip("/")
106107
if binderhub_url:
107108
url = (
@@ -161,6 +162,19 @@ def add_launch_buttons(
161162
}
162163
)
163164

165+
if basthon_url:
166+
gh = "https://raw.githubusercontent.com"
167+
url = f"{basthon_url}/?from={gh}/{org}/{repo}/{branch}/{path_rel_repo}"
168+
launch_buttons_list.append(
169+
{
170+
"type": "link",
171+
"text": "Basthon",
172+
"tooltip": "Launch on Basthon",
173+
"icon": "_static/images/logo_basthon.svg",
174+
"url": url,
175+
}
176+
)
177+
164178
# Add thebe flag in context
165179
if launch_buttons.get("thebe", False):
166180
launch_buttons_list.append(

src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_basthon.svg

Lines changed: 62 additions & 0 deletions
Loading

tests/sites/base/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"jupyterhub_url": "https://datahub.berkeley.edu",
2828
"colab_url": "https://colab.research.google.com",
2929
"deepnote_url": "https://deepnote.com",
30+
"basthon_url": "https://notebook.basthon.fr",
3031
"notebook_interface": "jupyterlab",
3132
"thebe": True,
3233
},

tests/test_build/build__header-article.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
</span>
5757
</a>
5858
</li>
59+
<li>
60+
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://notebook.basthon.fr/?from=https://raw.githubusercontent.com/executablebooks/sphinx-book-theme/master/TESTPATH/section1/ntbk.ipynb" title="Launch on Basthon">
61+
<span class="headerbtn__icon-container">
62+
<img src="../_static/images/logo_basthon.svg"/>
63+
</span>
64+
<span class="headerbtn__text-container">
65+
Basthon
66+
</span>
67+
</a>
68+
</li>
5969
<li>
6070
<button class="headerbtn headerbtn-launch-thebe" data-placement="left" data-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe">
6171
<span class="headerbtn__icon-container">

tests/test_build/test_header_launchbtns.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
</span>
4646
</a>
4747
</li>
48+
<li>
49+
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://notebook.basthon.fr/?from=https://raw.githubusercontent.com/executablebooks/sphinx-book-theme/master/TESTPATH/section1/ntbk.ipynb" title="Launch on Basthon">
50+
<span class="headerbtn__icon-container">
51+
<img src="../_static/images/logo_basthon.svg"/>
52+
</span>
53+
<span class="headerbtn__text-container">
54+
Basthon
55+
</span>
56+
</a>
57+
</li>
4858
<li>
4959
<button class="headerbtn headerbtn-launch-thebe" data-placement="left" data-toggle="tooltip" onclick="initThebeSBT()" title="Launch Thebe">
5060
<span class="headerbtn__icon-container">

0 commit comments

Comments
 (0)