+ create_item
+ end
+ else
+ respond_to do |format|
+ flash[:notice] = "Invalid feed name"
+ format.html { redirect_to index_url }
+ format.rss { head :not_found }
+ end
+ end
+ end
+
+
+ private
+
+ def valid_feed_name?(feed_name)
+ Rack::Utils::escape(feed_name) == feed_name and
+ Rack::Utils::unescape(feed_name) == feed_name and
+ feed_name != 'index' and
+ feed_name != 'show' and
+ feed_name != 'update' and
+ feed_name != 'action'
+ end
+
+
+ def create_item
+ item = FeedItem.new(:feed_name => params[:new_feed_name],
+ :title => params[:title],
+ :description => params[:description])
+ item.save!
+ flash[:notice] = "Element #{params[:title]} created"
+ respond_to do |format|
+ format.html { redirect_to feed_url(params[:new_feed_name]) }
+ format.rss { head :ok }
+ end
+ rescue ActiveRecord::RecordInvalid => error
+ flash[:notice] = "Element #{params[:title]} could not be created"
+ respond_to do |format|
+ format.html { redirect_to feed_url(params[:new_feed_name]) }
+ format.rss { head :unprocessable_entity }
+ end
+ end
+
+
+ def update_item(item)
+ if item.update_attribute(:description, params[:description])
+ flash[:notice] = "Element #{params[:title]} updated"
+ respond_to do |format|
+ format.html { redirect_to feed_url(params[:new_feed_name]) }
+ format.rss { head :ok }