diff --git a/django/contrib/sitemaps/tests/basic.py b/django/contrib/sitemaps/tests/basic.py
index 775e0d9..bee5676 100644
|
a
|
b
|
class SitemapTests(TestCase):
|
| 182 | 182 | return isinstance(url['item'], User) |
| 183 | 183 | item_in_url_info = all(map(is_user, user_sitemap.get_urls())) |
| 184 | 184 | self.assertTrue(item_in_url_info) |
| | 185 | |
| | 186 | def test_cached_sitemap_index(self): |
| | 187 | "A cached sitemap index can be rendered" |
| | 188 | # Retrieve the sitemap. |
| | 189 | response = self.client.get('/cached/index.xml') |
| | 190 | # Check for all the important bits: |
| | 191 | self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?> |
| | 192 | <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> |
| | 193 | <sitemap><loc>%s/cached/sitemap-simple.xml</loc></sitemap> |
| | 194 | </sitemapindex> |
| | 195 | """ % self.base_url) |
diff --git a/django/contrib/sitemaps/tests/urls.py b/django/contrib/sitemaps/tests/urls.py
index c264f94..2ebad20 100644
|
a
|
b
|
|
| 1 | 1 | from datetime import datetime |
| 2 | | from django.conf.urls import patterns |
| | 2 | from django.conf.urls import patterns, url |
| 3 | 3 | from django.contrib.sitemaps import Sitemap, GenericSitemap, FlatPageSitemap |
| 4 | 4 | from django.contrib.auth.models import User |
| | 5 | from django.views.decorators.cache import cache_page |
| | 6 | from django.contrib.sitemaps import views |
| 5 | 7 | |
| 6 | 8 | class SimpleSitemap(Sitemap): |
| 7 | 9 | changefreq = "never" |
| … |
… |
urlpatterns = patterns('django.contrib.sitemaps.views',
|
| 34 | 36 | (r'^simple/custom-sitemap\.xml$', 'sitemap', {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}), |
| 35 | 37 | (r'^generic/sitemap\.xml$', 'sitemap', {'sitemaps': generic_sitemaps}), |
| 36 | 38 | (r'^flatpages/sitemap\.xml$', 'sitemap', {'sitemaps': flatpage_sitemaps}), |
| | 39 | (r'^cached/index\.xml$', cache_page(views.index, 1), { |
| | 40 | 'sitemaps': simple_sitemaps, |
| | 41 | 'sitemap_url_name': 'sitemaps.views.sitemap' |
| | 42 | }), |
| | 43 | url(r'^cached/sitemap-(?P<section>.+)\.xml', |
| | 44 | cache_page(views.sitemap, 1), { |
| | 45 | 'sitemaps': simple_sitemaps |
| | 46 | }, |
| | 47 | name='sitemaps.views.sitemap') |
| 37 | 48 | ) |
diff --git a/django/contrib/sitemaps/views.py b/django/contrib/sitemaps/views.py
index d82146c..8a3c041 100644
|
a
|
b
|
from django.template.response import TemplateResponse
|
| 6 | 6 | from django.contrib.sites.models import get_current_site |
| 7 | 7 | |
| 8 | 8 | def index(request, sitemaps, |
| 9 | | template_name='sitemap_index.xml', mimetype='application/xml'): |
| | 9 | template_name='sitemap_index.xml', mimetype='application/xml', |
| | 10 | sitemap_url_name='django.contrib.sitemaps.views.sitemap'): |
| 10 | 11 | current_site = get_current_site(request) |
| 11 | 12 | sites = [] |
| 12 | 13 | protocol = request.is_secure() and 'https' or 'http' |
| … |
… |
def index(request, sitemaps,
|
| 16 | 17 | pages = site().paginator.num_pages |
| 17 | 18 | else: |
| 18 | 19 | pages = site.paginator.num_pages |
| 19 | | sitemap_url = urlresolvers.reverse('django.contrib.sitemaps.views.sitemap', kwargs={'section': section}) |
| | 20 | sitemap_url = urlresolvers.reverse(sitemap_url_name, kwargs={'section': section}) |
| 20 | 21 | sites.append('%s://%s%s' % (protocol, current_site.domain, sitemap_url)) |
| 21 | 22 | if pages > 1: |
| 22 | 23 | for page in range(2, pages+1): |