tornado/demos/blog/templates/feed.xml

27 lines
1.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
{% set date_format = "%Y-%m-%dT%H:%M:%SZ" %}
<title>{{ handler.settings["blog_title"] }}</title>
{% if len(entries) > 0 %}
<updated>{{ max(e.updated for e in entries).strftime(date_format) }}</updated>
{% else %}
<updated>{{ datetime.datetime.utcnow().strftime(date_format) }}</updated>
{% end %}
<id>http://{{ request.host }}/</id>
<link rel="alternate" href="http://{{ request.host }}/" title="{{ handler.settings["blog_title"] }}" type="text/html"/>
<link rel="self" href="{{ request.full_url() }}" title="{{ handler.settings["blog_title"] }}" type="application/atom+xml"/>
<author><name>{{ handler.settings["blog_title"] }}</name></author>
{% for entry in entries %}
<entry>
<id>http://{{ request.host }}/entry/{{ entry.slug }}</id>
<title type="text">{{ entry.title }}</title>
<link href="http://{{ request.host }}/entry/{{ entry.slug }}" rel="alternate" type="text/html"/>
<updated>{{ entry.updated.strftime(date_format) }}</updated>
<published>{{ entry.published.strftime(date_format) }}</published>
<content type="xhtml" xml:base="http://{{ request.host }}/">
<div xmlns="http://www.w3.org/1999/xhtml">{% raw entry.html %}</div>
</content>
</entry>
{% end %}
</feed>