Class: Muck::RecommendationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/muck/recommendations_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /recommendations GET /recommendations.xml



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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/recommendations_controller.rb', line 7

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 [email protected]?

  @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