Sha256: b11cbfc90b73cc47f6991734f4f506217871ea28f93b982cbabcaf5fce46c974

Contents?: true

Size: 1.89 KB

Versions: 30

Compression:

Stored size: 1.89 KB

Contents

class Muck::RecommendationsController < ApplicationController
  
  unloadable
    
  # GET /recommendations
  # GET /recommendations.xml
  def index

    @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
    
    if params[:educommons]
      @uri = @uri[%r=http://.*?/.*?/[^/]+=] || @uri
      params[:title] = true
      params[:more_link] = true
    end

#    Entry.track_time_on_page(session, @uri)
    @entry = Entry.recommender_entry(@uri)
#    I18n.locale = @entry.language[0..1] if !@entry.nil?

    @limit = params[:limit] ? params[:limit].to_i : 5
    @limit = 25 if @limit > 25
    
    respond_to do |format|
      format.html do
        order = params[:order] || "mixed"
        if !@entry.id.nil?
          redirect_to resource_path(@entry) + "?limit=#{@limit}&order=#{order}&details=#{@details}"
        else
          @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)
      }
      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)
      }
      format.rss {
        render(:template => 'recommendations/index.rss.builder', :layout => false)  
      }
    end
  end
  
  protected
  
  def allowed_uri(uri)
    return false if uri.blank?
    uri.match(/^(10\.|192\.168|172\.|127\.)/) == nil && uri.include?('localhost') == false
  end
  
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
muck-services-0.1.10 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.9 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.8 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.7 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.6 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.5 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.4 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.3 app/controllers/muck/recommendations_controller.rb
muck-services-0.1.2 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.11 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.10 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.9 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.8 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.7 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.6 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.5 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.4 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.3 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.2 app/controllers/muck/recommendations_controller.rb
muck-raker-0.2.0 app/controllers/muck/recommendations_controller.rb