aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-01-13 00:11:39 +0000
committerMichael Koziarski <michael@koziarski.com>2008-01-13 00:11:39 +0000
commit7e1c04d86691075d172bccb8bc1c7df2e71383c3 (patch)
treed37e3f008d774ba8210babf7137ad4f01ee1416a /actionpack/lib/action_view/helpers
parent772ad9520158fb35fd5d5a9357ceca51b297bd67 (diff)
downloadrails-7e1c04d86691075d172bccb8bc1c7df2e71383c3.tar.gz
rails-7e1c04d86691075d172bccb8bc1c7df2e71383c3.tar.bz2
rails-7e1c04d86691075d172bccb8bc1c7df2e71383c3.zip
Allow users to declare other namespaces when using the atom feed helpers. Closes #10304 [david.calavera]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8637 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/atom_feed_helper.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/atom_feed_helper.rb b/actionpack/lib/action_view/helpers/atom_feed_helper.rb
index 96721b5b03..aee709a116 100644
--- a/actionpack/lib/action_view/helpers/atom_feed_helper.rb
+++ b/actionpack/lib/action_view/helpers/atom_feed_helper.rb
@@ -42,13 +42,36 @@ module ActionView
# end
# end
#
- # The options are for atom_feed are:
+ # The options for atom_feed are:
#
# * <tt>:schema_date</tt>: Required. The date at which the tag scheme for the feed was first used. A good default is the year you created the feed. See http://feedvalidator.org/docs/error/InvalidTAG.html for more information.
# * <tt>:language</tt>: Defaults to "en-US".
# * <tt>:root_url</tt>: The HTML alternative that this feed is doubling for. Defaults to / on the current host.
# * <tt>:url</tt>: The URL for this feed. Defaults to the current URL.
#
+ # Other namespaces can be added to the root element:
+ #
+ # app/views/posts/index.atom.builder:
+ # atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app',
+ # 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed|
+ # feed.title("My great blog!")
+ # feed.updated((@posts.first.created_at))
+ # feed.tag!(openSearch:totalResults, 10)
+ #
+ # for post in @posts
+ # feed.entry(post) do |entry|
+ # entry.title(post.title)
+ # entry.content(post.body, :type => 'html')
+ # entry.tag!('app:edited', Time.now)
+ #
+ # entry.author do |author|
+ # author.name("DHH")
+ # end
+ # end
+ # end
+ # end
+ #
+ #
# atom_feed yields an AtomFeedBuilder instance.
def atom_feed(options = {}, &block)
if options[:schema_date].blank?
@@ -60,7 +83,10 @@ module ActionView
xml = options[:xml] || eval("xml", block.binding)
xml.instruct!
- xml.feed "xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom' do
+ feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom'}
+ feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)}
+
+ xml.feed(feed_opts) do
xml.id("tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}")
xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:root_url] || (request.protocol + request.host_with_port))
xml.link(:rel => 'self', :type => 'application/atom+xml', :href => options[:url] || request.url)