Skip to content
Browse files

trying just an image feed

  • Loading branch information...
1 parent 1877552 commit 9167753d1540046c3c4f5568226181eaf05bb523 @micahbrich committed Nov 25, 2009
Showing with 27 additions and 0 deletions.
  1. +4 −0 app/controllers/posts_controller.rb
  2. +22 −0 app/views/posts/image_feed.rxml
  3. +1 −0 config/routes.rb
View
4 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
View
22 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
+ }
+}
View
1 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'

0 comments on commit 9167753

Please sign in to comment.
Something went wrong with that request. Please try again.