/ Published in: Groovy
Here's a quick block of code that adds a valid Atom feed to you Grails application. Validate here: http://feedvalidator.org/check?url=http://aboutgroovy.com/item/atom
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
params.order = 'desc' <title type="text">aboutGroovy.com</title> <link rel="alternate" type="text/html" href="http://aboutGroovy.com"/> <link rel="self" type="application/atom+xml" href="http://aboutGroovy.com/item/atom"/> <updated>2006-12-17T18:30:02Z</updated> <author><name>Scott Davis</name></author> <id>tag:aboutgroovy.com,2006-12-18:thisIsUnique</id> <generator uri="http://aboutGroovy.com" version="0.0.1">Hand-rolled Grails code</generator> """ x.entry(xmlns:"http://www.w3.org/2005/Atom"){ author{name("Scott Davis")} published(df.format(item.datePosted)) updated(df.format(item.datePosted)) link(href:"http://aboutGroovy.com/item/show/${item.id}", rel:"alternate", title:item.title, type:"text/html") id("tag:aboutgroovy.com,2006:/item/show/${item.id}") title(type:"text", item.title) content(type:"xhtml"){ div(xmlns:"http://www.w3.org/1999/xhtml"){ p("Category: ${item.type}") p{a(href:item.url, "Original Source")} p(item.shortDescription) p(item.description) } } } } response.setContentType("application/atom+xml") render "${feedHeader}${feed}${feedFooter}" }
URL: http://aboutgroovy.com/item/atom