-
Notifications
You must be signed in to change notification settings - Fork 1
Generate sitemaps XML #108
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||
| """Create sitemaps.""" | ||||||||
|
|
||||||||
| from django.contrib.sitemaps import Sitemap | ||||||||
| from django.urls import reverse | ||||||||
| from . import models | ||||||||
|
|
||||||||
| class AtlasSitemap(Sitemap): | ||||||||
| """Sitemap for Cell Atlas pages.""" | ||||||||
| changefreq = "weekly" | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||
| priority = 0.8 | ||||||||
|
|
||||||||
| def items(self): | ||||||||
| """Return list of species to include in the sitemap.""" | ||||||||
| return models.Dataset.objects.all() | ||||||||
|
|
||||||||
| def location(self, obj): | ||||||||
| """Return the URL for the main page of a species.""" | ||||||||
| return reverse('atlas_info', args=[obj.slug]) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||
|
|
||||||||
| def lastmod(self, obj): | ||||||||
| """ | ||||||||
| Return last modified date for the species page. | ||||||||
| Useful to state last update to search engines. | ||||||||
| """ | ||||||||
| return obj.date_updated | ||||||||
|
|
||||||||
|
|
||||||||
| class StaticViewSitemap(Sitemap): | ||||||||
| """Sitemap for static pages.""" | ||||||||
| changefreq = "monthly" | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||
| priority = 0.5 | ||||||||
|
|
||||||||
| def items(self): | ||||||||
| return ['atlas', 'downloads', 'about', 'entry', 'reference', 'api'] | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||
|
|
||||||||
| def location(self, item): | ||||||||
| return reverse(item) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,9 +4,16 @@ | |||||||||
| """ | ||||||||||
|
|
||||||||||
| from django.urls import path | ||||||||||
| from django.contrib.sitemaps.views import sitemap | ||||||||||
| from .sitemaps import StaticViewSitemap, AtlasSitemap | ||||||||||
|
|
||||||||||
| from . import views | ||||||||||
|
|
||||||||||
| sitemaps = { | ||||||||||
| 'static': StaticViewSitemap, | ||||||||||
| 'dataset': AtlasSitemap, | ||||||||||
|
Comment on lines
+13
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| urlpatterns = [ | ||||||||||
| path("", views.IndexView.as_view(), name="index"), | ||||||||||
| # Cell Atlas | ||||||||||
|
|
@@ -119,6 +126,8 @@ | |||||||||
| path("about/", views.AboutView.as_view(), name="about"), | ||||||||||
| path("search/", views.SearchView.as_view(), name="search"), | ||||||||||
| path("health/", views.HealthView.as_view(), name="health"), | ||||||||||
| path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='sitemap'), | ||||||||||
|
|
||||||||||
|
Comment on lines
+129
to
+130
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Super-Linter] reported by reviewdog 🐶
Suggested change
|
||||||||||
| # Error pages | ||||||||||
| path("403/", views.Custom403View.as_view()), | ||||||||||
| path("404/", views.Custom404View.as_view()), | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Super-Linter] reported by reviewdog 🐶