<commit_before>module ActionController
  
  module IphoneController
    
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      def acts_as_iphone_controller(iphone_test_mode = nil)
        include ActionController::IphoneController::InstanceMethods
        if iphone_test_mode 
          before_filter :force_iphone_format
        else
          before_filter :set_iphone_format
        end
        helper_method :is_iphone_request?
      end
      
      def iphone_test_mode?
        @@iphone_test_mode
      end
    end
    
    module InstanceMethods
      
      def force_iphone_format
        request.format = :iphone
      end
      
      def set_iphone_format
        if is_iphone_request? or request.format.to_sym == :iphone
          request.format = if cookies["browser"] == "desktop" 
                           then :html 
                           else :iphone 
                           end
        end
      end

      def is_iphone_request?
        request.user_agent =~ /(Mobile\/.+Safari)/
      end
    end
    
  end
  
end

ActionController::Base.send(:include, ActionController::IphoneController)<commit_msg>added recognition via domain, more customization coming<commit_after>module ActionController
  
  module IphoneController
    
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      def acts_as_iphone_controller(iphone_test_mode = nil)
        include ActionController::IphoneController::InstanceMethods
        if iphone_test_mode 
          before_filter :force_iphone_format
        else
          before_filter :set_iphone_format
        end
        helper_method :is_iphone_request?
      end
      
      def iphone_test_mode?
        @@iphone_test_mode
      end
    end
    
    module InstanceMethods
      
      def force_iphone_format
        request.format = :iphone
      end
      
      def set_iphone_format
        if is_iphone_request? || is_iphone_format? || is_iphone_subdomain?
          request.format = if cookies["browser"] == "desktop" 
                           then :html 
                           else :iphone 
                           end
        end
      end
      
      def is_iphone_format?
        request.format.to_sym == :iphone
      end

      def is_iphone_request?
        request.user_agent =~ /(Mobile\/.+Safari)/
      end
      
      def is_iphone_subdomain?
        request.subdomains.first == "iphone"
      end
    end
    
  end
  
end

ActionController::Base.send(:include, ActionController::IphoneController)
{'fraction_non_alphanumeric': 0.05581216320246343, 'fraction_numerical': 0.0, 'mean_word_length': 1.8280739934711643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7214785', 'n_tokens_mistral': 746, 'n_tokens_neox': 729, 'n_words': 146}