First attempt at creating per-category Atom feeds. #201

Merged
merged 2 commits into from Oct 16, 2011

2 participants

@mikl

One of the things I've missed from Octopress is per-category RSS/Atom feeds. Many open source projects have "planet" sites where they aggregate community blogs, but they want a feed of only the relevant posts – Planet Drupal only wants posts about Drupal, for example.

This is my first Ruby code ever, so I more or less expect that I've done something horrible here, but it does work, and I'm currently in the process of deploying it to my own blog.

So I'd really like to hear how this could be improved :)

@mikl mikl commented on the diff Oct 4, 2011
...mes/classic/source/_includes/custom/category_feed.xml
+ <link href="{{ site.url }}/"/>
+ <updated>{{ site.time | date_to_xmlschema }}</updated>
+ <id>{{ site.url }}/</id>
+ <author>
+ <name><![CDATA[{{ site.author | strip_html }}]]></name>
+ {% if site.email %}<email><![CDATA[{{ site.email }}]]></email>{% endif %}
+ </author>
+ <generator uri="http://octopress.org/">Octopress</generator>
+
+ {% for post in site.categories[page.category] limit: 5 %}
+ <entry>
+ <title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title>
+ <link href="{{ site.url }}{{ post.url }}"/>
+ <updated>{{ post.date | date_to_xmlschema }}</updated>
+ <id>{{ site.url }}{{ post.id }}</id>
+ <content type="html"><![CDATA[{{ post.content | expand_urls: site.url | markdownify | cdata_escape }}]]></content>
@mikl
mikl added a line comment Oct 4, 2011

I had to add markdownify here to get my content rendered properly. This confounds me, since the other templates that I've looked at didn't have to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fhemberger fhemberger merged commit d84daa2 into imathis:master Oct 16, 2011
@fhemberger

Cool feature, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment