Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
fix bug 780740 - Creates sitemap.xml for MDN
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing authored and groovecoder committed Sep 24, 2012
1 parent 02237bb commit db8ed07
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
16 changes: 16 additions & 0 deletions apps/wiki/sitemap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.contrib.sitemaps import Sitemap
from wiki.models import (Document, Revision)

class DocumentSitemap(Sitemap):
changefreq = 'weekly'
priority = 0.5

def items(self):
docs = Document.objects.filter(is_template=False)
return docs

def lastmod(self, doc):
return doc.current_revision.created

def location(self, doc):
return doc.get_absolute_url()
4 changes: 3 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def lazy_language_deki_map():
ADMIN_MEDIA_PREFIX = '/admin-media/'

# Paths that don't require a locale prefix.
SUPPORTED_NONLOCALES = ('media', 'admin', 'robots.txt', 'services', '1', 'files', '@api')
SUPPORTED_NONLOCALES = ('sitemap.xml', 'media', 'admin', 'robots.txt', 'services',
'1', 'files', '@api', )

# Make this unique, and don't share it with anybody.
SECRET_KEY = '#%tc(zja8j01!r#h_y)=hy!^k)9az74k+-ib&ij&+**s3-e^_z'
Expand Down Expand Up @@ -367,6 +368,7 @@ def lazy_language_deki_map():
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.sitemaps',

# BrowserID
'django_browserid',
Expand Down
8 changes: 8 additions & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.shortcuts import redirect
from django.views.i18n import javascript_catalog
from django.views.decorators.cache import cache_page
from wiki.sitemap import DocumentSitemap

import authority
import jingo
Expand All @@ -12,6 +13,10 @@
admin.autodiscover()
authority.autodiscover()

sitemaps = {
'documents': DocumentSitemap,
}

urlpatterns = patterns('',
# Home / landing pages:
('', include('landing.urls')),
Expand Down Expand Up @@ -69,6 +74,9 @@
# Users
('', include('users.urls')),

#Sitemap
(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', { 'sitemaps': sitemaps }),

# Services and sundry.
#(r'', include('sumo.urls')),
(r'^humans.txt$', 'django.views.static.serve',
Expand Down

0 comments on commit db8ed07

Please sign in to comment.