diff --git a/templates/sitemap.xml b/templates/sitemap.xml index 5a29cf8..869a1cd 100644 --- a/templates/sitemap.xml +++ b/templates/sitemap.xml @@ -1,8 +1,29 @@ - + - + https://snipt.net/api/ + monthly + 1.0 + + https://snipt.net/todo/ + daily + 1.0 + + + https://snipt.net/public/ + always + 1.0 + + + https://blog.snipt.net/ + weekly + 1.0 + + {% for tag in tags %} + + https://snipt.net/public/tag/{{ tag.slug }} + 0.9 + + {% endfor %} diff --git a/views.py b/views.py index 57d1f99..83d92ec 100644 --- a/views.py +++ b/views.py @@ -2,13 +2,21 @@ from django.shortcuts import render_to_response from annoying.decorators import ajax_request from django.template import RequestContext from snipts.utils import get_lexers_list +from django.db.models import Count +from taggit.models import Tag def sitemap(request): + + tags = Tag.objects.filter(snipt__public=True) + tags = tags.annotate(count=Count('taggit_taggeditem_items__id')) + tags = tags.order_by('-count')[:20] + tags = sorted(tags, key=lambda tag: tag.name) + return render_to_response('sitemap.xml', - {}, - context_instance=RequestContext(request), - mimetype='application/xml') + {'tags': tags}, + context_instance=RequestContext(request), + mimetype='application/xml') @ajax_request def lexers(request):