1 class FeedController
< ApplicationController
3 skip_before_filter
:verify_authenticity_token
6 @feeds = FeedItem
.find(:all, :select => 'DISTINCT feed_name')
9 format
.rss
{ render
:layout => false }
15 if valid_feed_name
?(params
[:feed_name])
16 @feed_items = FeedItem
.find_all_by_feed_name(params
[:feed_name])
17 @feed_name = params
[:feed_name]
18 respond_to
do |format
|
20 flash
[:notice] = "No items in feed #{params[:feed_name]}"
21 format
.html
{ redirect_to index_url
}
22 format
.rss
{ render
:layout => false }
25 format
.rss
{ render
:layout => false }
29 respond_to
do |format
|
30 flash
[:notice] = "Invalid feed name"
31 format
.html
{ redirect_to index_url
}
32 format
.rss
{ head
:not_found}
39 if valid_feed_name
?(params
[:new_feed_name])
40 item
= FeedItem
.find_by_feed_name_and_title(params
[:new_feed_name], params
[:title])
42 if params
[:description] == ''
51 respond_to
do |format
|
52 flash
[:notice] = "Invalid feed name"
53 format
.html
{ redirect_to index_url
}
54 format
.rss
{ head
:not_found }
62 def valid_feed_name
?(feed_name
)
63 Rack
::Utils::escape(feed_name
) == feed_name
and
64 Rack
::Utils::unescape(feed_name
) == feed_name
and
65 feed_name
!= 'index' and
66 feed_name
!= 'show' and
67 feed_name
!= 'update' and
73 item
= FeedItem
.new(:feed_name => params
[:new_feed_name],
74 :title => params
[:title],
75 :description => params
[:description])
77 flash
[:notice] = "Element #{params[:title]} created"
78 respond_to
do |format
|
79 format
.html
{ redirect_to
feed_url(params
[:new_feed_name]) }
80 format
.rss
{ head
:ok }
82 rescue ActiveRecord
::RecordInvalid => error
83 flash
[:notice] = "Element #{params[:title]} could not be created"
84 respond_to
do |format
|
85 format
.html
{ redirect_to
feed_url(params
[:new_feed_name]) }
86 format
.rss
{ head
:unprocessable_entity }
92 if item
.update_attribute(:description, params
[:description])
93 flash
[:notice] = "Element #{params[:title]} updated"
94 respond_to
do |format
|
95 format
.html
{ redirect_to
feed_url(params
[:new_feed_name]) }
96 format
.rss
{ head
:ok }
99 flash
[:notice] = "Element #{params[:title]} could not be updated"
100 respond_to
do |format
|
101 format
.html
{ redirect_to
feed_url(params
[:new_feed_name]) }
102 format
.rss
{ head
:unprocessable_entity }
108 def destroy_item(item
)
110 flash
[:notice] = "Element #{params[:title]} destroyed"
111 respond_to
do |format
|
112 format
.html
{ redirect_to
feed_url(params
[:new_feed_name]) }
113 format
.rss
{ head
:ok }
116 flash
[:notice] = "Element #{params[:title]} could not be destroyed"
117 respond_to
do |format
|
118 format
.html
{ redirect_to
feed_url(params
[:new_feed_name]) }
119 format
.rss
{ head
:unprocessable_entity }