Commits

Jannis Leidel  committed 9cf5f59

Also pass the old SITEMAP_URL setting to the template for backwards compatibility.

  • Participants
  • Parent commits 076537e

Comments (0)

Files changed (2)

File robots/settings.py

+from warnings import warn
 from django.conf import settings
 
 #: A list of one or more sitemaps to inform robots about:
 
 # For backwards-compatibility, we'll automatically add a single URL
 # to the list:
-if hasattr(settings, 'ROBOTS_SITEMAP_URL'):
-    SITEMAP_URLS.append(settings.ROBOTS_SITEMAP_URL)
+SITEMAP_URL = getattr(settings,'ROBOTS_SITEMAP_URL', None)
+if SITEMAP_URL is not None:
+    warn("The ``SITEMAP_URL`` setting is deprecated. Use ``SITEMAP_URLS`` instead.",
+         PendingDeprecationWarning)
+    SITEMAP_URLS.append(SITEMAP_URL)
 
 USE_SITEMAP = getattr(settings, 'ROBOTS_USE_SITEMAP', True)
 

File robots/views.py

     scheme = request.is_secure() and 'https' or 'http'
     current_site = Site.objects.get_current()
 
+    sitemap_url = settings.SITEMAP_URL
     sitemap_urls = settings.SITEMAP_URLS
 
     if not sitemap_urls and settings.USE_SITEMAP:
                 pass
 
         if sitemap_url is not None:
-            sitemap_urls.append("%s://%s%s" % (scheme, current_site.domain, sitemap_url))
+            sitemap_url = "%s://%s%s" % (scheme, current_site.domain, sitemap_url)
+            sitemap_urls.append(sitemap_url)
 
     rules = Rule.objects.filter(sites=current_site)
 
     t = loader.get_template(template_name)
     c = RequestContext(request, {
         'rules': rules,
+        'sitemap_url': sitemap_url, # for old templates
         'sitemap_urls': sitemap_urls,
     })
     return HttpResponse(t.render(c), status=status_code, mimetype=mimetype)