From fdadda99101293fee348c9dda9cfe7eda5a50171 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 13 Feb 2023 14:12:29 +0100 Subject: [PATCH] Docs: Fix search page --- doc/_themes/pretix_theme/layout.html | 95 ++++++++++++++++------------ doc/_themes/pretix_theme/search.html | 18 ++++-- doc/conf.py | 1 + doc/requirements.rtd.txt | 1 + doc/requirements.txt | 1 + 5 files changed, 70 insertions(+), 46 deletions(-) diff --git a/doc/_themes/pretix_theme/layout.html b/doc/_themes/pretix_theme/layout.html index 681aa9dec9..da860bff30 100644 --- a/doc/_themes/pretix_theme/layout.html +++ b/doc/_themes/pretix_theme/layout.html @@ -18,67 +18,82 @@ {{ title|striptags|e }}{{ titlesuffix }} {% endblock %} - {# FAVICON #} - {% if favicon %} - - {% endif %} - {# CANONICAL URL #} - {% if theme_canonical_url %} + + {#- CSS #} + {%- for css in css_files %} + {%- if css|attr("rel") %} + + {%- else %} + + {%- endif %} + {%- endfor %} + + {%- for cssfile in extra_css_files %} + + {%- endfor -%} + + {#- FAVICON + favicon_url is the only context var necessary since Sphinx 4. + In Sphinx<4, we use favicon but need to prepend path info. + #} + {%- set _favicon_url = favicon_url | default(pathto('_static/' + (favicon or ""), 1)) %} + {%- if favicon_url or favicon %} + + {%- endif %} + + {#- CANONICAL URL (deprecated) #} + {%- if theme_canonical_url and not pageurl %} - {% endif %} + {%- endif -%} - {# CSS #} + {#- CANONICAL URL #} + {%- if pageurl %} + + {%- endif -%} - {# OPENSEARCH #} - {% if not embedded %} - {% if use_opensearch %} - - {% endif %} + {#- JAVASCRIPTS #} + {%- block scripts %} + + {%- if not embedded %} + {# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #} + {%- for scriptfile in script_files %} + {{ js_tag(scriptfile) }} + {%- endfor %} + - {% endif %} - - {# RTD hosts this file, so just load on non RTD builds #} - - - {% for cssfile in css_files %} - - {% endfor %} - - {% for cssfile in extra_css_files %} - - {% endfor %} + {#- OPENSEARCH #} + {%- if use_opensearch %} + + {%- endif %} + {%- endif %} + {%- endblock %} {%- block linktags %} {%- if hasdoc('about') %} - + {%- endif %} {%- if hasdoc('genindex') %} - + {%- endif %} {%- if hasdoc('search') %} - + {%- endif %} {%- if hasdoc('copyright') %} - - {%- endif %} - - {%- if parents %} - + {%- endif %} {%- if next %} - + {%- endif %} {%- if prev %} - + {%- endif %} {%- endblock %} {%- block extrahead %} {% endblock %} - {# Keep modernizr in head - http://modernizr.com/docs/#installing #} - - diff --git a/doc/_themes/pretix_theme/search.html b/doc/_themes/pretix_theme/search.html index e3aa9b5c6e..c9776969df 100644 --- a/doc/_themes/pretix_theme/search.html +++ b/doc/_themes/pretix_theme/search.html @@ -5,31 +5,37 @@ Template for the search page. :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. + :license: BSD, see https://github.com/sphinx-doc/sphinx/blob/master/LICENSE for details. #} {%- extends "layout.html" %} {% set title = _('Search') %} -{% set script_files = script_files + ['_static/searchtools.js'] %} +{% set display_vcs_links = False %} +{%- block scripts %} + {{ super() }} + + +{%- endblock %} {% block footer %} - {# this is used when loading the search index using $.ajax fails, such as on Chrome for documents on localhost #} - + {{ super() }} {% endblock %} {% block body %} {% if search_performed %} + {# Translators: Search is a noun, not a verb #}

{{ _('Search Results') }}

{% if not search_results %}

{{ _('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.') }}

@@ -47,4 +53,4 @@ {% endif %} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/doc/conf.py b/doc/conf.py index 337027aff1..04be9c765d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -49,6 +49,7 @@ extensions = [ 'sphinx.ext.coverage', 'sphinxcontrib.httpdomain', 'sphinxcontrib.images', + 'sphinxcontrib.jquery', 'sphinxemoji.sphinxemoji', ] if HAS_PYENCHANT: diff --git a/doc/requirements.rtd.txt b/doc/requirements.rtd.txt index 9e258d2857..43b7375bce 100644 --- a/doc/requirements.rtd.txt +++ b/doc/requirements.rtd.txt @@ -3,6 +3,7 @@ jinja2==3.1.* sphinx-rtd-theme sphinxcontrib-httpdomain sphinxcontrib-images +sphinxcontrib-jquery sphinxcontrib-spelling==7.* sphinxemoji pygments-markdown-lexer diff --git a/doc/requirements.txt b/doc/requirements.txt index bdbc35548d..49c9ac7962 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -4,6 +4,7 @@ jinja2==3.1.* sphinx-rtd-theme sphinxcontrib-httpdomain sphinxcontrib-images +sphinxcontrib-jquery sphinxcontrib-spelling==7.* sphinxemoji pygments-markdown-lexer