Sitemaps for page that should be public viewable
This commit is contained in:
@@ -1,31 +1,23 @@
|
|||||||
"""Add News and static pages to the global sitemap."""
|
"""Add News and static pages to the global sitemap."""
|
||||||
from django.contrib.sitemaps import Sitemap
|
from kasu.sitemaps import GenericSitemap
|
||||||
from .models import Article, Page
|
from .models import Article, Page
|
||||||
|
|
||||||
|
|
||||||
class ArticleSitemap(Sitemap):
|
class ArticleSitemap(GenericSitemap):
|
||||||
"""Add the news artivles to the Sitemap"""
|
"""Add all published news articles to the Sitemap."""
|
||||||
changefreq = "never"
|
min_priority = 0.25
|
||||||
priority = 0.6
|
|
||||||
|
|
||||||
def items(self):
|
@staticmethod
|
||||||
|
def items():
|
||||||
"""only add published articles to the sitemap"""
|
"""only add published articles to the sitemap"""
|
||||||
return Article.objects.published()
|
return Article.objects.published()
|
||||||
|
|
||||||
def lastmod(self, article):
|
|
||||||
"""return the last modification date of the article."""
|
|
||||||
return article.date_modified
|
|
||||||
|
|
||||||
|
class PageSitemap(GenericSitemap):
|
||||||
class PageSitemap(Sitemap):
|
|
||||||
"""add the static pages to the sitemap."""
|
"""add the static pages to the sitemap."""
|
||||||
changefreq = "monthly"
|
min_priority = 0.5
|
||||||
priority = 0.4
|
|
||||||
|
|
||||||
def items(self):
|
@staticmethod
|
||||||
|
def items():
|
||||||
"""add all pages to the sitemap."""
|
"""add all pages to the sitemap."""
|
||||||
return Page.objects.all()
|
return Page.objects.all()
|
||||||
|
|
||||||
def lastmod(self, page):
|
|
||||||
"""return the last modification date of the page."""
|
|
||||||
return page.date_modified
|
|
||||||
|
|||||||
@@ -1,23 +1,16 @@
|
|||||||
"""To geneate a Sitemap with all events."""
|
"""To geneate a Sitemap with all events."""
|
||||||
from django.contrib.sitemaps import Sitemap
|
from kasu.sitemaps import GenericSitemap
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from .models import Event
|
from .models import Event
|
||||||
|
|
||||||
|
|
||||||
class EventSitemap(Sitemap):
|
class EventSitemap(GenericSitemap):
|
||||||
"""To add an event to the global sitemap."""
|
"""sitemap to help indexing all events on this site."""
|
||||||
changefreq = "never"
|
changefreq = "never"
|
||||||
protocol = 'https'
|
protocol = 'https'
|
||||||
|
priority_field = 'start'
|
||||||
|
|
||||||
def items(self):
|
@staticmethod
|
||||||
"""add all events to the sitemap."""
|
def items():
|
||||||
|
"""add all upcoming and archived events to the sitemap."""
|
||||||
return Event.objects.all()
|
return Event.objects.all()
|
||||||
|
|
||||||
def priority(self, event):
|
|
||||||
"""give events closer to the present a higer priority for crawlers."""
|
|
||||||
delta = abs((timezone.now() - event.start) / 300.0)
|
|
||||||
return max(1 - delta, 0.1)
|
|
||||||
|
|
||||||
def lastmod(self, event):
|
|
||||||
"""return the last modification date."""
|
|
||||||
return event.date_modified
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% extends "events/event_detail.html" %}
|
{% extends "events/event_detail.html" %}
|
||||||
{% load i18n thumbnail %}
|
{% load i18n thumbnail %}
|
||||||
|
|
||||||
{% block title %}{{event.name}}{% endblock %}
|
{% block title %}{% trans "Photos" %}: {{ event.name }}{% endblock %}
|
||||||
|
|
||||||
{% block opengraph %}
|
{% block opengraph %}
|
||||||
<meta property="og:type" content="album" />
|
<meta property="og:type" content="album" />
|
||||||
|
|||||||
27
src/kasu/sitemaps.py
Normal file
27
src/kasu/sitemaps.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from django.contrib.sitemaps import Sitemap
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
|
class GenericSitemap(Sitemap):
|
||||||
|
changefreq = "never"
|
||||||
|
default_priority = 0.5
|
||||||
|
lastmod_field = 'date_modified'
|
||||||
|
min_priority = 0.1
|
||||||
|
priority_field = 'date_modified'
|
||||||
|
protocol = 'https'
|
||||||
|
|
||||||
|
def lastmod(self, entry):
|
||||||
|
"""return the last modification date."""
|
||||||
|
return getattr(entry, self.lastmod_field)
|
||||||
|
|
||||||
|
def priority(self, entry):
|
||||||
|
"""
|
||||||
|
Set a priority hint for crawlers.
|
||||||
|
hightes priority = 1, lowest priority = 0.1, normal priority = 0.5
|
||||||
|
updatet entries in the next/past 30 days (a month) should have a normal
|
||||||
|
priority. The nearer to the present day the higher the priority should
|
||||||
|
be.
|
||||||
|
"""
|
||||||
|
delta = timezone.now() - getattr(entry, self.priority_field)
|
||||||
|
priority = round(1 - abs(self.default_priority / 30 * delta.days), 2)
|
||||||
|
return max(self.min_priority, priority)
|
||||||
File diff suppressed because one or more lines are too long
@@ -3,5 +3,4 @@ Sitemap: https://kasu.at/sitemap.xml
|
|||||||
Disallow: /admin/
|
Disallow: /admin/
|
||||||
Disallow: /cgi-bin/
|
Disallow: /cgi-bin/
|
||||||
Disallow: /users/
|
Disallow: /users/
|
||||||
Disallow: /ranking/
|
Host: kasu.at
|
||||||
Host: kasu.at
|
|
||||||
|
|||||||
@@ -10,11 +10,17 @@ from content import views, feeds
|
|||||||
from content.sitemaps import ArticleSitemap, PageSitemap
|
from content.sitemaps import ArticleSitemap, PageSitemap
|
||||||
from events.sitemaps import EventSitemap
|
from events.sitemaps import EventSitemap
|
||||||
from events.views import EventListIcal
|
from events.views import EventListIcal
|
||||||
|
from mahjong_ranking.sitemaps import *
|
||||||
|
from maistar_ranking.sitemaps import *
|
||||||
from membership.views import MembershipDetail
|
from membership.views import MembershipDetail
|
||||||
|
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
sitemaps = { # Ignore PyLintBear (C0103)
|
sitemaps = {
|
||||||
|
'event_rankings': EventRankingSitemap,
|
||||||
|
'event_hanchans': EventHanchanSitemap,
|
||||||
|
'mahjong_seasons': MajongSeasonSitemap,
|
||||||
|
'maistar_games': MaistarGamesSitemap,
|
||||||
'articles': ArticleSitemap,
|
'articles': ArticleSitemap,
|
||||||
'events': EventSitemap,
|
'events': EventSitemap,
|
||||||
'pages': PageSitemap,
|
'pages': PageSitemap,
|
||||||
@@ -68,4 +74,5 @@ if settings.DEBUG:
|
|||||||
urlpatterns += [url(r'^rosetta/', include('rosetta.urls'))]
|
urlpatterns += [url(r'^rosetta/', include('rosetta.urls'))]
|
||||||
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
|
|
||||||
urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls)), ]
|
urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls)), ]
|
||||||
|
|||||||
17
src/maistar_ranking/sitemaps.py
Normal file
17
src/maistar_ranking/sitemaps.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
"""To geneate a Sitemap with all events."""
|
||||||
|
from kasu.sitemaps import GenericSitemap
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.urls import reverse
|
||||||
|
from events.models import Event
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MaistarGamesSitemap(GenericSitemap):
|
||||||
|
@staticmethod
|
||||||
|
def items():
|
||||||
|
"""add all upcoming and archived events to the sitemap."""
|
||||||
|
return Event.objects.all().exclude(maistargame_set=None)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def location(event):
|
||||||
|
return reverse('maistar-game-list', kwargs={'event': event.id})
|
||||||
Reference in New Issue
Block a user