|
Revision 4789, 1.4 kB
(checked in by jacob, 2 years ago)
|
Vastly improved the djangoproject.com doc system; it now draws from SVN directly (i.e. no more need for a hourly cron builder).
|
| Line | |
|---|
| 1 |
from django.contrib.sitemaps import Sitemap |
|---|
| 2 |
from django_website.apps.blog.models import Entry |
|---|
| 3 |
from django.contrib.flatpages.models import FlatPage |
|---|
| 4 |
import datetime |
|---|
| 5 |
|
|---|
| 6 |
class FlatPageSitemap(Sitemap): |
|---|
| 7 |
""" |
|---|
| 8 |
We're not using the built-in django.contrib.sitemaps.FlatPageSitemap, |
|---|
| 9 |
because we're doing something different. Also, we only have one Site, |
|---|
| 10 |
so there's no need to check the site is current. |
|---|
| 11 |
""" |
|---|
| 12 |
def changefreq(self, obj): |
|---|
| 13 |
if obj.url.startswith('/documentation/0_90/') or obj.url.startswith('/documentation/0_91/'): |
|---|
| 14 |
return 'never' # Old documentation never changes. |
|---|
| 15 |
else: |
|---|
| 16 |
return 'weekly' |
|---|
| 17 |
|
|---|
| 18 |
def priority(self, obj): |
|---|
| 19 |
if obj.url.startswith('/documentation/0_90/') or obj.url.startswith('/documentation/0_91/'): |
|---|
| 20 |
return 0.1 # Old documentation gets a low priority. |
|---|
| 21 |
else: |
|---|
| 22 |
return 0.5 |
|---|
| 23 |
|
|---|
| 24 |
def items(self): |
|---|
| 25 |
return FlatPage.objects.all() |
|---|
| 26 |
|
|---|
| 27 |
# lastmod is not implemented, because we have no way of knowing |
|---|
| 28 |
# when FlatPages were last updated. |
|---|
| 29 |
|
|---|
| 30 |
class WeblogSitemap(Sitemap): |
|---|
| 31 |
changefreq = 'never' |
|---|
| 32 |
priority = 0.4 |
|---|
| 33 |
|
|---|
| 34 |
def items(self): |
|---|
| 35 |
return Entry.objects.filter(pub_date__lte=datetime.datetime.now()) |
|---|
| 36 |
|
|---|
| 37 |
# lastmod is not implemented, because weblog pages contain comments. |
|---|
| 38 |
# We'd rather not look up the date of the latest comment -- not worth the overhead. |
|---|