Changeset 8517
- Timestamp:
- 01/01/08 19:55:40 (1 year ago)
- Files:
-
- plugins/atom_feed_helper/CHANGELOG (modified) (1 diff)
- plugins/atom_feed_helper/lib/atom_feed_helper.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/atom_feed_helper/CHANGELOG
r6908 r8517 1 * Add support for unique entry URLs. [rick] 2 3 * Update the id tag datestamps to use the current year of the feed or the entry. [rick] 4 1 5 * id tag datestamps should just be the year the plugin is created [Sam Ruby/feedvalidator.org] plugins/atom_feed_helper/lib/atom_feed_helper.rb
r7200 r8517 2 2 # template languages). 3 3 module AtomFeedHelper 4 # Available Options: 5 # 6 # :root_url - Adds a <link rel="alternate" type="text/html" ... /> tag for the feed. 7 # :url - Adds a <link rel="self" type="application/atom+xml" ... /> tag for the feed. 8 # 4 9 def atom_feed(options = {}, &block) 5 10 xml = options[:xml] || eval("xml", block.binding) … … 7 12 8 13 xml.feed "xml:lang" => "en-US", "xmlns" => 'http://www.w3.org/2005/Atom' do 9 xml.id("tag:#{request.host}, 2007:#{request.request_uri.split(".")[0].gsub("/", "")}")14 xml.id("tag:#{request.host},#{Time.now.utc.year}:#{request.request_uri.split(".")[0].gsub("/", "")}") 10 15 11 16 if options[:root_url] || respond_to?(:root_url) … … 28 33 end 29 34 30 def entry(record) 31 @xml.entry do 32 @xml.id("tag:#{@view.request.host_with_port},2007:#{record.class}#{record.id}") 33 @xml.published(record.created_at.xmlschema) if record.respond_to?(:created_at) 35 # Available Options: 36 # 37 # :url - Adds a <link rel="alternate" type="text/html" ... /> tag for the given record. 38 # :published - Uses the given field to set the <published> tag value. Defaults to #created_at. 39 def entry(record, options = {}) 40 published = record.created_at if record.respond_to?(:created_at) 41 42 @xml.entry do 43 @xml.id("tag:#{@view.request.host_with_port},#{(published || Time.now.utc).year}:#{record.class}#{record.id}") 44 @xml.published(published.xmlschema) if published 34 45 @xml.updated(record.updated_at.xmlschema) if record.respond_to?(:updated_at) 35 46 36 47 yield @xml 37 48 38 @xml.link(:rel => 'alternate', :type => 'text/html', :href => @view.polymorphic_url(record))49 @xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record)) 39 50 end 40 51 end