fix: pagination when searching

This commit is contained in:
eneller
2025-04-05 16:14:39 +02:00
parent 6e7d6b1e2a
commit ee598e4810
3 changed files with 11 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ PROJ_DIR = BASE_DIR / 'epub2go_web'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: keep the secret key used in production secret! TODO
SECRET_KEY = "django-insecure-^@m5bl*8x+=@c^b0lhkgb-%_#9#&oad=v15jq=!0$g#x17zjf8"
# SECURITY WARNING: don't run with debug turned on in production!

View File

@@ -22,3 +22,9 @@ function submitSearch(event){
let path = window.location.pathname + "./?s="+encodeURIComponent(searchInput.value);
window.location.href= path;
}
function buildURI(p){
let params = new URLSearchParams(window.location.search);
params.set('p', p);
return `${window.location.pathname}?${params.toString()}`;
}

View File

@@ -48,12 +48,12 @@
{% if page.has_other_pages %}
<div class="pagination">
{% if page.has_previous %}
<a href="?p=1"> &lt;&lt; </a>
<a href="?p={{ page.previous_page_number }}"> &lt; </a>
<a onclick="window.location.href = buildURI(1)" href="#"> &lt;&lt; </a>
<a onclick="window.location.href = buildURI('{{ page.previous_page_number }}')" href="#"> &lt; </a>
{% endif %}
{% if page.has_next %}
<a href="?p={{ page.next_page_number }}"> &gt; </a>
<a href="?p={{ page.paginator.num_pages }}"> &gt;&gt; </a>
<a onclick="window.location.href = buildURI('{{ page.next_page_number }}')" href="#"> &gt; </a>
<a onclick="window.location.href = buildURI('{{ page.paginator.num_pages }}')" href="#"> &gt;&gt; </a>
{% endif %}
</div>
{% endif %}