colinta / StrangeCase

It's yet another static site generator. Have you seen jekyll? hyde? Yup. Like those.
http://colinta.com/projects/StrangeCase.html
Other
49 stars 7 forks source link

Is there a way to generate an RSS feed for the site automatically? #47

Closed sureshvv closed 12 years ago

sureshvv commented 12 years ago

nikola, a similar product, seems to have the capability.

colinta commented 12 years ago

It is certainly possible, but not with the amount of automation that nikola can boast.

StrangeCase is more than a blogging engine. Instead of focusing on "Posts" as the important unit of work, StrangeCase focuses on generic nodes. The default engine treats all files and folders as nodes.

It is relatively straightforward to create processors that can create nodes that are not based on the file structure (the "category" processor does just that). The only curveball that RSS throws in is that the amount of meta data is much greater. A category processor can get away with only requiring a category name. An RSS feed needs author, blurb, post date, etc.

That said, this is something I am told that I need for my own site, so I think I'll have at it. I'll let you know when it's ready!

colinta commented 12 years ago

Turns out, it's easier just to write a feed.xml file than to try and build an RSS plugin.


----
title: stuff by colinta
description: thoughts on programming
link: /thoughts/
items ->: site.thoughts
----
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>{{ my.title }}</title>
        <description>{{ my.description }}</description>
        <link>{{ site.host + my.link }}</link>
        <atom:link href="{{ site.host + my.url }}" rel="self" type="application/rss+xml" />
{% for item in my.items|reverse %}
        <item>
            <title>{{ item.title }}</title>
            <link>{{ site.host + item.url }}</link>
            <description><![CDATA[{{ item.blurb|markdown }}]]></description>
            <author>Colin Thomas-Arnold</author>
            <category>{{ item.category }}</category>
            <pubDate>{{ item.created_at|date("%a, %e %b %Y %X %z") }}</pubDate>
            <guid>{{ my.url|sha }}</guid>
        </item>
{% endfor %}
    </channel>
</rss>
colinta commented 12 years ago

Assumes you have a global config setting called "host". Adjust site.thoughts to point to your blog folder. You'll have to add a blurb, because StrangeCase has no way of accessing page content right now (not a trivial feature, either).

sureshvv commented 12 years ago

Good stuff! Will test it out. Thanks.

sureshvv commented 12 years ago

Amazingly the whole thing works!

colinta commented 12 years ago

Sweet! Glad to help (and glad to finally add an RSS feed to my own site!)