app/controllers/muck/recommendations_controller.rb in muck-services-0.1.10 vs app/controllers/muck/recommendations_controller.rb in muck-services-0.1.11

- old
+ new

@@ -3,15 +3,12 @@ unloadable # GET /recommendations # GET /recommendations.xml def index + @details = (params[:details] == 'true') - @real_time == params[:rtr] - - @details = params[:details] == "true" - @uri = params[:u] || request.env['HTTP_REFERER'] if @uri.blank? || !allowed_uri(@uri) render :text => '<!-- permission denied -->' return end @@ -38,18 +35,36 @@ @recommendations = @entry.ranked_recommendations(@limit, params[:order] || "mixed", @details) render :template => 'recommendations/index' end end format.xml { - render(:template => @entry.id.nil? && @real_time == true ? '/recommendations/index_real_time.xml.builder' : '/recommendations/index.xml.builder', :layout => false) + render('recommendations/index.xml.builder', :layout => false) } format.pjs { @host = "http://#{URI.parse(@uri).host}" - render(:template => @entry.id.nil? && @real_time == true ? 'recommendations/index_real_time.pjs.erb' : 'recommendations/index.pjs.erb', :layout => false) + render('recommendations/index.pjs.erb', :layout => false) } format.rss { render(:template => 'recommendations/index.rss.builder', :layout => false) } + end + end + + def get_button + @uri = params[:u] + render 'recommendations/get_button', :layout => false + end + + def real_time + respond_to do |format| + format.html do + @uri = params[:u] + @cache_key = "recommendations/real_time?u=#{CGI.escape(@uri)}" + if !fragment_exist?(@cache_key) + @recommendations = Entry.real_time_recommendations(@uri, I18n.locale.to_s, 5) + end + render 'recommendations/real_time', :layout => false + end end end protected