Skip to content

Instantly share code, notes, and snippets.

@dokipen
Created February 3, 2011 16:04
Show Gist options
  • Select an option

  • Save dokipen/809680 to your computer and use it in GitHub Desktop.

Select an option

Save dokipen/809680 to your computer and use it in GitHub Desktop.
Atom xml generation in Kalimba
def _rss
if @last_update
self << @b.feed(
'xmlns' => 'http://www.w3.org/2005/Atom') do |f|
f.title 'Kalimba'
f.link :href => CONFIG[:canonical_url]
id = CONFIG[:canonical_url]
id = "#{id}/" unless id.end_with?'/'
f.id id
f.link :rel => 'self', :type => 'application/atom+xml',
:href=> "#{CONFIG[:canonical_url]}#{R(Rss)}"
f.subtitle CONFIG[:tagline]
f.updated @last_update.created_at.utc.strftime(
"%Y-%m-%dT%H:%S:%MZ")
f.author do |a|
a.name CONFIG[:author_name]
a.email CONFIG[:author_email]
a.uri CONFIG[:author_uri]
end
f.generator 'Kalimba'
@articles.each do |article, preview_row, preview|
f.entry do |i|
i.title article.title
i.link article.link,
:href => Kalimba::Models::Article.
normalize_url(article.link)
id = Kalimba::Models::Article.
normalize_url(article.link)
id = "#{id}/" unless id.end_with?'/'
i.id id
if preview_row
i.updated preview_row.created_at.utc.strftime(
"%Y-%m-%dT%H:%S:%MZ")
i.published preview_row.created_at.utc.strftime(
"%Y-%m-%dT%H:%S:%MZ")
else
i.updated @last_update.created_at.utc.strftime(
"%Y-%m-%dT%H:%S:%MZ")
i.published @last_update.created_at.utc.strftime(
"%Y-%m-%dT%H:%S:%MZ")
end
i.author do |author|
author.name article.author
author.uri article.author_link
end
if preview
content = render(:_rss_content, article, preview)
end
if content
i.content content, :type => 'html'
end
if preview
i.summary preview.description, :type => 'html'
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment