Skip to content

Commit 9da97e1

Browse files
authored
Merge pull request #233 from honeylogic-io/add-pagination
feat: add pagination, bump all deps
2 parents 4df3fb6 + 673a856 commit 9da97e1

File tree

10 files changed

+438
-495
lines changed

10 files changed

+438
-495
lines changed

django_wtf/core/search_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class SearchView(OriginalSearchView):
9-
paginate_by = 20
9+
paginate_by = 10
1010
models = (Repository,)
1111

1212
def get_template_names(self): # pyright: ignore [reportIncompatibleMethodOverride]

django_wtf/templates/core/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load tailwind_tags django_htmx %}
22
<!DOCTYPE html>
3-
<html lang="en-US">
3+
<html lang="en-US" data-theme="dark">
44
<head>
55
{% block head %}
66
{% include "meta/meta.html" %}

django_wtf/templates/core/components/_navbar.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,25 @@
4949
</form>
5050
{% endif %}
5151
</div>
52-
<ul class="text-white uppercase menu menu-horizontal menu-xs gap-4">
52+
<ul class="text-white uppercase menu menu-horizontal menu-sm gap-4 items-center">
5353
{% flag "newsletter" %}
54-
<li class="btn btn-outline btn-accent">
55-
<a class="text-sm" href="{% url 'core:subscriber-landing' %}">Newsletter</a>
56-
</li>
54+
<a class="btn btn-sm btn-outline btn-accent"
55+
href="{% url 'core:subscriber-landing' %}">Newsletter</a>
5756
{% endflag %}
5857
<li>
59-
<a class="text-sm" href="{% url 'core:top-repositories' %}">Best apps</a>
58+
<a href="{% url 'core:top-repositories' %}">Best apps</a>
6059
</li>
6160
<li>
62-
<a class="text-sm" href="{% url 'core:trending-repositories' %}">Trending apps</a>
61+
<a href="{% url 'core:trending-repositories' %}">Trending apps</a>
6362
</li>
6463
<li>
65-
<a class="text-sm" href="{% url 'core:top-profiles' %}">Best profiles</a>
64+
<a href="{% url 'core:top-profiles' %}">Best profiles</a>
6665
</li>
6766
<li>
68-
<a class="text-sm" href="{% url 'core:trending-profiles' %}">Trending profiles</a>
67+
<a href="{% url 'core:trending-profiles' %}">Trending profiles</a>
6968
</li>
7069
<li>
71-
<a class="text-sm" href="{% url 'core:social-media-news' %}">Social media news</a>
70+
<a href="{% url 'core:social-media-news' %}">Social media news</a>
7271
</li>
7372
</ul>
7473
</div>

django_wtf/templates/core/repository_list.html

Whitespace-only changes.

django_wtf/templates/core/search_table.html

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load admin_urls static %}
22

33
{% if object_list %}
4-
{% for object in object_list %}
4+
{% for object in page_obj %}
55
<div class="my-4 rounded">
66
<div class="shadow-xl card bg-base-200">
77
<div class="pb-2 card-body">
@@ -23,4 +23,47 @@ <h2 class="flex justify-between card-title">
2323
</div>
2424
</div>
2525
{% endfor %}
26+
<div class="flex w-100 justify-center mt-10 mb-5">
27+
<div class="join">
28+
{% if page_obj.has_previous %}
29+
<button class="join-item btn btn-neutral"
30+
hx-trigger="click"
31+
hx-include="[name='q'],[name='category']"
32+
hx-get="{% url 'core:search' %}?page={{ page_obj.previous_page_number }}"
33+
hx-push-url="true"
34+
hx-target="#search_table">
35+
<<
36+
</button>
37+
{% if page_obj.number > 2 %}
38+
<button class="join-item btn btn-neutral mr-3"
39+
hx-trigger="click"
40+
hx-include="[name='q'],[name='category']"
41+
hx-get="{% url 'core:search' %}?page=1"
42+
hx-push-url="true"
43+
hx-target="#search_table">1</button>
44+
{% endif %}
45+
<button class="join-item btn btn-neutral"
46+
hx-trigger="click"
47+
hx-include="[name='q'],[name='category']"
48+
hx-get="{% url 'core:search' %}?page={{ page_obj.previous_page_number }}"
49+
hx-push-url="true"
50+
hx-target="#search_table">{{ page_obj.previous_page_number }}</button>
51+
{% endif %}
52+
<button class="join-item btn btn-neutral btn-active">{{ page_obj.number }}</button>
53+
{% if page_obj.has_next %}
54+
<button class="join-item btn btn-neutral"
55+
hx-trigger="click"
56+
hx-include="[name='q'],[name='category']"
57+
hx-get="{% url 'core:search' %}?page={{ page_obj.next_page_number }}"
58+
hx-push-url="true"
59+
hx-target="#search_table">{{ page_obj.next_page_number }}</button>
60+
<button class="join-item btn btn-neutral"
61+
hx-trigger="click"
62+
hx-include="[name='q'],[name='category']"
63+
hx-get="{% url 'core:search' %}?page={{ page_obj.next_page_number }}"
64+
hx-push-url="true"
65+
hx-target="#search_table">>></button>
66+
{% endif %}
67+
</div>
68+
</div>
2669
{% endif %}

0 commit comments

Comments
 (0)