Fixed forms to allow for exernal driving of the site
[feedcatcher.git] / app / controllers / feed_controller.rb
index f1597c061fb6cf55622fba983ee5cbb99840905e..71ab1df4f829d2530acf4163143ab6a042481099 100644 (file)
@@ -1,13 +1,38 @@
 class FeedController < ApplicationController
+
+  skip_before_filter :verify_authenticity_token
+
   def index
     @feeds = FeedItem.find(:all, :select => 'DISTINCT feed_name')
+    respond_to do |format|
+      format.html
+      format.rss { render :layout => false }
+    end
   end
 
   def show
-    @feed_items = FeedItem.find_all_by_feed_name(params[:id])
+    @feed_items = FeedItem.find_all_by_feed_name(params[:feed_name])
+    redirect_to index_url if @feed_items == []
+    respond_to do |format|
+      format.html
+      format.rss { render :layout => false }
+    end
   end
 
   def update
+    item = FeedItem.find_by_feed_name_and_title(params[:feed_name], params[:title])
+    if item
+      if params[:description] == ''
+        item.destroy
+      else
+        item.update_attribute(:description, params[:description])
+      end
+    else
+      FeedItem.create(:feed_name => params[:feed_name],
+        :title => params[:title],
+        :description => params[:description])
+    end
+    redirect_to feed_url(params[:feed_name])
   end
 
 end