From db0c15c3e564197d5ce01cb594442e24fff9051a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BDitn=C3=BD?= Date: Tue, 24 Aug 2021 13:54:14 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20NEW:=20Add=20Deepnote=20launch=20op?= =?UTF-8?q?tion=20for=20notebooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/conf.py | 1 + docs/launch.md | 13 +++++++++++++ sphinx_book_theme/launch.py | 6 ++++++ sphinx_book_theme/static/images/logo_deepnote.svg | 1 + sphinx_book_theme/topbar/launchbuttons.html | 8 +++++++- tests/sites/base/conf.py | 1 + 6 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 sphinx_book_theme/static/images/logo_deepnote.svg diff --git a/docs/conf.py b/docs/conf.py index 4817e87fc..ed64cd8ac 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -107,6 +107,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, }, diff --git a/docs/launch.md b/docs/launch.md index 969950dba..54dd2e4f3 100644 --- a/docs/launch.md +++ b/docs/launch.md @@ -67,6 +67,19 @@ 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" + }, + ... +} +``` ## Live code cells with Thebe diff --git a/sphinx_book_theme/launch.py b/sphinx_book_theme/launch.py index 86da74658..65237f91b 100644 --- a/sphinx_book_theme/launch.py +++ b/sphinx_book_theme/launch.py @@ -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}?" @@ -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 diff --git a/sphinx_book_theme/static/images/logo_deepnote.svg b/sphinx_book_theme/static/images/logo_deepnote.svg new file mode 100644 index 000000000..2c364d274 --- /dev/null +++ b/sphinx_book_theme/static/images/logo_deepnote.svg @@ -0,0 +1 @@ + diff --git a/sphinx_book_theme/topbar/launchbuttons.html b/sphinx_book_theme/topbar/launchbuttons.html index 9d635a524..8f4c1ae5a 100644 --- a/sphinx_book_theme/topbar/launchbuttons.html +++ b/sphinx_book_theme/topbar/launchbuttons.html @@ -1,5 +1,5 @@ -{% 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 %}