Skip to content

Commit

Permalink
Add pagination rel-links to WUI header, related to issue Alfanous-tea…
Browse files Browse the repository at this point in the history
  • Loading branch information
sneetsher committed May 21, 2018
1 parent e9dda5f commit 9c8d98a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/alfanous-django/templates/aya_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
{% block pagination_phone %} {% endblock %}
{% endkwacro %}

{% block pagination_rel_block %}
{% include 'wui/pagination_rel.html' with page=results.search.interval.page nb_pages=results.search.interval.nb_pages %}
{% endblock %}

{% block results %}
<div id="#search_result_static" class="row span9 offset2 text-center ">

Expand Down
4 changes: 2 additions & 2 deletions src/alfanous-django/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
<link rel="alternate" href="http://www.alfanous.org{% url 'wui.views.results' current.unit %}{% if current.request %}?{{ current.request }}{% endif %}" hreflang="{{ lang_code }}" />
{% endlanguage %}
{% endfor %}

{# todo: restructure base.html with generic blocks that allows extending any part like header #}
{% block pagination_rel_block %}{% endblock %}
<link rel="search" type="application/opensearchdescription+xml" title="Alfanous" href="/static/alfanous-opensearch.xml"/>


<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
{% ifequal bidi.direction "ltr" %}
Expand Down
17 changes: 17 additions & 0 deletions src/alfanous-django/wui/templates/wui/pagination_rel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{# @page: The number of current page #}
{# @nb_pages: The total number of result pages #}

{% load custom_filters %}
{% load query %}

{% if page != 1 %}
{% with page|add:"-1" as prev_page %}
<link rel="prev" href="?{% custom_query params.query prev_page False %}" />
{% endwith %}
{% endif %}

{% if page != nb_pages %}
{% with page|add:"+1" as next_page %}
<link rel="next" href="?{% custom_query params.query next_page False %}" />
{% endwith %}
{% endif %}

0 comments on commit 9c8d98a

Please sign in to comment.