Fix bug related to arguments not being transferred over pages
This commit is contained in:
parent
fd2480ec45
commit
2dcf6d7c9e
2 changed files with 10 additions and 8 deletions
|
@ -38,7 +38,7 @@ async def root():
|
||||||
async def search(
|
async def search(
|
||||||
q: Union[str, None] = None,
|
q: Union[str, None] = None,
|
||||||
p: int = 0,
|
p: int = 0,
|
||||||
sort: str = "average_Rating",
|
sort: str = "average_rating",
|
||||||
dir: str = "desc",
|
dir: str = "desc",
|
||||||
date: int = -1
|
date: int = -1
|
||||||
):
|
):
|
||||||
|
@ -46,7 +46,9 @@ async def search(
|
||||||
limit = 10
|
limit = 10
|
||||||
if p is None:
|
if p is None:
|
||||||
p = 0
|
p = 0
|
||||||
|
|
||||||
|
# Passed to the template
|
||||||
|
QueryValues = {"q": q, "p": p, "sort": sort, "dir": dir, "date": date}
|
||||||
|
|
||||||
searchResults = None
|
searchResults = None
|
||||||
if q is not None:
|
if q is not None:
|
||||||
|
@ -115,12 +117,11 @@ async def search(
|
||||||
entryNumber = None
|
entryNumber = None
|
||||||
|
|
||||||
return template.render(
|
return template.render(
|
||||||
searchValue=searchValue,
|
|
||||||
searchPage=p,
|
|
||||||
searchResults=searchResults,
|
searchResults=searchResults,
|
||||||
THUMB_URL=THUMB_URL,
|
THUMB_URL=THUMB_URL,
|
||||||
entryLimit=limit,
|
entryLimit=limit,
|
||||||
entryNumber=entryNumber
|
entryNumber=entryNumber,
|
||||||
|
QueryValues=QueryValues
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.get("/level/{level_id}", response_class=HTMLResponse)
|
@app.get("/level/{level_id}", response_class=HTMLResponse)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<div class='searchBar'>
|
<div class='searchBar'>
|
||||||
<form action="/search" method="get">
|
<form action="/search" method="get">
|
||||||
<div class="search_entry">
|
<div class="search_entry">
|
||||||
<input type='text' id="q" name="q" value='{{ searchValue }}' placeholder="Enter a level name or code"/>
|
<input type='text' id="q" name="q" value='{{ QueryValues["q"] }}' placeholder="Enter a level name or code"/>
|
||||||
<button class="searchButton" id='searchButton' type='submit'>🔍</button>
|
<button class="searchButton" id='searchButton' type='submit'>🔍</button>
|
||||||
</div>
|
</div>
|
||||||
<details>
|
<details>
|
||||||
|
@ -83,9 +83,10 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="searchResultsFooter">
|
<div class="searchResultsFooter">
|
||||||
|
{% set searchPage = QueryValues['p'] %}
|
||||||
<p>Page {{ searchPage+1 }}</p>
|
<p>Page {{ searchPage+1 }}</p>
|
||||||
{% if not searchPage <= 0 %}<a href="/search?q={{ searchValue }}&p={{ searchPage-1 }}">Prev</a>{% endif %}
|
{% if not searchPage <= 0 %}<a href="/search?q={{ QueryValues['q'] }}&sort={{ QueryValues['sort'] }}&dir={{ QueryValues['dir'] }}&date={{ QueryValues['date'] }}&p={{ QueryValues['p']-1 }}">Prev</a>{% endif %}
|
||||||
{% if not entryNumber < entryLimit %}<a href="/search?q={{ searchValue }}&p={{ searchPage+1 }}">Next</a>{% endif %}
|
{% if not entryNumber < entryLimit %}<a href="/search?q={{ QueryValues['q'] }}&sort={{ QueryValues['sort'] }}&dir={{ QueryValues['dir'] }}&date={{ QueryValues['date'] }}&p={{ QueryValues['p']+1 }}">Next</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue