<commit_before>require 'omniauth/core'

module OmniAuth
  
  module Strategy
    
    def self.included(base)
      base.class_eval do
        attr_reader :app, :name, :env
      end
    end
     
    def initialize(app, name, *args)
      @app = app
      @name = name.to_sym
    end
    
    def call(env)
      dup.call!(env)
    end

    def call!(env)
      @env = env
      if request.path == "#{OmniAuth.config.path_prefix}/#{name}"
        request_phase
      elsif request.path == "#{OmniAuth.config.path_prefix}/#{name}/callback"
        callback_phase
      else
        if respond_to?(:other_phase)
          other_phase
        else
          call_app!
        end
      end
    end
    
    def request_phase
      raise NotImplementedError
    end
    
    def callback_phase
      @env['omniauth.auth'] = auth_hash
      call_app!
    end
    
    def call_app!
      @env['rack.auth'] = env['omniauth.auth'] if env.key?('omniauth.auth')
      @env['rack.auth.error'] = env['omniauth.error'] if env.key?('omniauth.error')
      
      @app.call(@env)
    end
    
    def auth_hash
      {
        'provider' => name.to_s,
        'uid' => nil
      }
    end
    
    def full_host
      uri = URI.parse(request.url)
      uri.path = ''
      uri.query = nil
      uri.to_s
    end
    
    def callback_url
      full_host + "#{OmniAuth.config.path_prefix}/#{name}/callback"
    end
    
    def session
      @env['rack.session']
    end

    def request
      @request ||= Rack::Request.new(@env)
    end
    
    def redirect(uri)
      r = Rack::Response.new("Redirecting to #{uri}...")
      r.redirect(uri)
      r.finish
    end
    
    def user_info; {} end
    
    def fail!(message_key, exception = nil)
      self.env['omniauth.error'] = exception
      OmniAuth.config.on_failure.call(self.env, message_key.to_sym)
    end
  end
end<commit_msg>Support for Facebook iFrame Applications<commit_after>require 'omniauth/core'

module OmniAuth
  
  module Strategy
    
    def self.included(base)
      base.class_eval do
        attr_reader :app, :name, :env
      end
    end
     
    def initialize(app, name, *args)
      @app = app
      @name = name.to_sym
    end
    
    def call(env)
      dup.call!(env)
    end

    def call!(env)
      @env = env
      if request.path == "#{OmniAuth.config.path_prefix}/#{name}"
        request_phase
      elsif request.path == "#{OmniAuth.config.path_prefix}/#{name}/callback"
        callback_phase
      else
        if respond_to?(:other_phase)
          other_phase
        else
          call_app!
        end
      end
    end
    
    def request_phase
      raise NotImplementedError
    end
    
    def callback_phase
      @env['omniauth.auth'] = auth_hash
      call_app!
    end
    
    def call_app!
      @env['rack.auth'] = env['omniauth.auth'] if env.key?('omniauth.auth')
      @env['rack.auth.error'] = env['omniauth.error'] if env.key?('omniauth.error')
      
      @app.call(@env)
    end
    
    def auth_hash
      {
        'provider' => name.to_s,
        'uid' => nil
      }
    end
    
    def full_host
      uri = URI.parse(request.url)
      uri.path = ''
      uri.query = nil
      uri.to_s
    end
    
    def callback_url
      full_host + "#{OmniAuth.config.path_prefix}/#{name}/callback"
    end
    
    def session
      @env['rack.session']
    end

    def request
      @request ||= Rack::Request.new(@env)
    end
    
    def redirect(uri)
      r = Rack::Response.new

      if options[:iframe]
        r.write("<script type='text/javascript' charset='utf-8'>top.location.href = '#{uri}';</script>")
      else
        r.write("Redirecting to #{uri}...")
        r.redirect(uri)
      end
      
      r.finish
    end
    
    def user_info; {} end
    
    def fail!(message_key, exception = nil)
      self.env['omniauth.error'] = exception
      OmniAuth.config.on_failure.call(self.env, message_key.to_sym)
    end
  end
end
{'fraction_non_alphanumeric': 0.11852413444528684, 'fraction_numerical': 0.00025271670457417233, 'mean_word_length': 1.8556998556998556, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5373855', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1319, 'n_words': 264}