DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Beefed Up RSS2 Template For Consumption With The Google Feed API Slide Show Control

05.31.2007
| 7200 views |
  • submit to reddit
        // description of your code here

xml.instruct!

# RSS2 rxml template based on: http://snippets.dzone.com/posts/show/558
xml.rss "version" => "2.0", \
        "xmlns:dc" => "http://purl.org/dc/elements/1.1/", \
        "xmlns:media" => "http://search.yahoo.com/mrss/" do

    xml.channel do

        xml.title       "foto-foo :: public timeline"
        xml.link        url_for :only_path => false, :controller => 'feeds'
        xml.pubDate     CGI.rfc1123_date(@images.first.updated_at) if @images.any?
        xml.description "foto-foo :: public timeline image feed"

        host = "AWS.S3.storage.host"
        @images.each do |img|
            img.url = "http://#{host}/#{img.name}"
            xml.item do
                xml.title       img.name
                xml.link        url_for :only_path => false, :controller => 'feeds', :action => 'show', :id => img.id
                xml.description "<a href='#{img.url}'><img src='#{img.url}'/></a>"
                xml.enclosure :url => "#{img.url}", :type => "image/jpg"

                xml.pubDate     CGI.rfc1123_date img.updated_at
                xml.guid        url_for :only_path => false, :controller => 'posts', :action => 'show', :id => img.id
                xml.author      "\"user-#{img.user_id}\" (#{img.user_id}@foto-foo.com)"

                xml.media :group do
                    xml.media :title, img.name
                    xml.media \
                        :content, :type => "#{img.mime}", :medium => "image", \
                        :url => "#{img.url}"
                        xml.media :credit, "#{img.credit.txt}", \
                                :role => "#{img.credit.role}" 
                    xml.media :description, "#{img.desc}", :type => 'plain'
                    xml.media :keywords, "#{img.tags}"
                    xml.media :thumbnail, \
                        :width => "#{img.thumbnail.widh}", \
                        :height => "#{img.thumbnail.height}", \
                        :url => "#{img.thumbnail.url}"
                end
            end
        end

    end
end