From 9167753d1540046c3c4f5568226181eaf05bb523 Mon Sep 17 00:00:00 2001 From: micah rich Date: Wed, 25 Nov 2009 13:27:20 -0500 Subject: [PATCH] trying just an image feed --- app/controllers/posts_controller.rb | 4 ++++ app/views/posts/image_feed.rxml | 22 ++++++++++++++++++++++ config/routes.rb | 1 + 3 files changed, 27 insertions(+) create mode 100644 app/views/posts/image_feed.rxml diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 6e4d7c4..e00852b 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -38,6 +38,10 @@ def feed @posts = Post.find_desc(:limit => 10) end + def image_feed + @posts = Post.find_desc(:limit => 10) + end + def show @post = Post.find(params[:id]) @comment = @post.comments.new diff --git a/app/views/posts/image_feed.rxml b/app/views/posts/image_feed.rxml new file mode 100644 index 0000000..4a4687c --- /dev/null +++ b/app/views/posts/image_feed.rxml @@ -0,0 +1,22 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version => "2.0", + "xmlns:media" => 'http://search.yahoo.com/mrss/'){ + xml.channel{ + xml.title(@site_name) + xml.link(@site_address) + xml.description(@site_description) + xml.language('en-us') + for post in @posts + xml.item do + xml.media(:content, :url => image_tag(post.image), :type => "image/jpeg") + + xml.title(post.title) + xml.description(newline_and_textilize(truncate(post.description, :length => 46))) + xml.author(@author) + xml.pubDate(post.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(post_path(post)) + xml.guid(post_path(post)) + end + end + } +} \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 329c829..3c9bb63 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,7 @@ # Sample of regular route: map.archive '/archive', :controller => 'posts', :action => 'archive' map.feed '/feed', :controller => 'posts', :action => 'feed' + map.feed '/imagefeed', :controller => 'posts', :action => 'image_feed' map.feed '/feed.:format', :controller => 'posts', :action => 'feed' map.about '/about', :controller => 'posts', :action => 'about'