# Atom Feeds

**URL:** <https://www.ruby-forum.com/t/atom-feeds/87759>\
**Category:** Radiant CMS\
**Created:** [March 5, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/atom-feeds/87759 "2007-03-05T20:21:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 5, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/atom-feeds/87759/1 "2007-03-05T20:21:38Z")

</div>

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

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 5, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/atom-feeds/87759/2 "2007-03-05T20:27:39Z")

</div>

> 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-](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/](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](http://seansantry.com)\<r:url /\>  
\<r:escape\_html\>\<r:content /\>\</  
r:escape\_html\>  
  
\</r:children:each\>  
\</r:find\>

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 5, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/atom-feeds/87759/3 "2007-03-05T21:05:47Z")

</div>

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-](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](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 5, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/atom-feeds/87759/4 "2007-03-05T21:23:51Z")

</div>

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](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 6, 2007, 12:07am UTC](https://www.ruby-forum.com/t/atom-feeds/87759/5 "2007-03-06T00:07:15Z")

</div>

> 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](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\>

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 6, 2007, 12:08am UTC](https://www.ruby-forum.com/t/atom-feeds/87759/6 "2007-03-06T00:08:15Z")

</div>

> ```
> <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.

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 5, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/atom-feeds/87759/7 "2007-03-05T21:15:49Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 6, 2007, 6:59am UTC](https://www.ruby-forum.com/t/atom-feeds/87759/8 "2007-03-06T06:59:47Z")

</div>

On 3/5/07, Daniel S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](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

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [March 6, 2007, 8:03am UTC](https://www.ruby-forum.com/t/atom-feeds/87759/9 "2007-03-06T08:03:52Z")

</div>

> 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](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.
