Sha256: 8b6c024de86027872c19d47b8a19874549818258a06f559bbb4cb1c3bbe9cbd1

Contents?: true

Size: 1.76 KB

Versions: 27

Compression:

Stored size: 1.76 KB

Contents

module ::ActionController
  if Rails.version < '2.3'
    class AbstractRequest
      def relative_url_root
        Facebooker.path_prefix
      end
    end
  else
    class Request
      def relative_url_root
        Facebooker.path_prefix
      end
    end
  end

  class Base
    class << self
      alias :old_relative_url_root :relative_url_root
      def relative_url_root
        Facebooker.path_prefix
      end
    end
  end

  class UrlRewriter
    include Facebooker::Rails::BackwardsCompatibleParamChecks

    RESERVED_OPTIONS << :canvas

    def link_to_new_canvas?
      one_or_true @request.parameters["fb_sig_in_new_facebook"]
    end

    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 || (can_safely_access_request_parameters? && (one_or_true(@request.parameters["fb_sig_in_canvas"]) || one_or_true(@request.parameters[:fb_sig_in_canvas]) || one_or_true(@request.parameters["fb_sig_is_ajax"]) ))
    end

    #rails blindly tries to merge things that may be nil into the parameters. Make sure this won't break
    def can_safely_access_request_parameters?
      @request.request_parameters
    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] = Facebooker.canvas_server_base
      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

27 entries across 27 versions & 8 rubygems

Version Path
facebooker-1.0.73 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.70 lib/facebooker/rails/facebook_url_rewriting.rb
benhutton-facebooker-1.0.69.1 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.69 lib/facebooker/rails/facebook_url_rewriting.rb
cbaclig-facebooker-1.0.67.3 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.68 lib/facebooker/rails/facebook_url_rewriting.rb
cbaclig-facebooker-1.0.67.2 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-lite-1.0.67 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.67 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.66 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.65 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.64 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.63 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.62 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-fbg1-1.0.61.1 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-fbg-10.0.59 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-fbg-1.0.59a lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.61 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-1.0.60 lib/facebooker/rails/facebook_url_rewriting.rb
facebooker-fbg-1.0.59 lib/facebooker/rails/facebook_url_rewriting.rb