Changeset 8637
- Timestamp:
- 01/13/08 00:11:39 (9 months ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/atom_feed_helper.rb (modified) (3 diffs)
- trunk/actionpack/test/template/atom_feed_helper_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r8628 r8637 1 1 *SVN* 2 3 * Allow users to declare other namespaces when using the atom feed helpers. #10304 [david.calavera] 2 4 3 5 * Introduce send_file :x_sendfile => true to send an X-Sendfile response header. [Jeremy Kemper] trunk/actionpack/lib/action_view/helpers/atom_feed_helper.rb
r8593 r8637 43 43 # end 44 44 # 45 # The options arefor atom_feed are:45 # The options for atom_feed are: 46 46 # 47 47 # * <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. … … 49 49 # * <tt>:root_url</tt>: The HTML alternative that this feed is doubling for. Defaults to / on the current host. 50 50 # * <tt>:url</tt>: The URL for this feed. Defaults to the current URL. 51 # 52 # Other namespaces can be added to the root element: 53 # 54 # app/views/posts/index.atom.builder: 55 # atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', 56 # 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| 57 # feed.title("My great blog!") 58 # feed.updated((@posts.first.created_at)) 59 # feed.tag!(openSearch:totalResults, 10) 60 # 61 # for post in @posts 62 # feed.entry(post) do |entry| 63 # entry.title(post.title) 64 # entry.content(post.body, :type => 'html') 65 # entry.tag!('app:edited', Time.now) 66 # 67 # entry.author do |author| 68 # author.name("DHH") 69 # end 70 # end 71 # end 72 # end 73 # 51 74 # 52 75 # atom_feed yields an AtomFeedBuilder instance. … … 61 84 xml.instruct! 62 85 63 xml.feed "xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom' do 86 feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => 'http://www.w3.org/2005/Atom'} 87 feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)} 88 89 xml.feed(feed_opts) do 64 90 xml.id("tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}") 65 91 xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:root_url] || (request.protocol + request.host_with_port)) trunk/actionpack/test/template/atom_feed_helper_test.rb
r8564 r8637 52 52 entry.title(scroll.title) 53 53 entry.content(scroll.body, :type => 'html') 54 end 55 end 56 end 57 EOT 58 FEEDS["feed_with_atomPub_namespace"] = <<-EOT 59 atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', 60 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| 61 feed.title("My great blog!") 62 feed.updated((@scrolls.first.created_at)) 63 64 for scroll in @scrolls 65 feed.entry(scroll) do |entry| 66 entry.title(scroll.title) 67 entry.content(scroll.body, :type => 'html') 68 entry.tag!('app:edited', Time.now) 69 70 entry.author do |author| 71 author.name("DHH") 72 end 54 73 end 55 74 end … … 140 159 end 141 160 161 def test_feed_should_include_atomPub_namespace 162 with_restful_routing(:scrolls) do 163 get :index, :id => "feed_with_atomPub_namespace" 164 assert_match %r{xml:lang="en-US"}, @response.body 165 assert_match %r{xmlns="http://www.w3.org/2005/Atom"}, @response.body 166 assert_match %r{xmlns:app="http://www.w3.org/2007/app"}, @response.body 167 end 168 end 169 142 170 private 143 171 def with_restful_routing(resources)