Automatically discovered RSS feeds
Posted 2009-03-28 13:27:47 by .

Good News!

Getting a browser to discover your sites RSS feeds is really easy. You simply need to add a link tag with the url for of your site's feeds. In my case I currently have one feed.

 
<link rel="feed alternate" type="application/atom+xml"  href="/musings/feed" title="Source Weaver Musings. Articles on various subjects."/>

This goes into the base template of my site and is available on all pages. You should see the RSS logo or RSS feed text in your browsers address bar. This works in Firefox, Safari or Internet Explorer (7+).

References:

 

Generating the feed for my site was also very easy. I use Pylons and it provides the WebHelpers module containing the feedgenerator. Have a look here for details. I generate my main feed based on this example. My version of this includes the "pubdate" field needed in the real world. Without this feed readers will keep thinking the current articles are new, each time they read the feed.

 

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from webhelpers.feedgenerator import Atom1Feed

def feed(self):
"""Create the RSS feed for this blog :)
"""
posts = post.find()

feed = Atom1Feed(
title=u"The Source Weaver Stream",
link=url_for('musings-feed'),
description=u"Oisin's musings on various subjects.",
language=u"en",
)

def add(p):
"""Generate a feed entry :)
"""
# url_for needs non unicode strings:
slug = p.slug.encode('utf8')

feed.add_item(
title=p.title,
link=url_for('/posts/%s' % slug),
description="%s..."% (p.body[:300]),
pubdate=p.created,
author_name=p.author
)

[add(p) for p in posts]

response.content_type = 'application/atom+xml'

return feed.writeString('utf-8')
 

Comments

On 2010-08-15 19:24:49 Oisin Mulvihill (http://www.foldingsoftware.com) wrote:
Just checking comments are up and ready.
Commenting is currently disabled on this post.