Sha256: e3c680821b31e2da357c29424ec3083f7403455460522f34efa7ae4e93ba6118

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module ::ActionController
  class AbstractRequest                         
    def relative_url_root
      Facebooker.path_prefix
    end                                         
  end
  
  class UrlRewriter
    RESERVED_OPTIONS << :canvas
  
    def link_to_canvas?(params, options)
      option_override = options[:canvas]
      return false if option_override == false # important to check for false. nil should use default behavior
      option_override || @request.parameters["fb_sig_in_canvas"] == "1" ||  @request.parameters[:fb_sig_in_canvas] == "1" 
    end
  
    def rewrite_url_with_facebooker(*args)
      options = args.first.is_a?(Hash) ? args.first : args.last
      is_link_to_canvas = link_to_canvas?(@request.request_parameters, options)
      if is_link_to_canvas && !options.has_key?(:host)
        options[:host] = "apps.facebook.com"
      end 
      options.delete(:canvas)
      Facebooker.request_for_canvas(is_link_to_canvas) do
        rewrite_url_without_facebooker(*args)
      end
    end
    
    alias_method_chain :rewrite_url, :facebooker
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facebooker-0.9.5 lib/facebooker/rails/facebook_url_rewriting.rb