From 3c66267b797a979370b1a55c6fba0807e22b5936 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 25 Dec 2023 22:22:10 +0000 Subject: [PATCH] Add breadcrumbs to search results --- static/src/scss/_listing.scss | 4 ++++ website/common/templates/common/listing-item.html | 5 ++++- website/search/templates/search/search_results.html | 2 +- website/search/tests.py | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/static/src/scss/_listing.scss b/static/src/scss/_listing.scss index 309b53f..e6b095c 100644 --- a/static/src/scss/_listing.scss +++ b/static/src/scss/_listing.scss @@ -42,6 +42,10 @@ .columns { width: 100%; } + + nav.breadcrumb { + margin-bottom: 0; + } } .page-blogpostlistpage { diff --git a/website/common/templates/common/listing-item.html b/website/common/templates/common/listing-item.html index 349cb63..5d8eeb8 100644 --- a/website/common/templates/common/listing-item.html +++ b/website/common/templates/common/listing-item.html @@ -1,6 +1,6 @@ {% load wagtailcore_tags cache util_tags %} -{% cache FRAGMENT_CACHE_TTL|jitter:FRAGMENT_CACHE_TTL_JITTER "listing-item" page.id request.is_preview %} +{% cache FRAGMENT_CACHE_TTL|jitter:FRAGMENT_CACHE_TTL_JITTER "listing-item" page.id request.is_preview breadcrumbs %}
@@ -12,6 +12,9 @@
+ {% if breadcrumbs %} + {% include "common/breadcrumbs.html" with parents=page.get_parent_pages %} + {% endif %}

{{ page.title }}

diff --git a/website/search/templates/search/search_results.html b/website/search/templates/search/search_results.html index e584a32..6484f0e 100644 --- a/website/search/templates/search/search_results.html +++ b/website/search/templates/search/search_results.html @@ -1,7 +1,7 @@ {% load wagtailadmin_tags %} {% for page in results %} - {% include "common/listing-item.html" %} + {% include "common/listing-item.html" with breadcrumbs=True %} {% endfor %} {% if not results and page_num == 1 %} diff --git a/website/search/tests.py b/website/search/tests.py index 6a85c60..bcdbfc1 100644 --- a/website/search/tests.py +++ b/website/search/tests.py @@ -55,7 +55,7 @@ class SearchPageResultsTestCase(TestCase): cls.url = cls.page.url + cls.page.reverse_subpage("results") def test_returns_results(self) -> None: - with self.assertNumQueries(12): + with self.assertNumQueries(24): response = self.client.get(self.url, {"q": "post"}, HTTP_HX_REQUEST="true") self.assertEqual(response.status_code, 200)