Skip to content

Commit c331f6c

Browse files
ammaraskarzware
authored andcommitted
Move the search box from sidebar to header and footer. (#34)
1 parent e9b3497 commit c331f6c

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@
110110
templates_path = ['tools/templates']
111111

112112
# Custom sidebar templates, filenames relative to this file.
113-
#html_sidebars = {
114-
# 'index': 'indexsidebar.html',
115-
#}
113+
html_sidebars = {
114+
# Defaults taken from http://www.sphinx-doc.org/en/stable/config.html#confval-html_sidebars
115+
# Removes the quick search block
116+
'**': ['localtoc.html', 'relations.html', 'sourcelink.html']
117+
}
116118

117119
# Additional static files.
118120
html_static_path = ['tools/static']

tools/templates/layout.html

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,32 @@
77
<a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}
88
</li>
99
{% endblock %}
10+
{% macro searchbox() %}
11+
{# modified from sphinx/themes/basic/searchbox.html #}
12+
<div role="search">
13+
<form action="{{ pathto('search') }}" method="get">
14+
<input placeholder="{{ _('Quick search') }}" type="text" name="q" />
15+
<input type="submit" value="{{ _('Go') }}" />
16+
<input type="hidden" name="check_keywords" value="yes" />
17+
<input type="hidden" name="area" value="default" />
18+
</form>
19+
</div>
20+
<script type="text/javascript">$('.inline-search').show(0);</script>
21+
{% endmacro %}
1022
{% block relbar1 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %}
1123
{% block relbar2 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %}
24+
{% block relbaritems %}
25+
{% if pagename != "search" and builder != "singlehtml" %}
26+
<li class="inline-search right" style="display: none">
27+
{{ searchbox() }}
28+
{{ reldelim2 }}
29+
</li>
30+
{%- endif %}
31+
{% endblock %}
1232
{% block extrahead %}
1333
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" />
1434
{% if not embedded %}<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>{% endif %}
15-
35+
1636
{{ super() }}
1737
{% endblock %}
1838
{% block footer %}
@@ -27,12 +47,3 @@
2747
{% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
2848
</div>
2949
{% endblock %}
30-
{% block sidebarsourcelink %}
31-
{%- if show_source and has_source and sourcename %}
32-
<h3>{{ _('This Page') }}</h3>
33-
<ul class="this-page-menu">
34-
<li><a href="{{ pathto('_sources/' + sourcename, true)|e }}"
35-
rel="nofollow">{% trans %}Show Source{% endtrans %}</a></li>
36-
</ul>
37-
{%- endif %}
38-
{% endblock %}

0 commit comments

Comments
 (0)