| records = (@versions + @comments + @updates + @uploads).uniq |
| xml.instruct! |
| #xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do |
| xml.rss "version" => "2.0", "xmlns:atom" => "http://www.w3.org/2005/Atom" do |
| scope = @wiki.title if @wiki |
| scope = ENV['EPFWIKI_APP_NAME'] unless @wiki |
| xml.channel do |
| xml.title "#{scope}" |
| if @wiki |
| xml.link @wiki.url(true) |
| xml.atom:link, :href => "http://#{ENV['EPFWIKI_HOST']}/rss/#{@wiki.folder}", :rel => 'self', :type => 'application/rss+xml' |
| else |
| xml.link "http://#{ENV['EPFWIKI_HOST']}/rss/all" |
| xml.atom:link, :href => "http://#{ENV['EPFWIKI_HOST']}/rss/all", :rel => 'self', :type => 'application/rss+xml' |
| end |
| if records.size > 0 |
| xml.pubDate CGI.rfc1123_date(records.first.created_on.gmtime) |
| else |
| xml.pubDate CGI.rfc1123_date(Time.now.gmtime) |
| end |
| xml.description h("News, changes, comments, baseline updates in #{scope}") |
| records.sort_by{|record| [record.created_on]}.reverse.each do |record| # can sort on more columns but we have the baseline_updated_on column |
| xml.item do |
| logger.debug("RSS item for #{record.class.to_s} with ID #{record.id}") |
| if record.class.name == 'UserVersion' |
| version = record |
| xml.guid "Version#{version.id.to_s}", :isPermaLink => false |
| xml.title "#{version.user.name} changed '#{version.page.presentation_name}'" |
| xml.link version.page.url(true) |
| xml.description version.note |
| xml.pubDate CGI.rfc1123_date(version.created_on.gmtime) |
| xml.dc_creator h(version.user.name) |
| elsif record.class.name == 'Upload' |
| upload = record |
| xml.guid "Upload#{upload.id.to_s}", :isPermaLink => false |
| xml.title "#{upload.user.name} uploaded #{upload.filename}" |
| xml.link upload.url(true) |
| xml.description "#{upload.description}" |
| xml.pubDate CGI.rfc1123_date(upload.created_on.gmtime) |
| xml.dc_creator h(upload.user.name) |
| elsif record.class.name == 'Comment' |
| comment = record |
| xml.guid "Comment#{comment.id.to_s}", :isPermaLink => false |
| xml.title "#{comment.user.name} discussed '#{comment.page.presentation_name}'" |
| xml.link comment.page.url(true) |
| xml.description "#{comment.text}" |
| xml.pubDate CGI.rfc1123_date(comment.created_on.gmtime) |
| xml.dc_creator h(comment.user.name) |
| elsif record.class.name == 'Update' |
| update = record |
| wiki = update.wiki |
| xml.link wiki.url(true) |
| xml.pubDate CGI.rfc1123_date(wiki.created_on.gmtime) |
| xml.dc_creator h(@cadmin.name) |
| if update.first_update? |
| xml.title "#{wiki.title} created!" |
| xml.description h("A new Wiki with title \"#{wiki.title}\" was created") |
| xml.guid "WikiCreated#{wiki.id.to_s}", :isPermaLink => false |
| else |
| xml.title "#{wiki.title} updated!" |
| xml.description "Wiki #{wiki.title} was updated with baseline #{wiki.baseline_process.title}" |
| xml.guid "WikiUpdated#{wiki.id.to_s}_#{update.id.to_s}", :isPermaLink => false |
| end |
| end |
| end |
| end |
| end |
| end |