summaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-06-03 18:50:02 -0700
committerBryan Newbold <bnewbold@archive.org>2020-06-03 18:50:04 -0700
commit042399269d593024cc8ed4a5d1e1251d435c5972 (patch)
treea0a8d9bda9ef5f812adff1428c9688ffbd6934e1 /fatcat_scholar
parentb3c8dc762747a8b6435dfaaaa7e52a0f0204de9b (diff)
downloadfatcat-scholar-042399269d593024cc8ed4a5d1e1251d435c5972.tar.gz
fatcat-scholar-042399269d593024cc8ed4a5d1e1251d435c5972.zip
basic pagination
Not well tested
Diffstat (limited to 'fatcat_scholar')
-rw-r--r--fatcat_scholar/templates/search.html13
-rw-r--r--fatcat_scholar/templates/search_macros.html14
2 files changed, 27 insertions, 0 deletions
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 @@
</div>
{% elif hits and hits.results %}
{% if hits.results %}
+ {% if hits.offset != 0 %}
+ <div style="text-align: center; margin-bottom: 2em;">
+ {{ search_macros.search_pagination(hits) }}
+ </div>
+ {% 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 %}
+ <div style="text-align: center; margin-top: 2em;">
+ {{ search_macros.search_pagination(hits) }}
+ </div>
+ {% endif %}
{% endif %}
{% elif hits %}
<div class="ui placeholder segment" style="height: 100%;">
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 @@
</div>
{% endmacro %}
+{% macro search_pagination(hits, top) %}
+{% if hits.offset > 0 %}
+ <button class="text-button" form="search_form" type="submit" name="offset" value="{{ hits.offset - hits.limit }}" style="margin-right: 2em;">
+ <a>&#xab; Previous</a>
+ </button>
+{% else %}
+ <span style="color:gray">&#xab; Previous</span>
+{% endif %}
+<i>Showing results {{ hits.offset }} &mdash; {{ hits.offset + hits.limit }} out of {{ "{:,}".format(hits.count_found) }} results</i>
+<button class="text-button" form="search_form" type="submit" name="offset" value="{{ hits.offset + hits.limit }}" style="margin-left: 2em;">
+ <a>Next &#xbb;</a>
+</button>
+{% endmacro %}
+
{% macro query_option(options, selected) -%}
<span style="color: rgba(0,0,0,0.4);">{{ _(options.label) }}</span>
<div class="ui link list" style="margin-top: 0.3em;">