mobile-fu 0.1.2 → 0.2.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.
- data/lib/mobile-fu.rb +2 -2
- data/lib/mobile-fu/helper.rb +17 -2
- data/lib/mobile-fu/version.rb +1 -1
- metadata +2 -3
- data/lib/mobile-fu/mobilized_styles.rb +0 -26
data/lib/mobile-fu.rb
CHANGED
@@ -3,7 +3,6 @@ require 'rack/mobile-detect'
|
|
3
3
|
|
4
4
|
module MobileFu
|
5
5
|
autoload :Helper, 'mobile-fu/helper'
|
6
|
-
autoload :MobilizedStyles, 'mobile-fu/mobilized_styles'
|
7
6
|
|
8
7
|
class Railtie < Rails::Railtie
|
9
8
|
initializer "mobile-fu.configure" do |app|
|
@@ -35,7 +34,6 @@ module ActionController
|
|
35
34
|
# has_mobile_fu false
|
36
35
|
# end
|
37
36
|
#
|
38
|
-
|
39
37
|
def has_mobile_fu(set_request_format = true)
|
40
38
|
include ActionController::MobileFu::InstanceMethods
|
41
39
|
|
@@ -102,3 +100,5 @@ module ActionController
|
|
102
100
|
end
|
103
101
|
|
104
102
|
ActionController::Base.send :include, ActionController::MobileFu
|
103
|
+
ActionView::Base.send :include, MobileFu::Helper
|
104
|
+
ActionView::Base.send :alias_method_chain, :stylesheet_link_tag, :mobilization
|
data/lib/mobile-fu/helper.rb
CHANGED
@@ -3,7 +3,22 @@ module MobileFu
|
|
3
3
|
def js_enabled_mobile_device?
|
4
4
|
is_device?('iphone') || is_device?('ipod') || is_device?('ipad') || is_device?('mobileexplorer') || is_device?('android')
|
5
5
|
end
|
6
|
+
|
7
|
+
def stylesheet_link_tag_with_mobilization(*sources)
|
8
|
+
mobilized_sources = Array.new
|
9
|
+
sources.each do |source|
|
10
|
+
mobilized_sources << source
|
11
|
+
|
12
|
+
device_names = is_mobile_device? ? ['mobile', mobile_device.downcase] : []
|
13
|
+
|
14
|
+
device_names.compact.each do |device_name|
|
15
|
+
possible_source = "#{source.to_s.gsub '.css', ''}_#{device_name}.css"
|
16
|
+
path = File.join config.stylesheets_dir, possible_source
|
17
|
+
mobilized_sources << possible_source if File.exist?(path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
stylesheet_link_tag_without_mobilization *mobilized_sources
|
22
|
+
end
|
6
23
|
end
|
7
24
|
end
|
8
|
-
|
9
|
-
ActionView::Base.send :include, MobileFu::Helper
|
data/lib/mobile-fu/version.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 1
|
8
7
|
- 2
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brendan Lim
|
@@ -88,7 +88,6 @@ files:
|
|
88
88
|
- Rakefile
|
89
89
|
- lib/mobile-fu.rb
|
90
90
|
- lib/mobile-fu/helper.rb
|
91
|
-
- lib/mobile-fu/mobilized_styles.rb
|
92
91
|
- lib/mobile-fu/version.rb
|
93
92
|
- mobile-fu.gemspec
|
94
93
|
- spec/mobilized_styles_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module MobileFu
|
2
|
-
module MobilizedStyles
|
3
|
-
|
4
|
-
# This logic was taken from Michael Bleigh's browserized styles
|
5
|
-
# with modification to work for mobile browsers.
|
6
|
-
|
7
|
-
def device_name
|
8
|
-
@device_name ||= request.headers['X_MOBILE_DEVICE']
|
9
|
-
end
|
10
|
-
|
11
|
-
def stylesheet_link_tag_with_mobilization(*sources)
|
12
|
-
mobilized_sources = Array.new
|
13
|
-
sources.each do |source|
|
14
|
-
mobilized_sources << source
|
15
|
-
|
16
|
-
path = File.join config.stylesheets_dir, "#{source.to_s.gsub '.css', ''}_#{device_name}.css"
|
17
|
-
mobilized_sources << possible_source if File.exist?(path)
|
18
|
-
end
|
19
|
-
|
20
|
-
stylesheet_link_tag *mobilized_sources
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
ActionView::Base.send :include, MobileFu::MobilizedStyles
|
26
|
-
ActionView::Base.send :alias_method_chain, :stylesheet_link_tag, :mobilization
|