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

Update DJ Press 0.14 and include new sitemaps feature #160

Merged
merged 1 commit into from
Nov 28, 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
1 change: 1 addition & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sitemaps",
"djpress.apps.DjpressConfig",
"timezone_converter",
"markdown_editor",
Expand Down
28 changes: 28 additions & 0 deletions config/sitemaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Sitemap for stuartm.nz."""

from django.contrib.sitemaps import Sitemap
from django.urls import reverse


class StaticSitemap(Sitemap):
"""Sitemap for stuartm.nz."""

changefreq = "monthly"
protocol = "https"

def items(self) -> list:
"""Return a list of URL names that you want to include."""
return [
"timezone_converter:converter",
"markdown_editor:markdown_editor",
"spf_generator:spf_generator",
"home:home",
]

def location(self, item: str) -> str:
"""Generate the URL for each item using Django's reverse."""
return reverse(item)

def lastmod(self, _: dict) -> None:
"""Return the last modification time for each item."""
return
18 changes: 18 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@

from django.conf import settings
from django.contrib import admin
from django.contrib.sitemaps.views import sitemap
from django.urls import include, path
from django.views.generic import TemplateView
from djpress.sitemaps import (
CategorySitemap,
DateBasedSitemap,
PageSitemap,
PostSitemap,
)

from config.sitemaps import StaticSitemap

sitemaps = {
"posts": PostSitemap,
"pages": PageSitemap,
"categories": CategorySitemap,
"archives": DateBasedSitemap,
"static": StaticSitemap,
}

urlpatterns = []

Expand All @@ -22,5 +39,6 @@
path("utils/spf/", view=include("spf_generator.urls")),
path("utils/home/", view=include("home.urls")),
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
path("sitemap.xml", sitemap, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.sitemap"),
path("", include("djpress.urls")),
]
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "stuartm-nz"
version = "0.13.0"
version = "0.14.0"
description = "stuartm.nz"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"django-environ>=0.11.2",
"django~=5.1.0",
"djpress~=0.13.0",
"djpress~=0.14.0",
"whitenoise>=6.7.0",
"gunicorn>=23.0.0",
"rich>=13.8.1",
Expand Down
10 changes: 5 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.