Compare commits
8 Commits
renovate/b
...
master
Author | SHA1 | Date |
---|---|---|
Jake Howard | 8d724277b0 | |
Jake Howard | 7fcbbad885 | |
Jake Howard | 514e609973 | |
Jake Howard | b89b9d0797 | |
Jake Howard | 413b3165e0 | |
Jake Howard | 2779a3e97f | |
Jake Howard | ac2ba1ef17 | |
Jake Howard | 0f328aff0a |
|
@ -14,6 +14,9 @@ server {
|
|||
|
||||
gzip_static on;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
|
||||
set_real_ip_from 0.0.0.0/0;
|
||||
real_ip_header X-Forwarded-For;
|
||||
|
||||
|
@ -39,6 +42,7 @@ server {
|
|||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080;
|
||||
gzip_types *;
|
||||
}
|
||||
|
||||
location /static {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Django==5.0.1
|
||||
wagtail==5.2.2
|
||||
Django==5.0.4
|
||||
wagtail==5.2.5
|
||||
django-environ==0.11.2
|
||||
whitenoise[brotli]==6.6.0
|
||||
Pygments==2.17.2
|
||||
|
@ -28,6 +28,7 @@ django-permissions-policy==4.18.0
|
|||
django-enforce-host==1.1.0
|
||||
django-proxy==1.2.2
|
||||
wagtail-lite-youtube-embed==0.1.0
|
||||
django-minify-html==1.7.1
|
||||
|
||||
# DRF OpenAPI dependencies
|
||||
uritemplate
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{% extends "common/listing_page.html" %}
|
||||
|
||||
{% load wagtailroutablepage_tags %}
|
||||
|
||||
{% block hero_buttons %}
|
||||
<a class="button is-radiusless" href="{{ page.tag_list_page_url }}" title="View tags"><i class="fas fa-tags" aria-hidden="true"></i></a>
|
||||
{{ block.super }}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from django_minify_html.middleware import MinifyHtmlMiddleware
|
||||
|
||||
|
||||
class CustomMinifyHtmlMiddleware(MinifyHtmlMiddleware):
|
||||
minify_args = {
|
||||
"do_not_minify_doctype": True,
|
||||
"ensure_spec_compliant_unquoted_attribute_values": True,
|
||||
"keep_spaces_between_attributes": True,
|
||||
}
|
|
@ -295,6 +295,13 @@ class BaseListingPage(RoutablePageMixin, BaseContentPage):
|
|||
def feed(self, request: HttpRequest) -> HttpResponse:
|
||||
return redirect("feed", permanent=True)
|
||||
|
||||
@route(r"^random/$")
|
||||
def random(self, request: HttpRequest) -> HttpResponse:
|
||||
page = self.get_listing_pages().order_by("?").first()
|
||||
if page is None:
|
||||
return redirect(self.get_url(request=request), permanent=False)
|
||||
return redirect(page.get_url(request=request), permanent=False)
|
||||
|
||||
|
||||
class ListingPage(BaseListingPage):
|
||||
pass
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{% extends "common/content_page.html" %}
|
||||
|
||||
{% load wagtailadmin_tags %}
|
||||
{% load wagtailadmin_tags wagtailroutablepage_tags %}
|
||||
|
||||
{% block hero_buttons %}
|
||||
<a class="button is-radiusless" href="{% routablepageurl page 'random' %}" title="View random"><i class="fas fa-dice" aria-hidden="true"></i></a>
|
||||
|
||||
{% if listing_pages.has_previous %}
|
||||
<a class="button is-radiusless" href="{% querystring page=listing_pages.previous_page_number %}" title="Previous page"><i class="fas fa-arrow-left" aria-hidden="true"></i></a>
|
||||
{% endif %}
|
||||
|
|
|
@ -77,3 +77,12 @@ class ListingPageTestCase(TestCase):
|
|||
self.assertEqual(
|
||||
response.context["page"].get_meta_url(), self.page.full_url + "?page=2"
|
||||
)
|
||||
|
||||
def test_random(self) -> None:
|
||||
url = self.page.url + self.page.reverse_subpage("random")
|
||||
with self.assertNumQueries(10):
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertIn(
|
||||
response.url, [page.get_url() for page in self.page.get_listing_pages()]
|
||||
)
|
||||
|
|
|
@ -9,6 +9,7 @@ class GitHubLinguistHealthCheckBackend(BaseHealthCheckBackend):
|
|||
colours = _get_linguist_colours()
|
||||
except Exception as e:
|
||||
self.add_error(str(e))
|
||||
return
|
||||
|
||||
if colours is None:
|
||||
self.add_error("No colours provided")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.core.cache import cache
|
||||
from wagtail import hooks
|
||||
from wagtail.models import Page
|
||||
|
||||
from website.common.utils import get_page_models
|
||||
|
||||
|
@ -7,7 +8,7 @@ from .utils import SingletonPageCache
|
|||
|
||||
|
||||
@hooks.register("after_move_page")
|
||||
def clear_singleton_url_cache(**kwargs: dict) -> None:
|
||||
def clear_singleton_url_cache(page_to_move: Page) -> None:
|
||||
"""
|
||||
Clear all page caches, in case a parent has moved
|
||||
"""
|
||||
|
|
|
@ -38,7 +38,7 @@ class SearchPageTestCase(TestCase):
|
|||
|
||||
self.assertEqual(search_input.attrs["name"], "q")
|
||||
self.assertEqual(search_input.attrs["hx-get"], "results/")
|
||||
self.assertEqual(search_input.attrs["value"], "")
|
||||
self.assertNotIn("value", search_input.attrs) # Because of minify-html
|
||||
|
||||
self.assertEqual(len(soup.select(search_input.attrs["hx-target"])), 1)
|
||||
self.assertEqual(len(soup.select(search_input.attrs["hx-indicator"])), 2)
|
||||
|
|
|
@ -79,6 +79,7 @@ INSTALLED_APPS = [
|
|||
"wagtail_2fa",
|
||||
"django_otp",
|
||||
"django_otp.plugins.otp_totp",
|
||||
"django_minify_html",
|
||||
"health_check",
|
||||
"health_check.db",
|
||||
"health_check.cache",
|
||||
|
@ -93,12 +94,12 @@ INSTALLED_APPS = [
|
|||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.gzip.GZipMiddleware",
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"corsheaders.middleware.CorsMiddleware",
|
||||
"enforce_host.EnforceHostMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"website.common.middleware.CustomMinifyHtmlMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
|
|
Loading…
Reference in New Issue