github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

noelrappin / rails-iui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 167
    • 15
  • Source
  • Commits
  • Network (15)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 50c7c19

click here to add a description

click here to add a homepage

  • Switch Branches (1)
    • master
  • Switch Tags (0)
  • Branch List
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rails wrapper for the iUI toolkit for building iPhone enabled web applications — Read more

  Cancel

http://blogs.pathf.com/agileajax/2008/05/rails-developme.html

  Cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Merge branch 'master' of git://github.com/jhh/rails-iui 
noelrappin (author)
Mon Aug 18 12:48:27 -0700 2008
commit  50c7c19038817d30b4c351232217c87a065d18a1
tree    fab6fe01c9ea5f6d58b2acc7b6cea56bbbf75598
parent  5a160a8761a2338b79c4dd6590c9e121c6a14ff6 parent  671945c8634ca30daf4e4a51752e15bc666802dd
rails-iui / lib / iphone_controller.rb lib/iphone_controller.rb
100644 57 lines (44 sloc) 1.345 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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)
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server