Skip to content
Closed
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
37 changes: 37 additions & 0 deletions app/sitemaps.py
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):

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
class AtlasSitemap(Sitemap):
class AtlasSitemap(Sitemap):

"""Sitemap for Cell Atlas pages."""
changefreq = "weekly"

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
changefreq = "weekly"
changefreq = "weekly"

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])

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
return reverse('atlas_info', args=[obj.slug])
return reverse("atlas_info", args=[obj.slug])


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"

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
changefreq = "monthly"
changefreq = "monthly"

priority = 0.5

def items(self):
return ['atlas', 'downloads', 'about', 'entry', 'reference', 'api']

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
return ['atlas', 'downloads', 'about', 'entry', 'reference', 'api']
return ["atlas", "downloads", "about", "entry", "reference", "api"]


def location(self, item):
return reverse(item)

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
return reverse(item)
return reverse(item)

9 changes: 9 additions & 0 deletions app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
'static': StaticViewSitemap,
'dataset': AtlasSitemap,
"static": StaticViewSitemap,
"dataset": AtlasSitemap,

}

urlpatterns = [
path("", views.IndexView.as_view(), name="index"),
# Cell Atlas
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

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 🐶

Suggested change
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='sitemap'),
path("sitemap.xml", sitemap, {"sitemaps": sitemaps}, name="sitemap"),

# Error pages
path("403/", views.Custom403View.as_view()),
path("404/", views.Custom404View.as_view()),
Expand Down
3 changes: 3 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
ALLOWED_HOSTS = get_env("DJANGO_ALLOWED_HOSTS", "", type="array")
DEBUG = get_env("DJANGO_DEBUG", type="bool")
SECRET_KEY = get_env("DJANGO_SECRET_KEY")
SITE_ID = 1

if get_env("ENVIRONMENT") == "prod":
# Production environment
Expand Down Expand Up @@ -76,6 +77,8 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"django.contrib.sitemaps",
"rest_framework",
"django_filters",
"colorfield",
Expand Down
Loading