Class: Muck::AggregationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Muck::AggregationsController
- Defined in:
- app/controllers/muck/aggregations_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #rss_discovery ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/muck/aggregations_controller.rb', line 91 def create @aggregation = Aggregation.create(params[:aggregation]) @parent.aggregations << @aggregation if @parent # associate the parent if present # build a list of feeds and associate them with the aggregation @aggregation.add_feeds(current_user, params[:service_ids]) @aggregation.add_feeds_by_uri(current_user, params[:uris]) respond_to do |format| flash[:notice] = I18n.t('muck.raker.add_feeds_to_aggregation', :title => @aggregation.title) format.html { redirect_to(edit_aggregation_path(@aggregation)) } format.xml { render :xml => @aggregation, :status => :created, :location => @aggregation } end rescue ActiveRecord::RecordInvalid => ex respond_to do |format| format.html { render :action => "aggregations/new" } format.xml { render :xml => @aggregation.errors } end end |
#destroy ⇒ Object
162 163 164 165 166 167 168 169 170 |
# File 'app/controllers/muck/aggregations_controller.rb', line 162 def destroy @aggregation = Aggregation.find(params[:id]) @aggregation.destroy respond_to do |format| flash[:notice] = I18n.t('muck.raker.aggregation_deleted', :title => @aggregation.title) format.html { redirect_to polymorphic_url([@aggregation.ownable, :aggregations]) } format.xml { head :ok } end end |
#edit ⇒ Object
112 113 114 115 116 117 |
# File 'app/controllers/muck/aggregations_controller.rb', line 112 def edit setup_edit respond_to do |format| format.html { render :template => 'aggregations/edit' } end end |
#index ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/muck/aggregations_controller.rb', line 15 def index if @parent @aggregations = @parent.aggregations.by_title else @aggregations = Aggregation.newest end respond_to do |format| format.html { render(:template => 'aggregations/index') } format.iphone { render(:template => 'aggregations/index') } end end |
#new ⇒ Object
83 84 85 86 87 88 89 |
# File 'app/controllers/muck/aggregations_controller.rb', line 83 def new @page_title = I18n.t('muck.raker.new_aggregation') @service_categories = ServiceCategory.sorted.find(:all, :include => [:tag_services]) respond_to do |format| format.html { render :template => 'aggregations/new' } end end |
#preview ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/muck/aggregations_controller.rb', line 55 def preview if params[:terms].blank? flash[:error] = I18n.t('muck.raker.no_terms_error') redirect_to new_polymorphic_url([@parent, :aggregation]) else terms = params[:terms] terms = terms.join(' ') if terms.is_a?(Array) #@feeds = Service.build_tag_feeds(terms, current_user, params[:service_ids]) @photo_feeds = Service.build_photo_feeds(terms, current_user) @video_feeds = Service.build_video_feeds(terms, current_user) @bookmark_feeds = Service.build_bookmark_feeds(terms, current_user) @music_feeds = Service.build_music_feeds(terms, current_user) @general_feeds = Service.build_general_feeds(terms, current_user) @discovered_feeds = GoogleFeedRequest.find_feeds(terms) @title = terms.titleize @terms = terms @aggregation = Aggregation.new(:title => @title, :terms => @terms) respond_to do |format| format.html { render :template => 'aggregations/preview' } end end end |
#rss_discovery ⇒ Object
27 28 29 30 |
# File 'app/controllers/muck/aggregations_controller.rb', line 27 def rss_discovery @feeds = @aggregation.feeds render :template => 'aggregations/rss_discovery' end |
#show ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/muck/aggregations_controller.rb', line 32 def show @page_title = @aggregation.title @photo_feeds = @aggregation.photo_feeds @video_feeds = @aggregation.video_feeds @bookmark_feeds = @aggregation.bookmark_feeds @music_feeds = @aggregation.music_feeds @general_feeds = @aggregation.general_feeds if GlobalConfig.render_feeds_client_side elsif GlobalConfig.render_feeds_server_side @feeds = @aggregation.feeds else @entries = @aggregation.feeds.entries.paginate(:page => @page, :per_page => @per_page) end respond_to do |format| format.html { render(:template => 'aggregations/show') } format.opml { render(:layout => false) } format.rss {} end end |
#update ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'app/controllers/muck/aggregations_controller.rb', line 119 def update if params[:aggregation] @aggregation.update_attributes!(params[:aggregation]) flash[:notice] = I18n.t('muck.raker.aggregation_updated') end @feeds = [] if params[:uri] @feeds = Feed.feeds_from_uri(params[:uri], current_user) @aggregation.safe_add_feeds(@feeds) elsif params[:service_ids] @aggregation.terms = @aggregation.terms + ",#{params[:terms]}" @aggregation.save! @feeds = @aggregation.add_feeds(current_user, params[:service_ids]) end = I18n.t('muck.raker.no_feeds_found') if @feeds.blank? respond_to do |format| format.html { redirect_to edit_polymorphic_url([@aggregation.ownable, @aggregation]) } format.xml { head :ok } format.json do render :json => { :aggregation => @aggregation, :feeds => @feeds, :message => , :success => true, :html => get_google_feed_html }.as_json end end rescue ActiveRecord::RecordInvalid => ex respond_to do |format| format.html do setup_edit render :template => "aggregations/edit" end format.json { render :json => { :aggregation => @aggregation, :feeds => @feeds, :message => ex.to_s, :success => false, :html => '' }.as_json } format.xml { render :xml => @aggregation.errors } end end |