Browse files

Added sitemap.xml

  • Loading branch information...
1 parent f4b561b commit ed0b1b3eaca3962574236b531b095fef8c372707 @gcollazo committed May 7, 2012
Showing with 22 additions and 1 deletion.
  1. +17 −0 angrytards/core/templates/sitemap.xml
  2. +4 −1 angrytards/core/views.py
  3. +1 −0 angrytards/urls.py
View
17 angrytards/core/templates/sitemap.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+ <url>
+ <loc>http://eldia.24veces.com/</loc>
+ <lastmod>{% now "Y-m-d" %}</lastmod>
+ <changefreq>daily</changefreq>
+ <priority>1.0</priority>
+ </url>
+ {% for story in stories %}
+ <url>
+ <loc>{{ story.comments }}</loc>
+ <lastmod>{% now "Y-m-d" %}</lastmod>
+ <changefreq>daily</changefreq>
+ <priority>0.2</priority>
+ </url>
+ {% endfor %}
+</urlset>
View
5 angrytards/core/views.py
@@ -38,7 +38,10 @@ def stories(request, format=None):
'comments_json': 'http://%s/story/%s/comments/1.json' % (request.META['HTTP_HOST'], story_id)
})
- return HttpResponse(json.dumps(stories), mimetype='application/json')
+ if format == 'xml':
+ return render(request, 'sitemap.xml', {'stories':stories}, content_type='application/xml')
+ else:
+ return HttpResponse(json.dumps(stories), mimetype='application/json')
def comments(request, story_id, page=None, format=None):
View
1 angrytards/urls.py
@@ -9,6 +9,7 @@
url(r'^api/$', 'views.api_doc', name='api_doc'),
url(r'^story/$', 'views.stories', name='stories'),
url(r'^story.(?P<format>json)$', 'views.stories', name='stories'),
+ url(r'^sitemap.(?P<format>xml)$', 'views.stories', name='stories'),
url(r'^story/(?P<story_id>\d+)/comments/$', 'views.comments', name='comments'),
url(r'^story/(?P<story_id>\d+)/comments/(?P<page>\d+)/$', 'views.comments', name='comments_page'),
url(r'^story/(?P<story_id>\d+)/comments/(?P<page>\d+).(?P<format>json)$', 'views.comments', name='comments_page'),

0 comments on commit ed0b1b3

Please sign in to comment.