diff options
author | Ismael Carnales <icarnales@gmail.com> | 2009-10-30 19:36:42 -0200 |
---|---|---|
committer | Ismael Carnales <icarnales@gmail.com> | 2009-11-09 22:24:45 -0200 |
commit | c1a197d29a692b7066ad12026f4bb9e92172f6b4 (patch) | |
tree | 7478f1c2a6f90c5d42c04ab5dd6f40c7cc9521d6 | |
parent | 19f0a3fb57e53977d1f2017033f0714a8cfc8779 (diff) |
added sitemaps from archweb_pub
-rw-r--r-- | settings.py | 1 | ||||
-rw-r--r-- | sitemaps.py | 25 | ||||
-rw-r--r-- | urls.py | 8 |
3 files changed, 34 insertions, 0 deletions
diff --git a/settings.py b/settings.py index e94f3505..d97c7857 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 00000000..9e2ef856 --- /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: + @@ -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', { |