-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80ccb35
commit 0a5bfb1
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.contrib.sitemaps import Sitemap | ||
from django.urls import reverse | ||
|
||
from data_registry import models | ||
|
||
|
||
class StaticViewSitemap(Sitemap): | ||
i18n = True | ||
alternates = True | ||
protocol = "https" | ||
|
||
def items(self): | ||
return ["index", "search"] | ||
|
||
def location(self, item): | ||
return reverse(item) | ||
|
||
|
||
class CollectionSitemap(Sitemap): | ||
i18n = True | ||
alternates = True | ||
protocol = "https" | ||
|
||
# See data_registry.util.collection_queryset(). | ||
def items(self): | ||
return models.Collection.objects.visible() | ||
|
||
def location(self, item): | ||
return reverse("detail", kwargs={"id": item.pk}) | ||
|
||
def lastmod(self, obj): | ||
return obj.modified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
from django.contrib.sitemaps.views import sitemap | ||
from django.urls import path | ||
|
||
from data_registry import i18n, views | ||
from data_registry import i18n, sitemaps, views | ||
|
||
maps = { | ||
"static": sitemaps.StaticViewSitemap, | ||
"detail": sitemaps.CollectionSitemap, | ||
} | ||
|
||
urlpatterns = [ | ||
path("", views.index, name="index"), | ||
path("search/", views.search, name="search"), | ||
path("publication/<int:id>", views.detail, name="detail"), | ||
path("publication/<int:id>/download", views.download_export, name="download"), | ||
# https://code.djangoproject.com/ticket/26556 | ||
path("i18n/setlang/", i18n.set_language, name="set-language"), | ||
# Uncomment after re-integrating Spoonbill. | ||
# path("excel-data/<int:job_id>/<str:job_range>", views.excel_data, name="excel-data"), | ||
# path("excel-data/<int:job_id>", views.excel_data, name="all-excel-data"), | ||
# https://code.djangoproject.com/ticket/26556 | ||
path("i18n/setlang/", i18n.set_language, name="set-language"), | ||
path("sitemap.xml", sitemap, {"sitemaps": maps}, name="django.contrib.sitemaps.views.sitemap"), | ||
] |