Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pagination, bump all deps #233

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_wtf/core/search_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class SearchView(OriginalSearchView):
paginate_by = 20
paginate_by = 10
models = (Repository,)

def get_template_names(self): # pyright: ignore [reportIncompatibleMethodOverride]
Expand Down
2 changes: 1 addition & 1 deletion django_wtf/templates/core/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load tailwind_tags django_htmx %}
<!DOCTYPE html>
<html lang="en-US">
<html lang="en-US" data-theme="dark">
<head>
{% block head %}
{% include "meta/meta.html" %}
Expand Down
17 changes: 8 additions & 9 deletions django_wtf/templates/core/components/_navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,25 @@
</form>
{% endif %}
</div>
<ul class="text-white uppercase menu menu-horizontal menu-xs gap-4">
<ul class="text-white uppercase menu menu-horizontal menu-sm gap-4 items-center">
{% flag "newsletter" %}
<li class="btn btn-outline btn-accent">
<a class="text-sm" href="{% url 'core:subscriber-landing' %}">Newsletter</a>
</li>
<a class="btn btn-sm btn-outline btn-accent"
href="{% url 'core:subscriber-landing' %}">Newsletter</a>
{% endflag %}
<li>
<a class="text-sm" href="{% url 'core:top-repositories' %}">Best apps</a>
<a href="{% url 'core:top-repositories' %}">Best apps</a>
</li>
<li>
<a class="text-sm" href="{% url 'core:trending-repositories' %}">Trending apps</a>
<a href="{% url 'core:trending-repositories' %}">Trending apps</a>
</li>
<li>
<a class="text-sm" href="{% url 'core:top-profiles' %}">Best profiles</a>
<a href="{% url 'core:top-profiles' %}">Best profiles</a>
</li>
<li>
<a class="text-sm" href="{% url 'core:trending-profiles' %}">Trending profiles</a>
<a href="{% url 'core:trending-profiles' %}">Trending profiles</a>
</li>
<li>
<a class="text-sm" href="{% url 'core:social-media-news' %}">Social media news</a>
<a href="{% url 'core:social-media-news' %}">Social media news</a>
</li>
</ul>
</div>
Expand Down
Empty file.
45 changes: 44 additions & 1 deletion django_wtf/templates/core/search_table.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load admin_urls static %}

{% if object_list %}
{% for object in object_list %}
{% for object in page_obj %}
<div class="my-4 rounded">
<div class="shadow-xl card bg-base-200">
<div class="pb-2 card-body">
Expand All @@ -23,4 +23,47 @@ <h2 class="flex justify-between card-title">
</div>
</div>
{% endfor %}
<div class="flex w-100 justify-center mt-10 mb-5">
<div class="join">
{% if page_obj.has_previous %}
<button class="join-item btn btn-neutral"
hx-trigger="click"
hx-include="[name='q'],[name='category']"
hx-get="{% url 'core:search' %}?page={{ page_obj.previous_page_number }}"
hx-push-url="true"
hx-target="#search_table">
<<
</button>
{% if page_obj.number > 2 %}
<button class="join-item btn btn-neutral mr-3"
hx-trigger="click"
hx-include="[name='q'],[name='category']"
hx-get="{% url 'core:search' %}?page=1"
hx-push-url="true"
hx-target="#search_table">1</button>
{% endif %}
<button class="join-item btn btn-neutral"
hx-trigger="click"
hx-include="[name='q'],[name='category']"
hx-get="{% url 'core:search' %}?page={{ page_obj.previous_page_number }}"
hx-push-url="true"
hx-target="#search_table">{{ page_obj.previous_page_number }}</button>
{% endif %}
<button class="join-item btn btn-neutral btn-active">{{ page_obj.number }}</button>
{% if page_obj.has_next %}
<button class="join-item btn btn-neutral"
hx-trigger="click"
hx-include="[name='q'],[name='category']"
hx-get="{% url 'core:search' %}?page={{ page_obj.next_page_number }}"
hx-push-url="true"
hx-target="#search_table">{{ page_obj.next_page_number }}</button>
<button class="join-item btn btn-neutral"
hx-trigger="click"
hx-include="[name='q'],[name='category']"
hx-get="{% url 'core:search' %}?page={{ page_obj.next_page_number }}"
hx-push-url="true"
hx-target="#search_table">>></button>
{% endif %}
</div>
</div>
{% endif %}
Loading
Loading