Created
February 3, 2011 16:04
-
-
Save dokipen/809680 to your computer and use it in GitHub Desktop.
Atom xml generation in Kalimba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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