Skip to content

Commit ef6a82e

Browse files
committed
Enable option for relbars
Provides *next* and *previous* links above and below main page content. They are disabled by default. Includes documentation. Closes #18.
1 parent 3e6bc4a commit ef6a82e

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

alabaster/layout.html

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,30 @@
1212
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
1313
{% endblock %}
1414

15-
{# Disable base theme's top+bottom related navs; we have our own in sidebar #}
15+
{# top+bottom related navs; we also have our own in sidebar #}
16+
{%- macro rellink_markup() %}
17+
<nav id="rellinks">
18+
<ul>
19+
{%- if prev %}
20+
<li>
21+
&larr;
22+
<a href="{{ prev.link|e }}" title="Previous document">{{ prev.title }}</a>
23+
</li>
24+
{%- endif %}
25+
{%- if next %}
26+
<li>
27+
<a href="{{ next.link|e }}" title="Next document">{{ next.title }}</a>
28+
&rarr;
29+
</li>
30+
{%- endif %}
31+
</ul>
32+
</nav>
33+
{%- endmacro %}
34+
35+
{%- set theme_show_relbar_top = theme_show_relbar_top or theme_show_relbars %}
36+
{%- set theme_show_relbar_bottom = theme_show_relbar_bottom or theme_show_relbars %}
37+
38+
{# removed existing top+bottom related nav, and embed in main content #}
1639
{%- block relbar1 %}{% endblock %}
1740
{%- block relbar2 %}{% endblock %}
1841

@@ -26,9 +49,29 @@
2649
{%- if render_sidebar %}
2750
<div class="bodywrapper">
2851
{%- endif %}
52+
53+
{%- block relbar_top %}
54+
{%- if theme_show_relbar_top|tobool %}
55+
<div class="related top">
56+
&nbsp;
57+
{{- rellink_markup () }}
58+
</div>
59+
{%- endif %}
60+
{% endblock %}
61+
2962
<div class="body" role="main">
3063
{% block body %} {% endblock %}
3164
</div>
65+
66+
{%- block relbar_bottom %}
67+
{%- if theme_show_relbar_bottom|tobool %}
68+
<div class="related bottom">
69+
&nbsp;
70+
{{- rellink_markup () }}
71+
</div>
72+
{%- endif %}
73+
{% endblock %}
74+
3275
{%- if render_sidebar %}
3376
</div>
3477
{%- endif %}

alabaster/static/alabaster.css_t

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
{%- set theme_narrow_sidebar_link = theme_narrow_sidebar_link or theme_gray_3 %}
5050
{%- set theme_sidebar_hr = theme_sidebar_hr or theme_gray_3 %}
5151

52+
{%- set theme_relbar_border = theme_relbar_border or theme_gray_2 -%}
53+
5254

5355
@import url("basic.css");
5456

@@ -704,3 +706,50 @@ table.docutils.citation, table.docutils.citation td, table.docutils.citation th
704706
-webkit-box-shadow: none;
705707
box-shadow: none;
706708
}
709+
710+
711+
/* relbar */
712+
713+
.related {
714+
line-height: 30px;
715+
width: 100%;
716+
font-size: 0.9rem;
717+
}
718+
719+
.related.top {
720+
border-bottom: 1px solid {{ theme_relbar_border }};
721+
margin-bottom: 20px;
722+
}
723+
724+
.related.bottom {
725+
border-top: 1px solid {{ theme_relbar_border }};
726+
}
727+
728+
.related ul {
729+
padding: 0;
730+
margin: 0;
731+
list-style: none;
732+
}
733+
734+
.related li {
735+
display: inline;
736+
}
737+
738+
nav#rellinks {
739+
float: right;
740+
}
741+
742+
nav#rellinks li+li:before {
743+
content: "|";
744+
}
745+
746+
nav#breadcrumbs li+li:before {
747+
content: "\00BB";
748+
}
749+
750+
/* Hide certain items when printing */
751+
@media print {
752+
div.related {
753+
display: none;
754+
}
755+
}

alabaster/theme.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ sidebar_includehidden = true
2727
sidebar_collapse = true
2828
show_powered_by = true
2929
show_related = false
30+
show_relbars = false
31+
show_relbar_top =
32+
show_relbar_bottom =
3033

3134
gray_1 = #444
3235
gray_2 = #EEE
@@ -119,3 +122,4 @@ code_highlight = #FFC
119122
page_width = 940px
120123
sidebar_width = 220px
121124
fixed_sidebar = false
125+
relbar_border =

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Changelog
33
=========
44

5+
* :feature:`18` add optional *next* and *previous* links at the top and bottom
6+
of page content. Use theme option ``show_relbars`` to enable these. Credit:
7+
William Minchin.
58
* :release:`0.7.10 <2017-02-28>`
69
* :bug:`32` Update styling of various block-level elements such as admonitions
710
(``.. note::``, ``.. warning::``, etc) and code blocks (``.. code::``) so

docs/customization.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ Variables and feature toggles
158158
main body of the page scrolls but the sidebar remains visible. (Applies only
159159
to desktop window sizes; the mobile view is unaffected.) Defaults to
160160
``false``.
161+
* ``show_relbars``: ``true`` or ``false`, defaults to ``false`` - used to
162+
display *next* and *previous* links above and below the main page content. If
163+
you only want to display one, this setting can be further overriden through
164+
the ``show_relbar_top`` and ``show_relbar_bottom`` settings.
161165

162166
Style colors
163167
------------
@@ -208,6 +212,8 @@ colorscheme. The more granular settings can be used to override as needed.
208212
* ``narrow_sidebar_fg``: Text color of same.
209213
* ``narrow_sidebar_link``: Link color of same. Defaults to ``gray_3``.
210214
* ``code_highlight``: Color of highlight when using ``:emphasize-lines:`` in a code block.
215+
* ``relbar_border``: Color of border between bar holding *next* and *previous*
216+
links, the rest of the page content. Defulats to ``gray_2``.
211217

212218
Fonts
213219
-----

0 commit comments

Comments
 (0)