Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Escape colon in JupyterHub link to repo #556

Merged
merged 5 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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