From 042399269d593024cc8ed4a5d1e1251d435c5972 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 3 Jun 2020 18:50:02 -0700 Subject: basic pagination Not well tested --- fatcat_scholar/templates/search.html | 13 +++++++++++++ fatcat_scholar/templates/search_macros.html | 14 ++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'fatcat_scholar/templates') diff --git a/fatcat_scholar/templates/search.html b/fatcat_scholar/templates/search.html index cfa4b74..9e2f06e 100644 --- a/fatcat_scholar/templates/search.html +++ b/fatcat_scholar/templates/search.html @@ -67,9 +67,22 @@ {% elif hits and hits.results %} {% if hits.results %} + {% if hits.offset != 0 %} +
+ {{ search_macros.search_pagination(hits) }} +
+ {% endif %} + + {# search results (rendered via macro) #} {% for paper in hits.results %} {{ search_macros.fulltext_search_result_row(paper) }} {% endfor %} + + {% if hits.count_found > hits.limit %} +
+ {{ search_macros.search_pagination(hits) }} +
+ {% endif %} {% endif %} {% elif hits %}
diff --git a/fatcat_scholar/templates/search_macros.html b/fatcat_scholar/templates/search_macros.html index 9676a6a..1b1ada2 100644 --- a/fatcat_scholar/templates/search_macros.html +++ b/fatcat_scholar/templates/search_macros.html @@ -181,6 +181,20 @@
{% endmacro %} +{% macro search_pagination(hits, top) %} +{% if hits.offset > 0 %} + +{% else %} + « Previous +{% endif %} +Showing results {{ hits.offset }} — {{ hits.offset + hits.limit }} out of {{ "{:,}".format(hits.count_found) }} results + +{% endmacro %} + {% macro query_option(options, selected) -%} {{ _(options.label) }}