Atom Feeds

Has anyone used Radiant to produce Atom feeds? If so what code did you
use?


John L.
http://wiseheartdesign.com

Has anyone used Radiant to produce Atom feeds? If so what code did
you use?

Long answer:

http://seansantry.com/development/articles/2006/12/15/creating-an-
atom-feed-in-radiant/

Short answer:

<?xml version="1.0" encoding="UTF-8"?> Sean S.

http://seansantry.com/
Radiant
CMS

Sean S. http://seansantry.com/

<r:find url=“/articles/”><r:children:each limit=“1”
order=“desc”><r:date format=“%Y-%m-%dT%H:%M:%SZ” /></
r:children:each></r:find>

<r:find url=“/articles/”>
<r:children:each limit=“10” order=“desc”>

<r:author />
<r:date format=“%Y-%m-%dT%H:%M:%SZ” />
<r:date format=“%Y-%m-%dT%H:%M:%SZ” />
<r:title />

http://seansantry.com<r:url />
<r:escape_html><r:content /></
r:escape_html>

</r:children:each>
</r:find>

Sean S. wrote:

Has anyone used Radiant to produce Atom feeds? If so what code did
you use?

Long answer:

http://seansantry.com/development/articles/2006/12/15/creating-an-
atom-feed-in-radiant/

Thanks Sean. That’s about what I worked out on my own.


John L.
http://wiseheartdesign.com

Sean S. wrote:

Thanks Sean. That’s about what I worked out on my own.

Is that approach working OK for you? Or did you run into some problem
that prompted the search for other solutions?

I was looking for a way to format the date correctly. I ended up doing
exactly what you did:

    <published><r:date format="%Y-%m-%dT%H:%M:%SZ" /></published>
    <updated><r:date format="%Y-%m-%dT%H:%M:%SZ" /></updated>

But the problem is the updated field is being set to the same thing as
the published field, which may or may not be correct. We need a tag that
exposes the updated_at field just like the date tag exposes
published_at.


John L.
http://wiseheartdesign.com

Has anyone used Radiant to produce Atom feeds? If so what
code did you use?

I’ve got a Page type that exposes all the data needed for an atom feed.

http://soxbox.no-ip.org/radiant/svn/extensions/x_groggy/app/models/atom_page.rb

There’s a few hard-coded things in there - Specifically in the ‘atom’
tag (choosing the pages to display) and atom:url tag (how do
you get the full url of a page including host?)

One thing to note is the updated_at (calculated in atom:each) - you
can’t have two pages with exactly the same updated time under
atom (which is a weird restriction if you ask me) - I make sure to keep
an eye on that and adjust if necessary (it bit me when I did
an automated update from my old system).

This is the actual content of the page. Note that you’d probably want to
serve up your content escaped, but I’m fairly anal about
maintaining valid content on my pages, so I didn’t bother with that.

<?xml version='1.0' encoding='UTF-8'?>

<r:atom>

The Groggy Squirrel http://www.thegroggysquirrel.com/ The Groggy Squirrel The Groggy Squirrel is an online guide to comedy in Melbourne and across Australia All content copyright to their respective authors. All rights reserved.

<r:each>

   <content type="html"><r:escape_html><r:content /></ 

r:escape_html>

Your content tag should have mode=“escaped” if it’s going to contain
escaped html.

Dan.

Thanks Sean. That’s about what I worked out on my own.

Is that approach working OK for you? Or did you run into some problem
that prompted the search for other solutions?

  • Sean

On 3/5/07, Daniel S. [email protected] wrote:

One thing to note is the updated_at (calculated in atom:each) - you can’t have two pages with exactly the same updated time under
atom (which is a weird restriction if you ask me) - I make sure to keep an eye on that and adjust if necessary (it bit me when I did
an automated update from my old system).

Are you sure about this? Since ATOM uses ids to mark the each entry,
it wouldn’t care if two entries are updated at the exact same time.
You just need to make sure to have two unique ids…granted if you are
using a time based id mechanism, then I would say you need to watch
out for this. Here is an article I found that helped me construct my
entry ids http://diveintomark.org/archives/2004/05/28/howto-atom-id.

And, I should have check this mailing list more often today…I was
building an atom feed today too.

Jason

Are you sure about this? Since ATOM uses ids to mark the each entry,
it wouldn’t care if two entries are updated at the exact same time.
You just need to make sure to have two unique ids…granted if you are
using a time based id mechanism, then I would say you need to watch
out for this. Here is an article I found that helped me construct my
entry ids http://diveintomark.org/archives/2004/05/28/howto-atom-id.

And, I should have check this mailing list more often today…I was
building an atom feed today too.

The feed validator complained when I did it, and I’m pretty sure that I
actually went and double-checked with the spec (though you
might want to do that yourself).

Dan.