root / app / controllers / feeds_controller.rb
View | Annotate | Download (3.5 KB)
| 1 | class FeedsController < ApplicationController |
|---|---|
| 2 | |
| 3 | layout 'two_column'
|
| 4 | |
| 5 | def index |
| 6 | end
|
| 7 | |
| 8 | def action_alerts |
| 9 | @alerts = ActionAlert.find(:all, :order => 'created_on DESC', :limit => 20) |
| 10 | response.headers['Content-Type'] = 'application/rss+xml' |
| 11 | render :action => 'action_alerts', :layout => false |
| 12 | end
|
| 13 | |
| 14 | def latest_articles |
| 15 | @articles = Article.promoted_and_featured.find(:all, :order => 'created_on DESC', :limit => 20) |
| 16 | response.headers['Content-Type'] = 'application/rss+xml' |
| 17 | render :action => 'latest_articles', :layout => false |
| 18 | end
|
| 19 | |
| 20 | def latest_videos |
| 21 | @videos = Video.promoted_and_featured.find(:all, :order => 'created_on DESC', :limit => 20) |
| 22 | response.headers['Content-Type'] = 'application/rss+xml' |
| 23 | render :action => 'latest_videos', :layout => false |
| 24 | end
|
| 25 | |
| 26 | def upcoming_events |
| 27 | @events = Event.promoted_and_featured.upcoming.find(:all, :order => 'date ASC', |
| 28 | :limit => events_per_feed)
|
| 29 | |
| 30 | response.headers['Content-Type'] = 'application/rss+xml' |
| 31 | render :action => 'upcoming_events', :layout => false |
| 32 | end
|
| 33 | |
| 34 | def upcoming_events_by_tag |
| 35 | tagname = params[:scope]
|
| 36 | @tag = Tag.find_by_name(tagname) |
| 37 | |
| 38 | if !@tag.nil? |
| 39 | @events = @tag.taggables.find( |
| 40 | :all,
|
| 41 | :conditions => ['moderation_status != ? and date >= ? and type = ?', "hidden", Date.today, "Event"], |
| 42 | :limit => events_per_feed)
|
| 43 | response.headers['Content-Type'] = 'application/rss+xml' |
| 44 | render :action => 'upcoming_events_by_tag', :layout => false |
| 45 | else
|
| 46 | flash[:notice] = 'No events tagged ' + tagname + ' were found...' |
| 47 | render :action => "index" |
| 48 | end
|
| 49 | |
| 50 | end
|
| 51 | |
| 52 | def upcoming_events_by_place |
| 53 | tagname = params[:scope]
|
| 54 | @tag = PlaceTag.find_by_name(tagname) |
| 55 | |
| 56 | if !@tag.nil? |
| 57 | @events = @tag.place_taggables.find( |
| 58 | :all,
|
| 59 | :conditions => ['moderation_status != ? and date >= ? and type = ?', "hidden", Date.today, "Event"], |
| 60 | :limit => events_per_feed)
|
| 61 | response.headers['Content-Type'] = 'application/rss+xml' |
| 62 | render :action => 'upcoming_events_by_place', :layout => false |
| 63 | else
|
| 64 | flash[:notice] = 'No events in ' + tagname + ' were found...' |
| 65 | render :action => "index" |
| 66 | end
|
| 67 | end
|
| 68 | |
| 69 | def articles_by_tag |
| 70 | tagname = params[:scope]
|
| 71 | @tag = Tag.find_by_name(tagname) |
| 72 | |
| 73 | if !@tag.nil? |
| 74 | @articles = @tag.taggables.find( |
| 75 | :all,
|
| 76 | :limit => events_per_feed,
|
| 77 | :conditions => ['type = ? and (moderation_status = ? or moderation_status = ? or moderation_status = ?)', "Article", "promoted", "featured", "published"], |
| 78 | :order => "created_on DESC") |
| 79 | response.headers['Content-Type'] = 'application/rss+xml' |
| 80 | render :action => 'articles_by_tag', :layout => false |
| 81 | else
|
| 82 | flash[:notice] = 'No articles tagged ' + tagname + ' were found...' |
| 83 | render :action => "index" |
| 84 | end
|
| 85 | end
|
| 86 | |
| 87 | def articles_by_place_tag |
| 88 | tagname = params[:scope]
|
| 89 | @tag = PlaceTag.find_by_name(tagname) |
| 90 | |
| 91 | if !@tag.nil? |
| 92 | @articles = @tag.place_taggables.find( |
| 93 | :all,
|
| 94 | :limit => events_per_feed,
|
| 95 | :conditions => ['type = ? and (moderation_status = ? or moderation_status = ? or moderation_status = ?)', "Article", "promoted", "featured", "published"], |
| 96 | :order => "created_on DESC") |
| 97 | response.headers['Content-Type'] = 'application/rss+xml' |
| 98 | render :action => 'articles_by_place_tag', :layout => false |
| 99 | else
|
| 100 | flash[:notice] = 'No articles from ' + tagname + ' were found...' |
| 101 | render :action => "index" |
| 102 | end
|
| 103 | end
|
| 104 | |
| 105 | end
|
| 106 |