summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--settings.py1
-rw-r--r--sitemaps.py25
-rw-r--r--urls.py8
3 files changed, 34 insertions, 0 deletions
diff --git a/settings.py b/settings.py
index e94f350..d97c785 100644
--- a/settings.py
+++ b/settings.py
@@ -69,6 +69,7 @@ INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
+ 'django.contrib.sitemaps',
'django.contrib.admin',
'archweb.main', # contains shared models and libs
'archweb.news',
diff --git a/sitemaps.py b/sitemaps.py
new file mode 100644
index 0000000..9e2ef85
--- /dev/null
+++ b/sitemaps.py
@@ -0,0 +1,25 @@
+from django.contrib.sitemaps import Sitemap
+from archweb.main.models import Package, News
+
+class PackagesSitemap(Sitemap):
+ changefreq = "monthly"
+ priority = "0.4"
+
+ def items(self):
+ return Package.objects.all()
+
+ def lastmod(self, obj):
+ return obj.last_update
+
+class NewsSitemap(Sitemap):
+ changefreq = "never"
+ priority = "0.7"
+
+ def items(self):
+ return News.objects.all()
+
+ def lastmod(self, obj):
+ return obj.postdate
+
+# vim: set ts=4 sw=4 et:
+
diff --git a/urls.py b/urls.py
index 0fda8d5..7a870ea 100644
--- a/urls.py
+++ b/urls.py
@@ -8,6 +8,7 @@ from django.contrib.auth.decorators import permission_required
from archweb.main.models import Todolist
from archweb.feeds import PackageFeed, NewsFeed
+from archweb.sitemaps import NewsSitemap, PackagesSitemap
feeds = {
@@ -15,6 +16,11 @@ feeds = {
'news': NewsFeed
}
+sitemaps = {
+ 'news': NewsSitemap,
+ 'packages': PackagesSitemap,
+}
+
admin.autodiscover()
urlpatterns = patterns('',
@@ -60,6 +66,8 @@ urlpatterns = patterns('',
# Feeds and sitemaps
(r'^feeds/(?P<url>.*)/$',
'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
+ (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap',
+ {'sitemaps': sitemaps}),
# Authentication / Admin
(r'^login/$', 'django.contrib.auth.views.login', {