Skip to content

Commit

Permalink
trying just an image feed
Browse files Browse the repository at this point in the history
  • Loading branch information
micahbrich committed Nov 25, 2009
1 parent 1877552 commit 9167753
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/posts_controller.rb
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions 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
}
}
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -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'

Expand Down

0 comments on commit 9167753

Please sign in to comment.