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] Use logo url as is to allow for web urls. #661

Merged
merged 1 commit into from
Jan 6, 2023

Conversation

feanil
Copy link

@feanil feanil commented Dec 21, 2022

logo_url can sometimes be a fully qualified URL starting in Sphinx 4.
Adding the _static prefix breaks logos that are URLs.

`logo_url` can sometimes be a fully qualified URL starting in Sphinx 4.
Adding the `_static` prefix breaks logos that are URLs.
@welcome
Copy link

welcome bot commented Dec 21, 2022

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.

Welcome to the EBP community! 🎉

@feanil feanil changed the title fix: Use logo url as is. [FIX] Use logo url as is to allow for web urls. Dec 21, 2022
@choldgraf
Copy link
Member

Thanks for the PR - one question, won't this break local paths because we're removing the pathto? It seems we should instead want to use pathto if the variable doesn't start with http.

@feanil
Copy link
Author

feanil commented Jan 5, 2023

@@ -5,7 +5,7 @@
{% set logo_url=logo %}
{% endif %}
{% if logo_url %}
<img src="{{ pathto('_static/' + logo_url, 1) }}" class="logo" alt="logo">
<img src="{{ logo_url|e }}" class="logo" alt="logo">
Copy link
Member

Choose a reason for hiding this comment

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

Why is this being escaped? Isn't it an already-encoded URL?

Copy link
Author

Choose a reason for hiding this comment

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

@pradyunsg I don't think that's guaranteed since the logo_url value comes from the user in conf.py and the code I linked to above doesn't seem to be escaping anything.

Copy link
Member

Choose a reason for hiding this comment

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

@pradyunsg
Copy link
Member

x-ref pradyunsg/furo#253 where I'd discovered this as well. :)

Copy link
Member

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

Many thanks for this fix and for linking to the sphinx code where this is now handled! :-)

@choldgraf choldgraf merged commit 0a16df6 into executablebooks:master Jan 6, 2023
@welcome
Copy link

welcome bot commented Jan 6, 2023

Congrats on your first merged pull request in this project! 🎉
congrats

Thank you for contributing, we are very proud of you! ❤️

@feanil feanil deleted the feanil/fix_logo branch January 6, 2023 18:28
@feanil
Copy link
Author

feanil commented Jan 6, 2023

Thanks for the quick reviews @choldgraf and @pradyunsg, when do you guys think this will be released in a new version?

@choldgraf
Copy link
Member

There's a release candidate out now and this will make it into the next RC i think

@melund
Copy link

melund commented Jan 18, 2023

@fenil/@choldgraf The master version of sphinx-book-theme doesn't use the sidebar-logo.htm anymore, but instead the navbar-logo.html from the pydata theme.

That version does check that the if the string is an URL, but if not it prepends _static/ which causes me to see it prepended twice.
image

A workaround is to specify the logo using the PyData logo config (light and dark theme). I guess that prevents sphinx from also prepending the _static:

html_theme_options: Dict[str, Any] = {
      ...,
    "logo": {
      "image_light": "logo.svg",
      "image_dark": "logo.svg",
   },

@feanil
Copy link
Author

feanil commented Jan 18, 2023

@melund it sounds like maybe this same fix needs to be made in navbar-logo.html as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants