Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12347 -- Added a mimetype option to sitemaps views to further …

…customize the output of the view, e.g. to support Yahoo's plain text urllist format. Thanks, afurlan.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16475 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 60f0421ed3ea16ba78545eeabcde7a3dcdcb7cdd 1 parent 3fe0c69
Jannis Leidel authored June 28, 2011

Showing 1 changed file with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. 10  django/contrib/sitemaps/views.py
10  django/contrib/sitemaps/views.py
@@ -5,7 +5,8 @@
5 5
 from django.utils.encoding import smart_str
6 6
 from django.core.paginator import EmptyPage, PageNotAnInteger
7 7
 
8  
-def index(request, sitemaps, template_name='sitemap_index.xml'):
  8
+def index(request, sitemaps,
  9
+        template_name='sitemap_index.xml', mimetype='application/xml'):
9 10
     current_site = get_current_site(request)
10 11
     sites = []
11 12
     protocol = request.is_secure() and 'https' or 'http'
@@ -21,9 +22,10 @@ def index(request, sitemaps, template_name='sitemap_index.xml'):
21 22
             for page in range(2, pages+1):
22 23
                 sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
23 24
     xml = loader.render_to_string(template_name, {'sitemaps': sites})
24  
-    return HttpResponse(xml, mimetype='application/xml')
  25
+    return HttpResponse(xml, mimetype=mimetype)
25 26
 
26  
-def sitemap(request, sitemaps, section=None, template_name='sitemap.xml'):
  27
+def sitemap(request, sitemaps, section=None,
  28
+        template_name='sitemap.xml', mimetype='application/xml'):
27 29
     maps, urls = [], []
28 30
     if section is not None:
29 31
         if section not in sitemaps:
@@ -43,4 +45,4 @@ def sitemap(request, sitemaps, section=None, template_name='sitemap.xml'):
43 45
         except PageNotAnInteger:
44 46
             raise Http404("No page '%s'" % page)
45 47
     xml = smart_str(loader.render_to_string(template_name, {'urlset': urls}))
46  
-    return HttpResponse(xml, mimetype='application/xml')
  48
+    return HttpResponse(xml, mimetype=mimetype)

0 notes on commit 60f0421

Please sign in to comment.
Something went wrong with that request. Please try again.