fix: pagination when searching
This commit is contained in:
@@ -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!
|
||||
|
||||
@@ -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()}`;
|
||||
}
|
||||
@@ -48,12 +48,12 @@
|
||||
{% if page.has_other_pages %}
|
||||
<div class="pagination">
|
||||
{% if page.has_previous %}
|
||||
<a href="?p=1"> << </a>
|
||||
<a href="?p={{ page.previous_page_number }}"> < </a>
|
||||
<a onclick="window.location.href = buildURI(1)" href="#"> << </a>
|
||||
<a onclick="window.location.href = buildURI('{{ page.previous_page_number }}')" href="#"> < </a>
|
||||
{% endif %}
|
||||
{% if page.has_next %}
|
||||
<a href="?p={{ page.next_page_number }}"> > </a>
|
||||
<a href="?p={{ page.paginator.num_pages }}"> >> </a>
|
||||
<a onclick="window.location.href = buildURI('{{ page.next_page_number }}')" href="#"> > </a>
|
||||
<a onclick="window.location.href = buildURI('{{ page.paginator.num_pages }}')" href="#"> >> </a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user