feat: display number of search results

This commit is contained in:
eneller
2025-04-05 10:28:08 +02:00
parent 21d6d265ed
commit 1ef440fb8f
2 changed files with 5 additions and 2 deletions

View File

@@ -35,11 +35,13 @@ def index(request: HttpRequest):
localbooks = [book for book in books if searchParam in book.title]
# return base view
# TODO pagination
context = {
'title': 'epub2go',
'http_host': f'http://{ request.META['HTTP_HOST'] }',
'books': localbooks,
'book_count': len(books),
'books_count': len(localbooks),
'allbooks_count': len(books),
'allbooks_url': allbooks_url,
}
return render(request, 'home.html', context)

View File

@@ -8,7 +8,7 @@
<input type="search" id="searchInput" placeholder="Suche nach Titel" minlength="3">
</form>
</search>
<small>Im Moment finden sich hier <a href="{{ allbooks_url }}">{{ book_count }} Bücher.</a> </small>
<small>Im Moment finden sich hier <a href="{{ allbooks_url }}">{{ allbooks_count }} Bücher.</a> </small>
<a href="javascript:void(window.open('{{ http_host }}/?t=' + encodeURIComponent(window.location.toString())))" title="Als Lesezeichen speichern">
<img src="{% static 'bookmark.svg' %}" alt="Bookmarklet" class="header-icon">
</a>
@@ -45,5 +45,6 @@
{% endfor %}
</tbody>
</table>
<small>{{ books_count }} Ergebnisse gefunden</small>
</main>
{% endblock %}