Class: LinkRouterController

Inherits:
ApplicationController show all
Defined in:
app/controllers/link_router_controller.rb

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#app_before_filter, #calculate_url_for_response, #error_404, #escape_xml, #frameset_action_url, #log_error, #log_processing, #params_preserve_xhr, #rescue_action_in_public, #url_for_with_co

Instance Method Details

- (Object) index

Will be redirected to a bannered frameset link based on the value of app config "link_with_frameset". URL parameter "umlaut.link_with_frameset=false" can suppress that. See environment.rb-dist for instructions on setting app parameter. .



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
# File 'app/controllers/link_router_controller.rb', line 12

def index

  # Capture mysterious exception for better error reporting. 
  begin
    svc_type = ServiceType.find(params[:id])
  rescue ActiveRecord::RecordNotFound => exception
    # Usually this happens when it's a spider trying an old link. "go" links
    # don't stay good forever! Bad spider, ignoring our robots.txt.
    
    logger.warn("LinkRouter/index not found exception!: #{exception}\nReferrer: #{request.referer}\nUser-Agent:#{request.user_agent}\nClient IP:#{request.remote_addr}\n\n")

    # Give em a generic 404. One is saved in public as part of standard Rails.
    render :file=>File.join(RAILS_ROOT,"public/404.html"), :layout=>false, :status=>404
    return            
  end


  @collection = Collection.new(svc_type.request, session)          

  clickthrough = Clickthrough.new
  clickthrough.request_id = svc_type.request_id
  clickthrough.service_response_id = svc_type.service_response_id
  clickthrough.save

  if ( link_with_frameset?(svc_type) )
    redirect_to( frameset_action_url(svc_type) )
  else
    url = calculate_url_for_response(svc_type)      
    redirect_to url
  end
end