Skip to content

Commit

Permalink
Add atom feed.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedouglas committed Aug 18, 2011
1 parent f8044c0 commit f158fac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/bamboo.rb
Expand Up @@ -33,6 +33,10 @@ def index(coll, name)
halt 307, {'Location' => 'http://github.com/mikedouglas'}, ''
end

get '/feed' do
Template.new('atom.xml').render({'posts' => @posts, 'site' => @site})
end

get '/posts' do
index @posts, 'posts'
end
Expand Down
26 changes: 26 additions & 0 deletions templates/atom.xml
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>entropy.io</title>
<link href="{{ site.url }}" />
<link type="application/atom+xml" rel="self" href="http://entropy.io/atom.xml" />
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}</id>
<author>
<name>{{ site.author }}</name>
<email>{{ site.email }}</email>
</author>

{% for post in site.posts %}
<entry>
<id>{{ site.url }}{{ post.url }}</id>
<link type="text/html" rel="alternative" href="{{ site.url }}{{ post.url }}" />
<title>{{ post.title }}</title>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<author>
<name>{{ site.author }}</name>
<uri>{{ site.url }}</uri>
</author>
<content type="html">{{ post.content | xml_escape }}</content>
</entry>
{% endfor %}
</feed>

0 comments on commit f158fac

Please sign in to comment.