Use singleton URL cache
This commit is contained in:
parent
7a4388bd69
commit
442aeb21b8
9 changed files with 16 additions and 13 deletions
|
@ -109,7 +109,7 @@ class BlogPostCollectionListPage(BaseListingPage):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_listing_pages(self) -> models.QuerySet:
|
def get_listing_pages(self) -> models.QuerySet:
|
||||||
blog_list_page = BlogPostListPage.objects.all().live().get()
|
blog_list_page = BlogPostListPage.objects.get()
|
||||||
return BlogPostCollectionPage.objects.child_of(blog_list_page).live().public()
|
return BlogPostCollectionPage.objects.child_of(blog_list_page).live().public()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="content has-text-centered">
|
<div class="content has-text-centered">
|
||||||
<p>
|
<p>
|
||||||
© <a href="{% pageurl homepage %}">TheOrangeOne</a> {% now "Y" %}
|
© <a href="{{ homepage_url }}">TheOrangeOne</a> {% now "Y" %}
|
||||||
</p>
|
</p>
|
||||||
<p id="to-top" class="is-size-7">
|
<p id="to-top" class="is-size-7">
|
||||||
<a class="scroll-top">To top</a>
|
<a class="scroll-top">To top</a>
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
<i class="fa-solid fa-circle-half-stroke" aria-hidden="true"></i>
|
<i class="fa-solid fa-circle-half-stroke" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
{% if search_page %}
|
{% if search_page_url %}
|
||||||
<a class="navbar-item navbar-icon" href="{% pageurl search_page %}">
|
<a class="navbar-item navbar-icon" href="{{ search_page_url }}">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="fas fa-search" aria-hidden="true"></i>
|
<i class="fas fa-search" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.template import Library
|
from django.template import Library
|
||||||
|
|
||||||
|
from website.contrib.singleton_url.utils import SingletonURLCache
|
||||||
from website.home.models import HomePage
|
from website.home.models import HomePage
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
@ -8,5 +9,5 @@ register = Library()
|
||||||
@register.inclusion_tag("common/footer.html")
|
@register.inclusion_tag("common/footer.html")
|
||||||
def footer() -> dict:
|
def footer() -> dict:
|
||||||
return {
|
return {
|
||||||
"homepage": HomePage.objects.get(),
|
"homepage_url": SingletonURLCache.get_url(HomePage),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.template import Library
|
from django.template import Library
|
||||||
|
|
||||||
|
from website.contrib.singleton_url.utils import SingletonURLCache
|
||||||
from website.home.models import HomePage
|
from website.home.models import HomePage
|
||||||
from website.search.models import SearchPage
|
from website.search.models import SearchPage
|
||||||
|
|
||||||
|
@ -16,5 +17,5 @@ def navbar() -> dict:
|
||||||
.public()
|
.public()
|
||||||
.filter(show_in_menus=True)
|
.filter(show_in_menus=True)
|
||||||
.order_by("title"),
|
.order_by("title"),
|
||||||
"search_page": SearchPage.objects.defer_streamfields().first(),
|
"search_page_url": SingletonURLCache.get_url(SearchPage),
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ from wagtail.images.models import Image
|
||||||
from wagtailmetadata.models import WagtailImageMetadataMixin
|
from wagtailmetadata.models import WagtailImageMetadataMixin
|
||||||
|
|
||||||
from website.common.models import BasePage
|
from website.common.models import BasePage
|
||||||
|
from website.contrib.singleton_url.utils import SingletonURLCache
|
||||||
|
|
||||||
|
|
||||||
class HomePage(BasePage, WagtailImageMetadataMixin):
|
class HomePage(BasePage, WagtailImageMetadataMixin):
|
||||||
|
@ -48,5 +49,5 @@ class HomePage(BasePage, WagtailImageMetadataMixin):
|
||||||
.order_by("-date")
|
.order_by("-date")
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
context["search_page"] = SearchPage.objects.defer_streamfields().first()
|
context["search_page_url"] = SingletonURLCache.get_url(SearchPage)
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<main {% if page.image %}style="background-image: url({% image_url page.image 'width-1200' %})"{% endif %}>
|
<main {% if page.image %}style="background-image: url({% image_url page.image 'width-1200' %})"{% endif %}>
|
||||||
<div class="heading-wrapper">
|
<div class="heading-wrapper">
|
||||||
<h1>{{ page.heading }}</h1>
|
<h1>{{ page.heading }}</h1>
|
||||||
{% if search_page %}
|
{% if search_page_url %}
|
||||||
<form action="{% pageurl search_page %}">
|
<form action="{{ search_page_url }}">
|
||||||
<input id="search-input" class="input" type="text" placeholder="Search" name="q">
|
<input id="search-input" class="input" type="text" placeholder="Search" name="q">
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{% load wagtailcore_tags %}
|
{% if contact_page_url %}
|
||||||
{% if contact_page %}
|
Contact: {{ contact_page_url }}
|
||||||
Contact: {% pageurl contact_page %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
Canonical: {{ security_txt }}
|
Canonical: {{ security_txt }}
|
||||||
Expires: {{ expires }}
|
Expires: {{ expires }}
|
||||||
|
|
|
@ -8,6 +8,7 @@ from django.views.decorators.cache import cache_page
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from website.contact.models import ContactPage
|
from website.contact.models import ContactPage
|
||||||
|
from website.contrib.singleton_url.utils import SingletonURLCache
|
||||||
|
|
||||||
|
|
||||||
class SecurityView(TemplateView):
|
class SecurityView(TemplateView):
|
||||||
|
@ -23,7 +24,7 @@ class SecurityView(TemplateView):
|
||||||
def get_context_data(self, **kwargs: dict) -> dict:
|
def get_context_data(self, **kwargs: dict) -> dict:
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["security_txt"] = self.request.build_absolute_uri(self.request.path)
|
context["security_txt"] = self.request.build_absolute_uri(self.request.path)
|
||||||
context["contact_page"] = ContactPage.objects.first()
|
context["contact_page_url"] = SingletonURLCache.get_url(ContactPage)
|
||||||
context["expires"] = (
|
context["expires"] = (
|
||||||
(timezone.now() + self.expires).replace(microsecond=0).isoformat()
|
(timezone.now() + self.expires).replace(microsecond=0).isoformat()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue