Skip to content

Commit

Permalink
FIX: Escape colon in JupyterHub link to repo (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-brett authored May 2, 2022
1 parent c4755c7 commit 5721a63
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/sphinx_book_theme/header_buttons/launch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from typing import Any, Dict, Optional
from urllib.parse import urlencode

from docutils.nodes import document
from sphinx.application import Sphinx
Expand Down Expand Up @@ -118,10 +119,13 @@ def add_launch_buttons(
)

if jupyterhub_url:
url = (
f"{jupyterhub_url}/hub/user-redirect/git-pull?"
f"repo={repo_url}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}"
url_params = urlencode(
dict(
repo=repo_url, urlpath=f"{ui_pre}/{repo}/{path_rel_repo}", branch=branch
),
safe="/",
)
url = f"{jupyterhub_url}/hub/user-redirect/git-pull?{url_params}"
launch_buttons_list.append(
{
"type": "link",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_build/build__header-article.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</a>
</li>
<li>
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https://github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A//github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
<span class="headerbtn__icon-container">
<img src="../_static/images/logo_jupyterhub.svg"/>
</span>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_build/test_header_launchbtns.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</a>
</li>
<li>
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https://github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A//github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
<span class="headerbtn__icon-container">
<img src="../_static/images/logo_jupyterhub.svg"/>
</span>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_build/test_topbar_launchbtns.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</a>
</li>
<li>
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https://github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A//github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
<span class="headerbtn__icon-container">
<img src="../_static/images/logo_jupyterhub.svg"/>
</span>
Expand Down

0 comments on commit 5721a63

Please sign in to comment.