Fork me on GitHub

RSS feed

An article by Gaspard Bucher

Related: Node-atom-xml


Some users like to be informed of changes on your site through RSS syndication. Offering such a possibility is very simple in zena:

Let’s take the most common example: inform about new posts in a blog.

First you must create a template to display the list of recent posts in a format that feed readers can understand. You can choose between RSS and atom. In this example, we shall use RSS. The format is pretty straightforward: it’s an xml file with a list of dated entries.

You may simply import the attached Project—rss template. The zafu is for the “Project” class scope in ”.rss” format (Project--rss.zafu).

The lines that actually fetch the latest posts are the ‘r:posts’ lines, e.g.:

<r:posts in='project' limit='20' order='date desc' do='each'>

The rest is just to render markup and information.

telling browsers about your feed

You must add a “link” tag inside the head of your project pages:

<link rel="alternate" type="application/rss+xml" title="#{title}" name="rss_feed" href="http://#{}#{path}/project#{id}.rss"/>

If your browser supports it, you should now see a sign in your browser indicating that there is an RSS feed available.


A regular rss subscribe button within the page may be rendered with zafu like this (after adding img/rss.png to the template):

<a title='Subscribe to RSS feed.' href='http://#{}#{path}/project#{id}.rss'><img src='img/rss.png' alt='RSS'/></a>