Ticket #12347: sitemaps-urllist.patch

File sitemaps-urllist.patch, 1.2 KB (added by afurlan, 15 years ago)

django.contrib.sitemaps.views.urllist

  • django/contrib/sitemaps/views.py

     
    2222    xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})
    2323    return HttpResponse(xml, mimetype='application/xml')
    2424
    25 def sitemap(request, sitemaps, section=None):
     25def _get_urls(request, sitemaps, section=None):
    2626    maps, urls = [], []
    2727    if section is not None:
    2828        if section not in sitemaps:
     
    4141            raise Http404("Page %s empty" % page)
    4242        except PageNotAnInteger:
    4343            raise Http404("No page '%s'" % page)
     44    return urls
     45
     46def sitemap(request, sitemaps, section=None):
     47    urls = _get_urls(request, sitemaps, section)
    4448    xml = smart_str(loader.render_to_string('sitemap.xml', {'urlset': urls}))
    4549    return HttpResponse(xml, mimetype='application/xml')
     50
     51def urllist(request, sitemaps, section=None):
     52    urls = [url['location'] for url in _get_urls(request, sitemaps, section)]
     53    text = smart_str('\n'.join(urls))
     54    return HttpResponse(text, mimetype='text/plain')
Back to Top