From 9663810730d157cc14770207ee7b4e00b2db2790 Mon Sep 17 00:00:00 2001 From: Nils Lehmann Date: Thu, 1 Aug 2024 21:48:06 +0200 Subject: [PATCH 1/8] lightning launch button --- docs/conf.py | 1 + docs/content/launch.md | 16 ++++++++++++++++ src/sphinx_book_theme/header_buttons/launch.py | 17 +++++++++++++++++ .../static/images/logo_lightning_studio.svg | 3 +++ tests/sites/base/conf.py | 1 + tests/test_build/build__header-article.html | 10 ++++++++++ tests/test_build/test_header_launchbtns.html | 10 ++++++++++ 7 files changed, 58 insertions(+) create mode 100644 src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg diff --git a/docs/conf.py b/docs/conf.py index 7eafdb884..561da0917 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -113,6 +113,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 diff --git a/docs/content/launch.md b/docs/content/launch.md index 8c851c344..a83d5e5d4 100644 --- a/docs/content/launch.md +++ b/docs/content/launch.md @@ -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 [Ligthning Studio](https://lightning.ai) links to your page, add the following configuration: + + +```python +html_theme_options = { + ... + "launch_buttons": { + "lightning_studio_url": "https://lightning.ai" + }, + ... +} +``` + + ## Live code cells with Thebe diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index c00f92937..08ef14cba 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -116,6 +116,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: @@ -189,6 +190,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}" + 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( diff --git a/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg b/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg new file mode 100644 index 000000000..481762a96 --- /dev/null +++ b/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg @@ -0,0 +1,3 @@ + + + diff --git a/tests/sites/base/conf.py b/tests/sites/base/conf.py index 63f37fe83..0bcf1ec88 100644 --- a/tests/sites/base/conf.py +++ b/tests/sites/base/conf.py @@ -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, }, diff --git a/tests/test_build/build__header-article.html b/tests/test_build/build__header-article.html index 4ffce98c7..956bd04c0 100644 --- a/tests/test_build/build__header-article.html +++ b/tests/test_build/build__header-article.html @@ -57,6 +57,16 @@ +
  • + + + Lighting Studio logo + + + Lightning Studio + + +
  • +
  • + + + Lightning Studio logo + + + Lightning Studio + + +
  • - + Lighting Studio logo From c1c16965f8ebec9a84877a5b63f0effcd50b0460 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Fri, 22 Nov 2024 09:39:04 +0000 Subject: [PATCH 6/8] Update tests/test_build/test_header_launchbtns.html Co-authored-by: Adam J. Stewart --- tests/test_build/test_header_launchbtns.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_build/test_header_launchbtns.html b/tests/test_build/test_header_launchbtns.html index d86b9b326..4a29f4f32 100644 --- a/tests/test_build/test_header_launchbtns.html +++ b/tests/test_build/test_header_launchbtns.html @@ -45,7 +45,7 @@
  • - + Lightning Studio logo From c58865cec9beb1eea5ff8f6c7b6be25b3b4ed48f Mon Sep 17 00:00:00 2001 From: Nils Lehmann Date: Sun, 12 Jan 2025 12:49:50 +0100 Subject: [PATCH 7/8] studios plural --- docs/conf.py | 2 +- docs/content/launch.md | 6 +++--- src/sphinx_book_theme/header_buttons/launch.py | 12 ++++++------ ...ghtning_studio.svg => logo_lightning_studios.svg} | 0 tests/sites/base/conf.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename src/sphinx_book_theme/theme/sphinx_book_theme/static/images/{logo_lightning_studio.svg => logo_lightning_studios.svg} (100%) diff --git a/docs/conf.py b/docs/conf.py index 96502cf02..0ab727cd8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -114,7 +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/", + "lightning_studios_url": "https://lightning.ai/studios", "notebook_interface": "jupyterlab", "thebe": True, # "jupyterhub_url": "https://datahub.berkeley.edu", # For testing diff --git a/docs/content/launch.md b/docs/content/launch.md index aee537be6..66a69783c 100644 --- a/docs/content/launch.md +++ b/docs/content/launch.md @@ -85,16 +85,16 @@ html_theme_options = { This will create a new Deepnote project every time you click the launch button. ``` -## Lightning Studio +## Lightning Studios -To add [Lightning Studio](https://lightning.ai) links to your page, add the following configuration: +To add [Lightning Studios](https://lightning.ai/studios) links to your page, add the following configuration: ```python html_theme_options = { ... "launch_buttons": { - "lightning_studio_url": "https://lightning.ai" + "lightning_studios_url": "https://lightning.ai/studios" }, ... } diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index 3acb030e8..ea4961ab1 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -114,7 +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("/") + lightning_studios_url = launch_buttons.get("lightning_studios_url", "").strip("/") # Loop through each provider and add a button for it if needed if binderhub_url: @@ -188,18 +188,18 @@ def add_launch_buttons( } ) - if lightning_studio_url: + if lightning_studios_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}" - url = f"{lightning_studio_url}/new?repo_url=https://github.com{github_path}" + url = f"{lightning_studios_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", + "text": "Lightning Studios", + "tooltip": translation("Launch on") + " Lightning Studios", + "icon": "_static/images/logo_lightning_studios.svg", "url": url, } ) diff --git a/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg b/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studios.svg similarity index 100% rename from src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg rename to src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studios.svg diff --git a/tests/sites/base/conf.py b/tests/sites/base/conf.py index 0bcf1ec88..c92e4fad7 100644 --- a/tests/sites/base/conf.py +++ b/tests/sites/base/conf.py @@ -27,7 +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/", + "lightning_studios_url": "https://lightning.ai/studios", "notebook_interface": "jupyterlab", "thebe": True, }, From 7a841fb6bd66c8406e098dbabaed97760e754b67 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 11:50:04 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/sphinx_book_theme/header_buttons/launch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index ea4961ab1..8b9c61b13 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -193,7 +193,9 @@ def add_launch_buttons( 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}" - url = f"{lightning_studios_url}/new?repo_url=https://github.com{github_path}" + url = ( + f"{lightning_studios_url}/new?repo_url=https://github.com{github_path}" + ) launch_buttons_list.append( { "type": "link",