Permalink
Browse files

Refactored pagination into include

  • Loading branch information...
simonw committed Oct 1, 2017
1 parent a76b691 commit 6c24d9fdeab4f58b6c3982b36a41e1a1179835ca
Showing with 30 additions and 31 deletions.
  1. +3 −0 static/css/all.css
  2. +24 −0 templates/_pagination.html
  3. +1 −15 templates/archive_tag.html
  4. +2 −16 templates/search.html
View
@@ -641,6 +641,9 @@ div.paginator {
padding: 0.5em 0;
font-size: 0.9em
}
.pagination {
margin-bottom: 1em;
}
.paginator a {
text-decoration: none
}
View
@@ -0,0 +1,24 @@
{% if page.paginator.num_pages > 1 %}{% load blog_tags %}
<div class="pagination">
{% if page_total %}
<strong>{{ page_total }} result{{ page_total|pluralize }}</strong>
{% endif %}
<span class="step-links">
{% if page.has_previous %}
<a href="{% page_href page.previous_page_number %}">&laquo; previous</a>
{% endif %}
<span class="current">
page {{ page.number }} / {{ page.paginator.num_pages }}
</span>
{% if page.has_next %}
<a href="{% page_href page.next_page_number %}">next &raquo;</a>
{% endif %}
</span>
</div>
{% else %}
{% if page_total %}
<div class="pagination">
<strong>{{ page_total }} result{{ page_total|pluralize }}</strong>
</div>
{% endif %}
{% endif %}
View
@@ -8,21 +8,7 @@ <h2>{{ total }} item{{ total|pluralize }} tagged “{{ tags|join:"” and “"|e
{% blog_mixed_list_with_dates items %}
{% if page.paginator.num_pages > 1 %}
<div class="pagination">
<span class="step-links">
{% if page.has_previous %}
<a href="{% page_href page.previous_page_number %}">&laquo; previous</a>
{% endif %}
<span class="current">
Page {{ page.number }} / {{ page.paginator.num_pages }}
</span>
{% if page.has_next %}
<a href="{% page_href page.next_page_number %}">next &raquo;</a>
{% endif %}
</span>
</div>
{% endif %}
{% include "_pagination.html" %}
{% endblock %}
View
@@ -13,23 +13,9 @@ <h2>Search{% if q %} for “{{ q }}”{% endif %}</h2>
<br>
{% if total %}
<p><strong>{{ total }} result{{ total|pluralize }}</strong></p>
{% include "_pagination.html" with page_total=total %}
{% blog_mixed_list_with_dates results %}
{% if page.paginator.num_pages > 1 %}
<div class="pagination">
<span class="step-links">
{% if page.has_previous %}
<a href="{% page_href page.previous_page_number %}">&laquo; previous</a>
{% endif %}
<span class="current">
Page {{ page.number }} / {{ page.paginator.num_pages }}
</span>
{% if page.has_next %}
<a href="{% page_href page.next_page_number %}">next &raquo;</a>
{% endif %}
</span>
</div>
{% endif %}
{% include "_pagination.html" %}
{% endif %}
{% endblock %}

0 comments on commit 6c24d9f

Please sign in to comment.