[mod] Retain page numbers even when there are no results

This commit is contained in:
obfuscated-loop 2023-11-22 10:49:45 +00:00 committed by Markus Heiser
parent c3cc24be12
commit 99fb565b39
2 changed files with 19 additions and 17 deletions

View file

@ -232,7 +232,7 @@ class ResultContainer:
if engine_name in engines: if engine_name in engines:
histogram_observe(standard_result_count, 'engine', engine_name, 'result', 'count') histogram_observe(standard_result_count, 'engine', engine_name, 'result', 'count')
if not self.paging and standard_result_count > 0 and engine_name in engines and engines[engine_name].paging: if not self.paging and engine_name in engines and engines[engine_name].paging:
self.paging = True self.paging = True
def _merge_infobox(self, infobox): def _merge_infobox(self, infobox):

View file

@ -124,22 +124,24 @@
</div> </div>
</form> </form>
{% endif %} {% endif %}
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="next_page"> {%- if results | count > 0 -%}
<div class="{% if rtl %}left{% else %}right{% endif %}"> <form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="next_page">
<input type="hidden" name="q" value="{{ q|e }}" > <div class="{% if rtl %}left{% else %}right{% endif %}">
{% for category in selected_categories %} <input type="hidden" name="q" value="{{ q|e }}" >
<input type="hidden" name="category_{{ category }}" value="1" > {% for category in selected_categories %}
{% endfor %} <input type="hidden" name="category_{{ category }}" value="1" >
<input type="hidden" name="pageno" value="{{ pageno+1 }}" > {% endfor %}
<input type="hidden" name="language" value="{{ current_language }}" > <input type="hidden" name="pageno" value="{{ pageno+1 }}" >
<input type="hidden" name="time_range" value="{{ time_range }}" > <input type="hidden" name="language" value="{{ current_language }}" >
<input type="hidden" name="safesearch" value="{{ safesearch }}" > <input type="hidden" name="time_range" value="{{ time_range }}" >
<input type="hidden" name="theme" value="{{ theme }}" > <input type="hidden" name="safesearch" value="{{ safesearch }}" >
{% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %} <input type="hidden" name="theme" value="{{ theme }}" >
{{- engine_data_form(engine_data) -}} {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %}
<button role="link" type="submit">{{ _('Next page') }} {{ icon_small('chevron-right') }}</button> {{- engine_data_form(engine_data) -}}
</div> <button role="link" type="submit">{{ _('Next page') }} {{ icon_small('chevron-right') }}</button>
</form> </div>
</form>
{%- endif -%}
{% set pstart = 1 %} {% set pstart = 1 %}
{% set pend = 11 %} {% set pend = 11 %}
{% if pageno > 5 %} {% if pageno > 5 %}