Sha256: c16af03bc93494b7521224ebb62b6cb438b9da57c00c843d8a2e3829f5d8ad79

Contents?: true

Size: 1.71 KB

Versions: 41

Compression:

Stored size: 1.71 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]) ))
    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

41 entries across 41 versions & 9 rubygems

Version Path
fs-facebooker-1.0.37 lib/facebooker/rails/facebook_url_rewriting.rb
micahwedemeyer-facebooker-1.0.50 lib/facebooker/rails/facebook_url_rewriting.rb
micahwedemeyer-facebooker-1.0.51 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.36 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.37 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.38 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.39 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.40 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.41 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.42 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.43 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.44 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.45 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.46 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.47 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.48 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.49 lib/facebooker/rails/facebook_url_rewriting.rb
mmangino-facebooker-1.0.50 lib/facebooker/rails/facebook_url_rewriting.rb
mwilliams-facebooker-1.0.40 lib/facebooker/rails/facebook_url_rewriting.rb
pomartel-facebooker-1.0.45 lib/facebooker/rails/facebook_url_rewriting.rb