mobile_views 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG.md +11 -0
- data/app/controllers/mobile_views_controller.rb +12 -6
- data/config/initializers/mime_types.rb +1 -0
- data/lib/mobile_views.rb +2 -4
- data/lib/mobile_views/version.rb +1 -1
- data/mobile_views.gemspec +1 -1
- metadata +5 -3
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
0.0.2 (2011-12-09)
|
2
|
+
------------------
|
3
|
+
* Some fixes
|
4
|
+
* Improved mobile device detection
|
5
|
+
* Added homepage to gemspec
|
6
|
+
|
7
|
+
0.0.1 (2011-12-08)
|
8
|
+
------------------
|
9
|
+
* Created MobileViews modules
|
10
|
+
* Added new mime-type: mobile
|
11
|
+
* Added class method has_mobile_views for Controllers
|
@@ -3,25 +3,31 @@ module MobileViewsController
|
|
3
3
|
module ClassMethods
|
4
4
|
|
5
5
|
def has_mobile_views(args={})
|
6
|
-
|
7
|
-
before_filter :has_mobile_views
|
8
|
-
end
|
6
|
+
before_filter :has_mobile_views
|
9
7
|
end
|
10
8
|
|
11
9
|
end
|
12
10
|
|
13
11
|
module InstanceMethods
|
12
|
+
|
13
|
+
def mobile_device?
|
14
|
+
if session[:mobile]
|
15
|
+
session[:mobile] == "1"
|
16
|
+
else
|
17
|
+
request.user_agent =~ /Mobile|webOS/
|
18
|
+
end
|
19
|
+
end
|
14
20
|
|
15
21
|
def has_mobile_views
|
16
|
-
if request.subdomain
|
17
|
-
request.format = :mobile_html
|
18
|
-
elsif request.user_agent =~ /Mobile|webOS|iPhone|iOS|Android/
|
22
|
+
if request.subdomain != 'm' && mobile_device?
|
19
23
|
if request.host =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|localhost/
|
20
24
|
raise Exception, "Can't redirect to subdomain 'm.#{request.host}'! Please use e.g. lvh.me"
|
21
25
|
else
|
22
26
|
redirect_to request.protocol + "m." + request.host_with_port + request.fullpath
|
23
27
|
end
|
24
28
|
end
|
29
|
+
session[:mobile] = params[:mobile] if params[:mobile]
|
30
|
+
request.format = :mobile if mobile_device?
|
25
31
|
end
|
26
32
|
|
27
33
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Mime::Type.register_alias "text/html", :mobile
|
data/lib/mobile_views.rb
CHANGED
data/lib/mobile_views/version.rb
CHANGED
data/mobile_views.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
|
8
8
|
s.authors = ["Patrick Bartels"]
|
9
9
|
s.email = %q{patrick@bartels.ug}
|
10
|
-
s.homepage = %q{
|
10
|
+
s.homepage = %q{https://github.com/roughneck/mobile_views}
|
11
11
|
s.description = "MobileViews description."
|
12
12
|
s.summary = "MobileViews summary."
|
13
13
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mobile_views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Patrick Bartels
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-10 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -56,12 +56,14 @@ extra_rdoc_files: []
|
|
56
56
|
|
57
57
|
files:
|
58
58
|
- .gitignore
|
59
|
+
- CHANGELOG.md
|
59
60
|
- Gemfile
|
60
61
|
- Gemfile.lock
|
61
62
|
- MIT-LICENSE
|
62
63
|
- README.md
|
63
64
|
- Rakefile
|
64
65
|
- app/controllers/mobile_views_controller.rb
|
66
|
+
- config/initializers/mime_types.rb
|
65
67
|
- lib/mobile_views.rb
|
66
68
|
- lib/mobile_views/engine.rb
|
67
69
|
- lib/mobile_views/version.rb
|
@@ -107,7 +109,7 @@ files:
|
|
107
109
|
- test/support/integration_case.rb
|
108
110
|
- test/test_helper.rb
|
109
111
|
has_rdoc: true
|
110
|
-
homepage:
|
112
|
+
homepage: https://github.com/roughneck/mobile_views
|
111
113
|
licenses: []
|
112
114
|
|
113
115
|
post_install_message:
|