Skip to content
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"binderhub_url": "https://mybinder.org",
"colab_url": "https://colab.research.google.com/",
"deepnote_url": "https://deepnote.com/",
"lightning_studio_url": "https://lightning.ai/",
"notebook_interface": "jupyterlab",
"thebe": True,
# "jupyterhub_url": "https://datahub.berkeley.edu", # For testing
Expand Down
16 changes: 16 additions & 0 deletions docs/content/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ html_theme_options = {
This will create a new Deepnote project every time you click the launch button.
```

## Lightning Studio

To add [Lightning Studio](https://lightning.ai) links to your page, add the following configuration:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use https://lightning.ai/studios and call it Lightning Studios (plural) consistently throughout.



```python
html_theme_options = {
...
"launch_buttons": {
"lightning_studio_url": "https://lightning.ai"
},
...
}
```



## Live code cells with Thebe

Expand Down
17 changes: 17 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(
binderhub_url = launch_buttons.get("binderhub_url", "").strip("/")
colab_url = launch_buttons.get("colab_url", "").strip("/")
deepnote_url = launch_buttons.get("deepnote_url", "").strip("/")
lightning_studio_url = launch_buttons.get("lightning_studio_url", "").strip("/")

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

if lightning_studio_url:
if provider.lower() != "github":
SPHINX_LOGGER.warning(f"Provider {provider} not supported on Lightning.")
else:
github_path = f"%2F{org}%2F{repo}%2Fblob%2F{branch}%2F{path_rel_repo}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably need to URL escape these.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agoose77 is the latest commit what you were looking for? At least the tests seem to pass again. Let me know if I need to change something else.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nilsleh not quite -- I'm worried about the case where org, repo, branch, or path_rel_repo aren't URL escaped properly.

Equally, it's something that the other launchers would need to worry about, so I'll just merge for now!

url = f"{lightning_studio_url}/new?repo_url=https://github.com{github_path}"
launch_buttons_list.append(
{
"type": "link",
"text": "Lightning Studio",
"tooltip": translation("Launch on") + " Lightning Studio",
"icon": "_static/images/logo_lightning_studio.svg",
"url": url,
}
)

# Add thebe flag in context
if launch_buttons.get("thebe", False):
launch_buttons_list.append(
Expand Down
Loading
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",
"lightning_studio_url": "https://lightning.ai/",
"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://lightning.ai/new?repo_url=https%3A%2F%2Fgithub.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Fmaster%2FTESTPATH/section1/ntbk.ipynb" target="_blank" title="Launch on Lightning Studio">
<span class="btn__icon-container">
<img alt="Lighting Studio logo" src="../_static/images/logo_lightning_studio.svg"/>
</span>
<span class="btn__text-container">
Lightning Studio
</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://lightning.ai/new?repo_url=https%3A%2F%2Fgithub.com%2Fexecutablebooks%2Fsphinx-book-theme%2Fblob%2Fmaster%2FTESTPATH/section1/ntbk.ipynb" target="_blank" title="Launch on Lightning Studio">
<span class="btn__icon-container">
<img alt="Lightning Studio logo" src="../_static/images/logo_lightning_studio.svg"/>
</span>
<span class="btn__text-container">
Lightning Studio
</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
Loading