keep archive per year, don't call it archive
This commit is contained in:
parent
d995ea0c6f
commit
cf2efd7fb3
8 changed files with 72 additions and 17 deletions
26
app/views.py
26
app/views.py
|
|
@ -31,15 +31,23 @@ def sitemap_xml(request):
|
|||
priority = ET.SubElement(url, "priority")
|
||||
priority.text = '1.0'
|
||||
|
||||
url = ET.SubElement(urlset, "url")
|
||||
loc = ET.SubElement(url, "loc")
|
||||
loc.text = request.build_absolute_uri('/archive/')
|
||||
lastmod = ET.SubElement(url, "lastmod")
|
||||
lastmod.text = now.strftime("%Y-%m-%d")
|
||||
changefreq = ET.SubElement(url, "changefreq")
|
||||
changefreq.text = 'weekly'
|
||||
priority = ET.SubElement(url, "priority")
|
||||
priority.text = '1.0'
|
||||
first = Item.objects.exclude(published=None).exclude(published__gt=now).order_by('published').first()
|
||||
if first:
|
||||
for year in reversed(range(first.published.year, now.year + 1)):
|
||||
url = ET.SubElement(urlset, "url")
|
||||
loc = ET.SubElement(url, "loc")
|
||||
loc.text = request.build_absolute_uri('/_%s/' % year)
|
||||
lastmod = ET.SubElement(url, "lastmod")
|
||||
changefreq = ET.SubElement(url, "changefreq")
|
||||
priority = ET.SubElement(url, "priority")
|
||||
if year == now.year:
|
||||
lastmod.text = now.strftime("%Y-%m-%d")
|
||||
changefreq.text = 'weekly'
|
||||
priority.text = '1.0'
|
||||
else:
|
||||
lastmod.text = now.strftime("%s-12-31" % year)
|
||||
changefreq.text = 'yearly'
|
||||
priority.text = '0.8'
|
||||
|
||||
for item in Item.objects.exclude(published=None).exclude(published__gt=now).order_by('-published'):
|
||||
url = ET.SubElement(urlset, "url")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue