mobile_fu 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG +113 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +159 -0
- data/Rakefile +41 -0
- data/lib/mobile-fu.rb +203 -0
- data/lib/mobile-fu/helper.rb +44 -0
- data/lib/mobile-fu/tablet.rb +13 -0
- data/lib/mobile-fu/version.rb +3 -0
- metadata +126 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 91e4dddb668797fabc780bf419934c8357baa4a4
|
|
4
|
+
data.tar.gz: 7ba4304b5332534ca4d8ec0d5c019af051804fca
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f5b3b2052ea311844f52312f35e41fee0f1644da2d2085837da0abf028d1399f5d48132e4c420b12fb89009797ac8b6e30cbb0d4088ce8b1901ffe86bf2bfba4
|
|
7
|
+
data.tar.gz: 69d89ab54c6519ee89cd300ccb721635d47d16e4e19feb857435b3d7bdb73996dc69f1b5e8282b0bee932fb9f0b63dbf8a5fa826bfb3ffe264b53f48277aff29
|
data/CHANGELOG
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
commit a46e0d5ff0a95407bbd8f3437a372ced53d90c9b
|
|
2
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
3
|
+
Date: Sat Dec 20 20:59:49 2008 -0500
|
|
4
|
+
|
|
5
|
+
Added a helper method to determine if a device is JavaScript enabled and one to output the XHTML Mobile 1.0 doctype
|
|
6
|
+
|
|
7
|
+
commit f4b29b2e2c68a79b8904dddb7a91efd4341540ee
|
|
8
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
9
|
+
Date: Sun Sep 21 21:39:10 2008 -0400
|
|
10
|
+
|
|
11
|
+
Fixes issue with 'in_mobile_view' instead of 'is_mobile_view' helper method
|
|
12
|
+
|
|
13
|
+
commit 29e8e8b407dd3dc8d5f3248183223d11c6a78843
|
|
14
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
15
|
+
Date: Wed Sep 10 12:51:12 2008 -0400
|
|
16
|
+
|
|
17
|
+
Updating CHANGELOG
|
|
18
|
+
|
|
19
|
+
commit 0aac5bd7f0d2f71e6af7b144a04a18dad9f5aca5
|
|
20
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
21
|
+
Date: Wed Sep 10 12:50:50 2008 -0400
|
|
22
|
+
|
|
23
|
+
Styling overrides for iPods
|
|
24
|
+
|
|
25
|
+
commit f30c97c794ba74e737856aa9226328469c8395b6
|
|
26
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
27
|
+
Date: Mon Sep 8 00:07:27 2008 -0400
|
|
28
|
+
|
|
29
|
+
Adding in some comments to the latest changes
|
|
30
|
+
|
|
31
|
+
commit 78dae861e46d383356d7e4d6dfdaefbf60072e27
|
|
32
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
33
|
+
Date: Mon Sep 8 00:06:16 2008 -0400
|
|
34
|
+
|
|
35
|
+
Updating README
|
|
36
|
+
|
|
37
|
+
commit 1a66ccd2142e387f6d3138acb688a58df4687fcd
|
|
38
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
39
|
+
Date: Mon Sep 8 00:05:48 2008 -0400
|
|
40
|
+
|
|
41
|
+
Adding in a helper method to check for a specific mobile device and adding in 'ipod' to the list of mobile user agents
|
|
42
|
+
|
|
43
|
+
commit cbb26fff3287e16a757ee2aed2dcc8e98cbfb369
|
|
44
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
45
|
+
Date: Fri Aug 22 22:16:19 2008 -0400
|
|
46
|
+
|
|
47
|
+
Updating the CHANGELOG
|
|
48
|
+
|
|
49
|
+
commit ee49945b593b1c55bf546da1d595a0941d071f94
|
|
50
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
51
|
+
Date: Fri Aug 22 22:16:00 2008 -0400
|
|
52
|
+
|
|
53
|
+
Updating README
|
|
54
|
+
|
|
55
|
+
commit 02c12a8563466f7cef6aba8e53915dc2efec908c
|
|
56
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
57
|
+
Date: Mon Aug 18 16:08:51 2008 -0400
|
|
58
|
+
|
|
59
|
+
Adding in support for Android
|
|
60
|
+
|
|
61
|
+
commit 2dffa5958905c0419288d03a0650127a0734b41a
|
|
62
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
63
|
+
Date: Sat Jul 26 14:08:56 2008 -0400
|
|
64
|
+
|
|
65
|
+
Adding in other phone user agents, including some Japanese and French manufacturers
|
|
66
|
+
|
|
67
|
+
commit e8f9f1a9c2e668d639690f4f1beb4f701f742cfa
|
|
68
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
69
|
+
Date: Fri Jul 18 11:15:52 2008 -0400
|
|
70
|
+
|
|
71
|
+
Adding in CHANGELOG
|
|
72
|
+
|
|
73
|
+
commit a3122b40c0c722b2942e9cb5341614d0e0d834a5
|
|
74
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
75
|
+
Date: Fri Jul 18 11:14:35 2008 -0400
|
|
76
|
+
|
|
77
|
+
Changes to README
|
|
78
|
+
|
|
79
|
+
commit 64a24e36b6a770757963eb2d961262fb8a14ec1b
|
|
80
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
81
|
+
Date: Fri Jul 18 11:10:40 2008 -0400
|
|
82
|
+
|
|
83
|
+
Quick fix
|
|
84
|
+
|
|
85
|
+
commit 116fa5b7c1168471cf56cb9961b98f0b73fc3308
|
|
86
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
87
|
+
Date: Fri Jul 18 10:04:41 2008 -0400
|
|
88
|
+
|
|
89
|
+
Fixed issue with mobile view session variable getting set incorrectly, when forcing mobile format
|
|
90
|
+
|
|
91
|
+
commit d172665c9d0458801fd672076e269a3c0ee9d80d
|
|
92
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
93
|
+
Date: Fri Jul 18 01:04:19 2008 -0400
|
|
94
|
+
|
|
95
|
+
Adding in more MIT license goodness
|
|
96
|
+
|
|
97
|
+
commit a6c947d684d2d9abdbe354dc1ea757f23cd5a633
|
|
98
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
99
|
+
Date: Fri Jul 18 01:00:55 2008 -0400
|
|
100
|
+
|
|
101
|
+
Change to the README
|
|
102
|
+
|
|
103
|
+
commit dad4f4db1f3cb816283069a91c01982c953ff8a5
|
|
104
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
105
|
+
Date: Fri Jul 18 01:00:16 2008 -0400
|
|
106
|
+
|
|
107
|
+
Change to the README
|
|
108
|
+
|
|
109
|
+
commit c5ec9de6ef19e48a66917d8f6f3a59771295765b
|
|
110
|
+
Author: Brendan G. Lim <brendan@intridea.com>
|
|
111
|
+
Date: Fri Jul 18 00:59:36 2008 -0400
|
|
112
|
+
|
|
113
|
+
Releasing Mobile Fu to the world
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Mobile Fu
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Want to automatically detect mobile devices that access your Rails application?
|
|
5
|
+
Mobile Fu allows you to do just that. People can access your site from a Palm,
|
|
6
|
+
Blackberry, iPhone, iPad, Nokia, etc. and it will automatically adjust the format
|
|
7
|
+
of the request from :html to :mobile or :tablet.
|
|
8
|
+
|
|
9
|
+
Installation
|
|
10
|
+
------------
|
|
11
|
+
|
|
12
|
+
Simply add `gem 'mobile-fu'` to your Gemfile and run bundle install.
|
|
13
|
+
|
|
14
|
+
Usage
|
|
15
|
+
-----
|
|
16
|
+
|
|
17
|
+
Add this this one line to the controller.
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
class ApplicationController < ActionController::Base
|
|
21
|
+
has_mobile_fu
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Once this is in place, any request that comes from a mobile device will be
|
|
26
|
+
set as :mobile format. It is up to you to determine how you want to handle
|
|
27
|
+
these requests. It is also up to you to create the .mobile.erb versions of
|
|
28
|
+
your views that are to be requested.
|
|
29
|
+
|
|
30
|
+
If you do not want to set the format to :mobile or :tablet and only use the
|
|
31
|
+
helper functions, pass false as an argument.
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
class ApplicationController < ActionController::Base
|
|
35
|
+
has_mobile_fu false
|
|
36
|
+
end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you dont want to have all the methods respond to :mobile and :tablet, you can opt-in this actions
|
|
40
|
+
using the following class method: `has_mobile_fu_for :action`
|
|
41
|
+
Example:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
class YourAwesomeClass < ActionController::Base
|
|
45
|
+
has_mobile_fu
|
|
46
|
+
has_mobile_fu_for :index
|
|
47
|
+
|
|
48
|
+
def index
|
|
49
|
+
# Mobile format will be set as normal here if user is on a mobile device
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def another_method
|
|
53
|
+
# Mobile format will not be set, even if user is on a mobile device
|
|
54
|
+
end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Mobile Fu automatically adds a new `:mobile` and `:tablet` to `text/html` mime type
|
|
58
|
+
alias for Rails apps. If you already have a custom `:mobile` alias registered in
|
|
59
|
+
`config/initializers/mime_types.rb`, you can remove that.
|
|
60
|
+
|
|
61
|
+
I recommend that you setup a before_filter that will redirect to a specific page
|
|
62
|
+
depending on whether or not it is a mobile request. How can you check this?
|
|
63
|
+
|
|
64
|
+
```ruby
|
|
65
|
+
is_mobile_device? # => Returns true or false depending on the device or
|
|
66
|
+
|
|
67
|
+
is_tablet_device? # => Returns true if the device is a tablet
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You can also determine which format is currently set in by calling the following:
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
in_mobile_view? # => Returns true or false depending on current req. format or
|
|
74
|
+
|
|
75
|
+
in_tablet_view? # => Returns true if the current req. format is for tablet view
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Also, if you want the ability to allow a user to switch between 'mobile' and
|
|
79
|
+
'standard' format (:html), you can just adjust the mobile_view session variable
|
|
80
|
+
in a custom controller action.
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
session[:mobile_view] # => Set to true if request format is :mobile and false
|
|
84
|
+
if set to :html
|
|
85
|
+
|
|
86
|
+
session[:tablet_view] # => Set to true if request format is :tablet and false
|
|
87
|
+
if set to :html
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If you want to use the default response templates, like index.html.erb, instead of the index.tablet.erb you can
|
|
91
|
+
exclude the tablet rendering from beeing used:
|
|
92
|
+
you can create a `before_filter` and put it before the has_mobile_fu call
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
before_filter :force_tablet_html
|
|
96
|
+
has_mobile_fu
|
|
97
|
+
|
|
98
|
+
def force_tablet_html
|
|
99
|
+
session[:tablet_view] = false
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Same will work for mobile, just change the `tablet` values to `mobile`
|
|
104
|
+
|
|
105
|
+
So, different devices need different styling. Don't worry, we've got this
|
|
106
|
+
baked in to Mobile Fu.
|
|
107
|
+
|
|
108
|
+
If you are including a css or sass file via `stylesheet_link_tag`, all you have
|
|
109
|
+
to do is add _device to the name of one of your files to override your styling
|
|
110
|
+
for a certain device. The stylesheet that is loaded is dependant on which device
|
|
111
|
+
is making the request.
|
|
112
|
+
|
|
113
|
+
e.g., Accessing a page from a Blackberry.
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
stylesheet_link_tag 'mobile.css'
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This loads mobile.css, and mobile_blackberry.css if the file exists.
|
|
120
|
+
|
|
121
|
+
Supported stylesheet override device extensions at the moment are:
|
|
122
|
+
|
|
123
|
+
* blackberry
|
|
124
|
+
* iphone (iphone,ipod)
|
|
125
|
+
* ipad
|
|
126
|
+
* android
|
|
127
|
+
* mobileexplorer
|
|
128
|
+
* nokia
|
|
129
|
+
* palm
|
|
130
|
+
|
|
131
|
+
The stylesheet awesomeness was derived from [Michael Bleigh's browserized styles](http://www.intridea.com/2007/12/9/announcing-browserized-styles)
|
|
132
|
+
|
|
133
|
+
Inspiration for Mobile Fu came from [Noel Rappin's rails_iui](http://blogs.pathf.com/agileajax/2008/05/rails-developme.html)
|
|
134
|
+
|
|
135
|
+
Hopefully this should help you create some awesome mobile applications.
|
|
136
|
+
|
|
137
|
+
Testing Mobile Interface
|
|
138
|
+
------------------------
|
|
139
|
+
|
|
140
|
+
If you want to force the mobile interface for testing, you can either use a
|
|
141
|
+
mobile device emulator, or you can call `force_mobile_format` in a before filter.
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
class ApplicationController < ActionController::Base
|
|
145
|
+
has_mobile_fu
|
|
146
|
+
before_filter :force_mobile_format
|
|
147
|
+
end
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
You can also force the tablet view by calling `force_tablet_format` instead
|
|
151
|
+
|
|
152
|
+
```ruby
|
|
153
|
+
class ApplicationController < ActionController::Base
|
|
154
|
+
has_mobile_fu
|
|
155
|
+
before_filter :force_tablet_format
|
|
156
|
+
end
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license
|
data/Rakefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'httparty'
|
|
5
|
+
|
|
6
|
+
MOBILE_DETECT_JSON = 'https://raw.github.com/serbanghita/Mobile-Detect/master/Mobile_Detect.json'
|
|
7
|
+
TABLET_FILE = 'lib/mobile-fu/tablet.rb'
|
|
8
|
+
|
|
9
|
+
task :default => [:test]
|
|
10
|
+
|
|
11
|
+
Rake::TestTask.new do |t|
|
|
12
|
+
t.libs.push 'lib'
|
|
13
|
+
t.test_files = FileList['spec/*_spec.rb', 'spec/mobile-fu/*_spec.rb']
|
|
14
|
+
t.verbose = true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Pull in data from Mobile Detect"
|
|
18
|
+
task :pull_mobile_detect_data do
|
|
19
|
+
|
|
20
|
+
# call out to Mobile Detect to get the data
|
|
21
|
+
content = HTTParty.get(MOBILE_DETECT_JSON).body
|
|
22
|
+
|
|
23
|
+
# build a new tablet regex
|
|
24
|
+
data = JSON.parse content
|
|
25
|
+
regexes = data['uaMatch']['tablets'].each.map { |_, v| v }
|
|
26
|
+
new_regex = regexes.join('|').downcase
|
|
27
|
+
|
|
28
|
+
# rewrite the tablet regex in our file
|
|
29
|
+
new_content = File.read(TABLET_FILE).gsub!(/TABLET_USER_AGENTS = \/.*\//, "TABLET_USER_AGENTS = \/#{new_regex}\/")
|
|
30
|
+
File.open(TABLET_FILE, 'w') { |f| f.write new_content }
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# desc 'Generate documentation for the mobile_fu plugin.'
|
|
35
|
+
# Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
36
|
+
# rdoc.rdoc_dir = 'rdoc'
|
|
37
|
+
# rdoc.title = 'MobileFu'
|
|
38
|
+
# rdoc.options << '--line-numbers' << '--inline-source'
|
|
39
|
+
# rdoc.rdoc_files.include('README')
|
|
40
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
|
41
|
+
# end
|
data/lib/mobile-fu.rb
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
require 'mobile-fu/tablet'
|
|
2
|
+
require 'rails'
|
|
3
|
+
require 'rack/mobile-detect'
|
|
4
|
+
|
|
5
|
+
module MobileFu
|
|
6
|
+
autoload :Helper, 'mobile-fu/helper'
|
|
7
|
+
|
|
8
|
+
class Railtie < Rails::Railtie
|
|
9
|
+
initializer "mobile-fu.configure" do |app|
|
|
10
|
+
app.config.middleware.use Rack::MobileDetect
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if Rails::VERSION::MAJOR >= 3
|
|
14
|
+
initializer "mobile-fu.action_controller" do |app|
|
|
15
|
+
ActiveSupport.on_load :action_controller do
|
|
16
|
+
include ActionController::MobileFu
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
initializer "mobile-fu.action_view" do |app|
|
|
21
|
+
ActiveSupport.on_load :action_view do
|
|
22
|
+
include MobileFu::Helper
|
|
23
|
+
alias_method :stylesheet_link_tag_without_mobilization, :stylesheet_link_tag
|
|
24
|
+
alias_method :stylesheet_link_tag, :stylesheet_link_tag_with_mobilization
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Mime::Type.register_alias "text/html", :mobile
|
|
30
|
+
Mime::Type.register_alias "text/html", :tablet
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module ActionController
|
|
35
|
+
module MobileFu
|
|
36
|
+
|
|
37
|
+
def self.included(base)
|
|
38
|
+
base.extend ClassMethods
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module ClassMethods
|
|
42
|
+
|
|
43
|
+
# Add this to one of your controllers to use MobileFu.
|
|
44
|
+
#
|
|
45
|
+
# class ApplicationController < ActionController::Base
|
|
46
|
+
# has_mobile_fu
|
|
47
|
+
# end
|
|
48
|
+
#
|
|
49
|
+
# If you don't want mobile_fu to set the request format automatically,
|
|
50
|
+
# you can pass false here.
|
|
51
|
+
#
|
|
52
|
+
# class ApplicationController < ActionController::Base
|
|
53
|
+
# has_mobile_fu false
|
|
54
|
+
# end
|
|
55
|
+
#
|
|
56
|
+
def has_mobile_fu(set_request_format = true)
|
|
57
|
+
include ActionController::MobileFu::InstanceMethods
|
|
58
|
+
|
|
59
|
+
before_action :set_request_format if set_request_format
|
|
60
|
+
|
|
61
|
+
helper_method :is_mobile_device?
|
|
62
|
+
helper_method :is_tablet_device?
|
|
63
|
+
helper_method :in_mobile_view?
|
|
64
|
+
helper_method :in_tablet_view?
|
|
65
|
+
helper_method :is_device?
|
|
66
|
+
helper_method :mobile_device
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Add this to your controllers to prevent the mobile format from being set for specific actions
|
|
70
|
+
# class AwesomeController < ApplicationController
|
|
71
|
+
# has_no_mobile_fu_for :index
|
|
72
|
+
#
|
|
73
|
+
# def index
|
|
74
|
+
# # Mobile format will not be set, even if user is on a mobile device
|
|
75
|
+
# end
|
|
76
|
+
#
|
|
77
|
+
# def show
|
|
78
|
+
# # Mobile format will be set as normal here if user is on a mobile device
|
|
79
|
+
# end
|
|
80
|
+
# end
|
|
81
|
+
def has_no_mobile_fu_for(*actions)
|
|
82
|
+
@mobile_exempt_actions = actions
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Add this to your controllers to only let those actions use the mobile format
|
|
86
|
+
# this method has priority over the #has_no_mobile_fu_for
|
|
87
|
+
# class AwesomeController < ApplicationController
|
|
88
|
+
# has_mobile_fu_for :index
|
|
89
|
+
#
|
|
90
|
+
# def index
|
|
91
|
+
# # Mobile format will be set as normal here if user is on a mobile device
|
|
92
|
+
# end
|
|
93
|
+
#
|
|
94
|
+
# def show
|
|
95
|
+
# # Mobile format will not be set, even if user is on a mobile device
|
|
96
|
+
# end
|
|
97
|
+
# end
|
|
98
|
+
def has_mobile_fu_for(*actions)
|
|
99
|
+
@mobile_include_actions = actions
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
module InstanceMethods
|
|
104
|
+
def set_request_format(force_mobile = false)
|
|
105
|
+
force_mobile ? force_mobile_format : set_mobile_format
|
|
106
|
+
end
|
|
107
|
+
alias :set_device_type :set_request_format
|
|
108
|
+
|
|
109
|
+
# Forces the request format to be :mobile
|
|
110
|
+
def force_mobile_format
|
|
111
|
+
unless request.xhr?
|
|
112
|
+
request.format = :mobile
|
|
113
|
+
session[:mobile_view] = true if session[:mobile_view].nil?
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Forces the request format to be :tablet
|
|
118
|
+
def force_tablet_format
|
|
119
|
+
unless request.xhr?
|
|
120
|
+
request.format = :tablet
|
|
121
|
+
session[:tablet_view] = true if session[:tablet_view].nil?
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Determines the request format based on whether the device is mobile or if
|
|
126
|
+
# the user has opted to use either the 'Standard' view or 'Mobile' view or
|
|
127
|
+
# 'Tablet' view.
|
|
128
|
+
|
|
129
|
+
def set_mobile_format
|
|
130
|
+
return unless request.format
|
|
131
|
+
if request.format.html? && mobile_action? && is_mobile_device? && !request.xhr?
|
|
132
|
+
request.format = :mobile unless session[:mobile_view] == false
|
|
133
|
+
session[:mobile_view] = true if session[:mobile_view].nil?
|
|
134
|
+
elsif request.format.html? && mobile_action? && is_tablet_device? && !request.xhr?
|
|
135
|
+
request.format = :tablet unless session[:tablet_view] == false
|
|
136
|
+
session[:tablet_view] = true if session[:tablet_view].nil?
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Returns either true or false depending on whether or not the format of the
|
|
141
|
+
# request is either :mobile or not.
|
|
142
|
+
|
|
143
|
+
def in_mobile_view?
|
|
144
|
+
return false unless request.format
|
|
145
|
+
request.format.to_sym == :mobile
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Returns either true or false depending on whether or not the format of the
|
|
149
|
+
# request is either :tablet or not.
|
|
150
|
+
|
|
151
|
+
def in_tablet_view?
|
|
152
|
+
return false unless request.format
|
|
153
|
+
request.format.to_sym == :tablet
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Returns either true or false depending on whether or not the user agent of
|
|
157
|
+
# the device making the request is matched to a device in our regex.
|
|
158
|
+
|
|
159
|
+
def is_tablet_device?
|
|
160
|
+
::MobileFu::Tablet.is_a_tablet_device? request.user_agent
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def is_mobile_device?
|
|
164
|
+
!is_tablet_device? && !!mobile_device
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def mobile_device
|
|
168
|
+
request.headers['X_MOBILE_DEVICE']
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Can check for a specific user agent
|
|
172
|
+
# e.g., is_device?('iphone') or is_device?('mobileexplorer')
|
|
173
|
+
|
|
174
|
+
def is_device?(type)
|
|
175
|
+
request.user_agent.to_s.downcase.include? type.to_s.downcase
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Returns true if current action is supposed to use mobile format
|
|
179
|
+
# See #has_mobile_fu_for
|
|
180
|
+
def mobile_action?
|
|
181
|
+
if self.class.instance_variable_get("@mobile_include_actions").nil? #Now we know we dont have any includes, maybe excludes?
|
|
182
|
+
return !mobile_exempt?
|
|
183
|
+
else
|
|
184
|
+
self.class.instance_variable_get("@mobile_include_actions").try(:include?, params[:action].try(:to_sym))
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Returns true if current action isn't supposed to use mobile format
|
|
189
|
+
# See #has_no_mobile_fu_for
|
|
190
|
+
|
|
191
|
+
def mobile_exempt?
|
|
192
|
+
self.class.instance_variable_get("@mobile_exempt_actions").try(:include?, params[:action].try(:to_sym))
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
if Rails::VERSION::MAJOR < 3
|
|
199
|
+
ActionController::Base.send :include, ActionController::MobileFu
|
|
200
|
+
ActionView::Base.send :include, MobileFu::Helper
|
|
201
|
+
ActionView::Base.send :alias_method, :stylesheet_link_tag_without_mobilization, :stylesheet_link_tag
|
|
202
|
+
ActionView::Base.send :alias_method, :stylesheet_link_tag, :stylesheet_link_tag_with_mobilization
|
|
203
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module MobileFu
|
|
2
|
+
module Helper
|
|
3
|
+
JS_ENABLED_DEVICES = %w{iphone ipod ipad mobileexplorer android zune}
|
|
4
|
+
|
|
5
|
+
def js_enabled_mobile_device?
|
|
6
|
+
JS_ENABLED_DEVICES.find { |device| is_device? device }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def stylesheet_link_tag_with_mobilization(*sources)
|
|
10
|
+
mobilized_sources = Array.new
|
|
11
|
+
|
|
12
|
+
# Figure out where stylesheets live, which differs depending if the asset
|
|
13
|
+
# pipeline is used or not.
|
|
14
|
+
stylesheets_dir = config.stylesheets_dir # Rails.root/public/stylesheets
|
|
15
|
+
|
|
16
|
+
# Look for mobilized stylesheets in the app/assets path if asset pipeline
|
|
17
|
+
# is enabled, because public/stylesheets will be missing in development
|
|
18
|
+
# mode without precompiling assets first, and may also contain multiple
|
|
19
|
+
# stylesheets with similar names because of checksumming during
|
|
20
|
+
# precompilation.
|
|
21
|
+
if Rails.application.config.respond_to?(:assets) # don't break pre-rails3.1
|
|
22
|
+
if Rails.application.config.assets.enabled
|
|
23
|
+
stylesheets_dir = File.join(Rails.root, 'app/assets/stylesheets/')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
device_names = respond_to?(:is_mobile_device?) && is_mobile_device? ? ['mobile', mobile_device.downcase] : []
|
|
28
|
+
|
|
29
|
+
sources.each do |source|
|
|
30
|
+
mobilized_sources << source
|
|
31
|
+
|
|
32
|
+
device_names.compact.each do |device_name|
|
|
33
|
+
# support ERB and/or SCSS extensions (e.g., mobile.css.erb, mobile.css.scss.erb)
|
|
34
|
+
possible_source = source.to_s.sub(/\.css.*$/, '') + "_#{device_name}"
|
|
35
|
+
|
|
36
|
+
mobilized_files = Dir.glob(File.join(stylesheets_dir, "#{possible_source}.css*")).map { |f| f.sub(stylesheets_dir, '') }
|
|
37
|
+
mobilized_sources += mobilized_files.map { |f| f.sub(/\.css.*/, '') }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
stylesheet_link_tag_without_mobilization *mobilized_sources
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module MobileFu
|
|
2
|
+
|
|
3
|
+
module Tablet
|
|
4
|
+
|
|
5
|
+
TABLET_USER_AGENTS = /ipad|ipad.*mobile|android.*nexus[\s]+(7|9|10)|^.*android.*nexus(?:(?!mobile).)*$|samsung.*tablet|galaxy.*tab|sc-01c|gt-p1000|gt-p1003|gt-p1010|gt-p3105|gt-p6210|gt-p6800|gt-p6810|gt-p7100|gt-p7300|gt-p7310|gt-p7500|gt-p7510|sch-i800|sch-i815|sch-i905|sgh-i957|sgh-i987|sgh-t849|sgh-t859|sgh-t869|sph-p100|gt-p3100|gt-p3108|gt-p3110|gt-p5100|gt-p5110|gt-p6200|gt-p7320|gt-p7511|gt-n8000|gt-p8510|sgh-i497|sph-p500|sgh-t779|sch-i705|sch-i915|gt-n8013|gt-p3113|gt-p5113|gt-p8110|gt-n8010|gt-n8005|gt-n8020|gt-p1013|gt-p6201|gt-p7501|gt-n5100|gt-n5105|gt-n5110|shv-e140k|shv-e140l|shv-e140s|shv-e150s|shv-e230k|shv-e230l|shv-e230s|shw-m180k|shw-m180l|shw-m180s|shw-m180w|shw-m300w|shw-m305w|shw-m380k|shw-m380s|shw-m380w|shw-m430w|shw-m480k|shw-m480s|shw-m480w|shw-m485w|shw-m486w|shw-m500w|gt-i9228|sch-p739|sch-i925|gt-i9200|gt-i9205|gt-p5200|gt-p5210|gt-p5210x|sm-t311|sm-t310|sm-t310x|sm-t210|sm-t210r|sm-t211|sm-p600|sm-p601|sm-p605|sm-p900|sm-p901|sm-t217|sm-t217a|sm-t217s|sm-p6000|sm-t3100|sgh-i467|xe500|sm-t110|gt-p5220|gt-i9200x|gt-n5110x|gt-n5120|sm-p905|sm-t111|sm-t2105|sm-t315|sm-t320|sm-t320x|sm-t321|sm-t520|sm-t525|sm-t530nu|sm-t230nu|sm-t330nu|sm-t900|xe500t1c|sm-p605v|sm-p905v|sm-p600x|sm-p900x|sm-t210x|sm-t230|sm-t230x|sm-t325|gt-p7503|sm-t531|sm-t330|sm-t530|sm-t705c|sm-t535|sm-t331|sm-t800|sm-t700|sm-t537|sm-t807|sm-p907a|sm-t337a|sm-t707a|sm-t807a|sm-t237p|sm-t807p|sm-p607t|sm-t217t|sm-t337t|kindle|silk.*accelerated|android.*\b(kfot|kftt|kfjwi|kfjwa|kfote|kfsowi|kfthwi|kfthwa|kfapwi|kfapwa|wfjwae|kfsawa|kfsawi|kfaswi)\b|windows nt [0-9.]+; arm;.*(tablet|armbjs)|hp slate (7|8|10)|hp elitepad 900|hp-tablet|elitebook.*touch|hp 8|slate 21|hp slatebook 10|^.*padfone((?!mobile).)*$|transformer|tf101|tf101g|tf300t|tf300tg|tf300tl|tf700t|tf700kl|tf701t|tf810c|me171|me301t|me302c|me371mg|me370t|me372mg|me172v|me173x|me400c|slider sl101|\bk00f\b|\bk00c\b|\bk00e\b|\bk00l\b|tx201la|me176c|me102a|\bm80ta\b|me372cl|me560cg|me372cg|playbook|rim tablet|htc_flyer_p512|htc flyer|htc jetstream|htc-p715a|htc evo view 4g|pg41200|pg09410|xoom|sholest|mz615|mz605|mz505|mz601|mz602|mz603|mz604|mz606|mz607|mz608|mz609|mz615|mz616|mz617|android.*nook|nookcolor|nook browser|bnrv200|bnrv200a|bntv250|bntv250a|bntv400|bntv600|logicpd zoom2|android.*; \b(a100|a101|a110|a200|a210|a211|a500|a501|a510|a511|a700|a701|w500|w500p|w501|w501p|w510|w511|w700|g100|g100w|b1-a71|b1-710|b1-711|a1-810|a1-811|a1-830)\b|w3-810|\ba3-a10\b|android.*(at100|at105|at200|at205|at270|at275|at300|at305|at1s5|at500|at570|at700|at830)|toshiba.*folio|\bl-06c|lg-v909|lg-v900|lg-v700|lg-v510|lg-v500|lg-v410|lg-v400|lg-vk810\b|android.*\b(f-01d|f-02f|f-05e|f-10d|m532|q572)\b|pmp3170b|pmp3270b|pmp3470b|pmp7170b|pmp3370b|pmp3570c|pmp5870c|pmp3670b|pmp5570c|pmp5770d|pmp3970b|pmp3870c|pmp5580c|pmp5880d|pmp5780d|pmp5588c|pmp7280c|pmp7280c3g|pmp7280|pmp7880d|pmp5597d|pmp5597|pmp7100d|per3464|per3274|per3574|per3884|per5274|per5474|pmp5097cpro|pmp5097|pmp7380d|pmp5297c|pmp5297c_quad|idea(tab|pad)( a1|a10| k1|)|thinkpad([ ]+)?tablet|lenovo.*(s2109|s2110|s5000|s6000|k3011|a3000|a3500|a1000|a2107|a2109|a1107|a5500|a7600|b6000|b8000|b8080)(-|)(fl|f|hv|h|)|venue 11|venue 8|venue 7|dell streak 10|dell streak 7|android.*\b(tab210|tab211|tab224|tab250|tab260|tab264|tab310|tab360|tab364|tab410|tab411|tab420|tab424|tab450|tab460|tab461|tab464|tab465|tab467|tab468|tab07-100|tab07-101|tab07-150|tab07-151|tab07-152|tab07-200|tab07-201-3g|tab07-210|tab07-211|tab07-212|tab07-214|tab07-220|tab07-400|tab07-485|tab08-150|tab08-200|tab08-201-3g|tab08-201-30|tab09-100|tab09-211|tab09-410|tab10-150|tab10-201|tab10-211|tab10-400|tab10-410|tab13-201|tab274euk|tab275euk|tab374euk|tab462euk|tab474euk|tab9-200)\b|android.*\boyo\b|life.*(p9212|p9514|p9516|s9512)|lifetab|an10g2|an7bg3|an7fg3|an8g3|an8cg3|an7g3|an9g3|an7dg3|an7dg3st|an7dg3childpad|an10bg3|an10bg3dt|an9g2|inm8002kp|inm1010fp|inm805nd|intenso tab|tab1004|m702pro|megafon v9|\bzte v9\b|android.*\bmt7a\b|e-boda (supreme|impresspeed|izzycomm|essential)|allview.*(viva|alldro|city|speed|all tv|frenzy|quasar|shine|tx1|ax1|ax2)|\b(101g9|80g9|a101it)\b|qilive 97r|archos5|\barchos (70|79|80|90|97|101|familypad|)(b|)(g10| cobalt| titanium(hd|)| xenon| neon|xsk| 2| xs 2| platinum| carbon|gamepad)\b|novo7|novo8|novo10|novo7aurora|novo7basic|novo7paladin|novo9-spark|sony.*tablet|xperia tablet|sony tablet s|so-03e|sgpt12|sgpt13|sgpt114|sgpt121|sgpt122|sgpt123|sgpt111|sgpt112|sgpt113|sgpt131|sgpt132|sgpt133|sgpt211|sgpt212|sgpt213|sgp311|sgp312|sgp321|ebrd1101|ebrd1102|ebrd1201|sgp351|sgp341|sgp511|sgp512|sgp521|sgp541|sgp551|\b(pi2010|pi3000|pi3100|pi3105|pi3110|pi3205|pi3210|pi3900|pi4010|pi7000|pi7100)\b|android.*(k8gt|u9gt|u10gt|u16gt|u17gt|u18gt|u19gt|u20gt|u23gt|u30gt)|cube u8gt|mid1042|mid1045|mid1125|mid1126|mid7012|mid7014|mid7015|mid7034|mid7035|mid7036|mid7042|mid7048|mid7127|mid8042|mid8048|mid8127|mid9042|mid9740|mid9742|mid7022|mid7010|m9701|m9000|m9100|m806|m1052|m806|t703|mid701|mid713|mid710|mid727|mid760|mid830|mid728|mid933|mid125|mid810|mid732|mid120|mid930|mid800|mid731|mid900|mid100|mid820|mid735|mid980|mid130|mid833|mid737|mid960|mid135|mid860|mid736|mid140|mid930|mid835|mid733|msi \b(primo 73k|primo 73l|primo 81l|primo 77|primo 93|primo 75|primo 76|primo 73|primo 81|primo 91|primo 90|enjoy 71|enjoy 7|enjoy 10)\b|android.*(\bmid\b|mid-560|mtv-t1200|mtv-pnd531|mtv-p1101|mtv-pnd530)|android.*(rk2818|rk2808a|rk2918|rk3066)|rk2738|rk2808a|iq310|fly vision|bq.*(elcano|curie|edison|maxwell|kepler|pascal|tesla|hypatia|platon|newton|livingstone|cervantes|avant)|maxwell.*lite|maxwell.*plus|mediapad|mediapad 7 youth|ideos s7|s7-201c|s7-202u|s7-101|s7-103|s7-104|s7-105|s7-106|s7-201|s7-slim|\bn-06d|\bn-08d|pantech.*p4100|broncho.*(n701|n708|n802|a710)|touchpad.*[78910]|\btouchtab\b|z1000|z99 2g|z99|z930|z999|z990|z909|z919|z900|tb07sta|tb10sta|tb07fta|tb10fta|android.*\bnabi|kobo touch|\bk080\b|\bvox\b build|\barc\b build|dslide.*\b(700|701r|702|703r|704|802|970|971|972|973|974|1010|1012)\b|navipad|tb-772a|tm-7045|tm-7055|tm-9750|tm-7016|tm-7024|tm-7026|tm-7041|tm-7043|tm-7047|tm-8041|tm-9741|tm-9747|tm-9748|tm-9751|tm-7022|tm-7021|tm-7020|tm-7011|tm-7010|tm-7023|tm-7025|tm-7037w|tm-7038w|tm-7027w|tm-9720|tm-9725|tm-9737w|tm-1020|tm-9738w|tm-9740|tm-9743w|tb-807a|tb-771a|tb-727a|tb-725a|tb-719a|tb-823a|tb-805a|tb-723a|tb-715a|tb-707a|tb-705a|tb-709a|tb-711a|tb-890hd|tb-880hd|tb-790hd|tb-780hd|tb-770hd|tb-721hd|tb-710hd|tb-434hd|tb-860hd|tb-840hd|tb-760hd|tb-750hd|tb-740hd|tb-730hd|tb-722hd|tb-720hd|tb-700hd|tb-500hd|tb-470hd|tb-431hd|tb-430hd|tb-506|tb-504|tb-446|tb-436|tb-416|tb-146se|tb-126se|playstation.*(portable|vita)|st10416-1|vt10416-1|st70408-1|st702xx-1|st702xx-2|st80208|st97216|st70104-2|vt10416-2|st10216-2a|surftab|\b(ptbl10ceu|ptbl10c|ptbl72bc|ptbl72bceu|ptbl7ceu|ptbl7c|ptbl92bc|ptbl92bceu|ptbl9ceu|ptbl9cuk|ptbl9c)\b|android.* \b(e3a|t3x|t5c|t5b|t3e|t3c|t3b|t1j|t1f|t2a|t1h|t1i|e1c|t1-e|t5-a|t4|e1-b|t2ci|t1-b|t1-d|o1-a|e1-a|t1-a|t3a|t4i)\b |genius tab g3|genius tab s2|genius tab q3|genius tab g4|genius tab q4|genius tab g-ii|genius tab gii|genius tab giii|genius tab s1|android.*\bg1\b|funbook|micromax.*\b(p250|p560|p360|p362|p600|p300|p350|p500|p275)\b|android.*\b(a39|a37|a34|st8|st10|st7|smart tab3|smart tab2)\b|fine7 genius|fine7 shine|fine7 air|fine8 style|fine9 more|fine10 joy|fine11 wide|\b(pem63|plt1023g|plt1041|plt1044|plt1044g|plt1091|plt4311|plt4311pl|plt4315|plt7030|plt7033|plt7033d|plt7035|plt7035d|plt7044k|plt7045k|plt7045kb|plt7071kg|plt7072|plt7223g|plt7225g|plt7777g|plt7810k|plt7849g|plt7851g|plt7852g|plt8015|plt8031|plt8034|plt8036|plt8080k|plt8082|plt8088|plt8223g|plt8234g|plt8235g|plt8816k|plt9011|plt9045k|plt9233g|plt9735|plt9760g|plt9770g)\b|bq1078|bc1003|bc1077|rk9702|bc9730|bc9001|it9001|bc7008|bc7010|bc708|bc728|bc7012|bc7030|bc7027|bc7026|tpc7102|tpc7103|tpc7105|tpc7106|tpc7107|tpc7201|tpc7203|tpc7205|tpc7210|tpc7708|tpc7709|tpc7712|tpc7110|tpc8101|tpc8103|tpc8105|tpc8106|tpc8203|tpc8205|tpc8503|tpc9106|tpc9701|tpc97101|tpc97103|tpc97105|tpc97106|tpc97111|tpc97113|tpc97203|tpc97603|tpc97809|tpc97205|tpc10101|tpc10103|tpc10106|tpc10111|tpc10203|tpc10205|tpc10503|tx-a1301|tx-m9002|q702|kf026|tab-p506|tab-navi-7-3g-m|tab-p517|tab-p-527|tab-p701|tab-p703|tab-p721|tab-p731n|tab-p741|tab-p825|tab-p905|tab-p925|tab-pr945|tab-pl1015|tab-p1025|tab-pi1045|tab-p1325|tab-protab[0-9]+|tab-protab25|tab-protab26|tab-protab27|tab-protab26xl|tab-protab2-ips9|tab-protab30-ips9|tab-protab25xxl|tab-protab26-ips10|tab-protab30-ips10|ov-(steelcore|newbase|basecore|baseone|exellen|quattor|edutab|solution|action|basictab|teddytab|magictab|stream|tb-08|tb-09)|hcl.*tablet|connect-3g-2.0|connect-2g-2.0|me tablet u1|me tablet u2|me tablet g1|me tablet x1|me tablet y2|me tablet sync|dps dream 9|dps dual 7|v97 hd|i75 3g|visture v4( hd)?|visture v5( hd)?|visture v10|ctp(-)?810|ctp(-)?818|ctp(-)?828|ctp(-)?838|ctp(-)?888|ctp(-)?978|ctp(-)?980|ctp(-)?987|ctp(-)?988|ctp(-)?989|\bmt8125|mt8389|mt8135|mt8377\b|concorde([ ]+)?tab|concorde readman|goclever tab|a7goclever|m1042|m7841|m742|r1042bk|r1041|tab a975|tab a7842|tab a741|tab a741l|tab m723g|tab m721|tab a1021|tab i921|tab r721|tab i720|tab t76|tab r70|tab r76.2|tab r106|tab r83.2|tab m813g|tab i721|gcta722|tab i70|tab i71|tab s73|tab r73|tab r74|tab r93|tab r75|tab r76.1|tab a73|tab a93|tab a93.2|tab t72|tab r83|tab r974|tab r973|tab a101|tab a103|tab a104|tab a104.2|r105bk|m713g|a972bk|tab a971|tab r974.2|tab r104|tab r83.3|tab a1042|freetab 9000|freetab 7.4|freetab 7004|freetab 7800|freetab 2096|freetab 7.5|freetab 1014|freetab 1001 |freetab 8001|freetab 9706|freetab 9702|freetab 7003|freetab 7002|freetab 1002|freetab 7801|freetab 1331|freetab 1004|freetab 8002|freetab 8014|freetab 9704|freetab 1003|\b(argus[ _]?s|diamond[ _]?79hd|emerald[ _]?78e|luna[ _]?70c|onyx[ _]?s|onyx[ _]?z|orin[ _]?hd|orin[ _]?s|otis[ _]?s|speedstar[ _]?s|magnet[ _]?m9|primus[ _]?94[ _]?3g|primus[ _]?94hd|primus[ _]?qs|android.*\bq8\b|sirius[ _]?evo[ _]?qs|sirius[ _]?qs|spirit[ _]?s)\b|v07ot2|tm105a|s10ot1|tr10cs1|ezee[_']?(tab|go)[0-9]+|tablc7|looney tunes tab|smarttab([ ]+)?[0-9]+|smarttabii10|smarttabii7|smart[ ']?tab[ ]+?[0-9]+|family[ ']?tab2|rm-790|rm-997|rmd-878g|rmd-974r|rmt-705a|rmt-701|rme-601|rmt-501|rmt-711|i-mobile i-note|tolino tab [0-9.]+|tolino shine|\bc-22q|t7-qc|t-17b|t-17p\b|android.* a78 |android.* (skypad|phoenix|cyclops)|tecno p9|android.*\b(f3000|a3300|jxd5000|jxd3000|jxd2000|jxd300b|jxd300|s5800|s7800|s602b|s5110b|s7300|s5300|s602|s603|s5100|s5110|s601|s7100a|p3000f|p3000s|p101|p200s|p1000m|p200m|p9100|p1000s|s6600b|s908|p1000|p300|s18|s6600|s9100)\b|tablet (spirit 7|essentia|galatea|fusion|onix 7|landa|titan|scooby|deox|stella|themis|argon|unique 7|sygnus|hexen|finity 7|cream|cream x2|jade|neon 7|neron 7|kandy|scape|saphyr 7|rebel|biox|rebel|rebel 8gb|myst|draco 7|myst|tab7-004|myst|tadeo jones|tablet boing|arrow|draco dual cam|aurix|mint|amity|revolution|finity 9|neon 9|t9w|amity 4gb dual cam|stone 4gb|stone 8gb|andromeda|silken|x2|andromeda ii|halley|flame|saphyr 9,7|touch 8|planet|triton|unique 10|hexen 10|memphis 4gb|memphis 8gb|onix 10)|fx2 pad7|fx2 pad10|kidspad 701|pad[ ]?712|pad[ ]?714|pad[ ]?716|pad[ ]?717|pad[ ]?718|pad[ ]?720|pad[ ]?721|pad[ ]?722|pad[ ]?790|pad[ ]?792|pad[ ]?900|pad[ ]?9715d|pad[ ]?9716dr|pad[ ]?9718dr|pad[ ]?9719qr|pad[ ]?9720qr|telepad1030|telepad1032|telepad730|telepad731|telepad732|telepad735q|telepad830|telepad9730|telepad795|megapad 1331|megapad 1851|megapad 2151|viewpad 10pi|viewpad 10e|viewpad 10s|viewpad e72|viewpad7|viewpad e100|viewpad 7e|viewsonic vb733|vb100a|loox|xeno10|odys[ -](space|evo|xpress|noon)|\bxelio\b|xelio10pro|xelio7phonetab|xelio10extreme|xeliopt2|neo_quad10|captiva pad|nettab|nt-3702|nt-3702s|nt-3702s|nt-3603p|nt-3603p|nt-0704s|nt-0704s|nt-3805c|nt-3805c|nt-0806c|nt-0806c|nt-0909t|nt-0909t|nt-0907s|nt-0907s|nt-0902s|nt-0902s|t98 4g|\bp80\b|\bx90hd\b|x98 air|x98 air 3g|\bx89\b|p80 3g|\bx80h\b|p98 air|\bx89hd\b|p98 3g|\bp90hd\b|p89 3g|x98 3g|\bp70h\b|p79hd 3g|g18d 3g|\bp79hd\b|\bp89s\b|\ba88\b|\bp10hd\b|\bp19hd\b|g18 3g|\bp78hd\b|\ba78\b|\bp75\b|g17s 3g|g17h 3g|\bp85t\b|\bp90\b|\bp11\b|\bp98t\b|\bp98hd\b|\bg18d\b|\bp85s\b|\bp11hd\b|\bp88s\b|\ba80hd\b|\ba80se\b|\ba10h\b|\bp89\b|\bp78s\b|\bg18\b|\bp85\b|\ba70h\b|\ba70\b|\bg17\b|\bp18\b|\ba80s\b|\ba11s\b|\bp88hd\b|\ba80h\b|\bp76s\b|\bp76h\b|\bp98\b|\ba10hd\b|\bp78\b|\bp88\b|\ba11\b|\ba10t\b|\bp76a\b|\bp76t\b|\bp76e\b|\bp85hd\b|\bp85a\b|\bp86\b|\bp75hd\b|\bp76v\b|\ba12\b|\bp75a\b|\ba15\b|\bp76ti\b|\bp81hd\b|\ba10\b|\bt760ve\b|\bt720hd\b|\bp76\b|\bp73\b|\bp71\b|\bp72\b|\bt720se\b|\bc520ti\b|\bt760\b|\bt720ve\b|t720-3ge|t720-wifi|tpc-pa762|endeavour 800ng|endeavour 1010|\b(idx10|idx9|idx8|idx7|idxd7|idxd8|idsq8|idsq7|idsq8|idsd10|idnd7|3ts804h|idsq11|idj7|ids10)\b|aria_mini_wifi|aria[ _]mini|evolio x10|evolio x7|evolio x8|\bevotab\b|\bneura\b|qpad e704|\bivorys\b|e-tab ivory|ct695|ct888|ct[\s]?910|ct7 tab|ct9 tab|ct3 tab|ct2 tab|ct1 tab|c820|c720|\bct-1\b|\bmi pad\b|\bhm note 1w\b|nibiru m1|nibiru jupiter one|nexo nova|nexo 10|nexo avio|nexo free|nexo go|nexo evo|nexo 3g|nexo smart|nexo kiddo|nexo mobi|ubislate[\s]?7c|pocketbook|hudl ht7s3|t-hub2|android.*\b97d\b|tablet(?!.*pc)|bntv250a|mid-wcdma|logicpd zoom2|\ba7eb\b|catnova8|a1_07|ct704|ct1002|\bm721\b|rk30sdk|\bevotab\b|m758a|et904|alumium10|smartfren tab|endeavour 1010|tablet-pc-4|tagi tab|\bm6pro\b|ct1020w|arc 10hd|\bjolla\b/.freeze
|
|
6
|
+
|
|
7
|
+
def self.is_a_tablet_device? user_agent
|
|
8
|
+
!!(user_agent.to_s.downcase =~ TABLET_USER_AGENTS)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mobile_fu
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.4.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Brendan Lim
|
|
8
|
+
- Ben Langfeld
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rails
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">="
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '0'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: rack-mobile-detect
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: mocha
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: rdoc
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: httparty
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
84
|
+
description: Want to automatically detect mobile devices that access your Rails application?
|
|
85
|
+
Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry,
|
|
86
|
+
iPhone, iPad, Nokia, etc. and it will automatically adjust the format of the request
|
|
87
|
+
from :html to :mobile.
|
|
88
|
+
email:
|
|
89
|
+
- brendangl@gmail.com, ben@langfeld.me
|
|
90
|
+
executables: []
|
|
91
|
+
extensions: []
|
|
92
|
+
extra_rdoc_files: []
|
|
93
|
+
files:
|
|
94
|
+
- CHANGELOG
|
|
95
|
+
- Gemfile
|
|
96
|
+
- MIT-LICENSE
|
|
97
|
+
- README.md
|
|
98
|
+
- Rakefile
|
|
99
|
+
- lib/mobile-fu.rb
|
|
100
|
+
- lib/mobile-fu/helper.rb
|
|
101
|
+
- lib/mobile-fu/tablet.rb
|
|
102
|
+
- lib/mobile-fu/version.rb
|
|
103
|
+
homepage: https://github.com/benlangfeld/mobile-fu
|
|
104
|
+
licenses: []
|
|
105
|
+
metadata: {}
|
|
106
|
+
post_install_message:
|
|
107
|
+
rdoc_options: []
|
|
108
|
+
require_paths:
|
|
109
|
+
- lib
|
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: '0'
|
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
requirements: []
|
|
121
|
+
rubyforge_project:
|
|
122
|
+
rubygems_version: 2.5.2
|
|
123
|
+
signing_key:
|
|
124
|
+
specification_version: 4
|
|
125
|
+
summary: Automatically detect mobile requests from mobile devices in your Rails application.
|
|
126
|
+
test_files: []
|