has_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.
Files changed (3) hide show
  1. data/README.md +48 -0
  2. data/lib/has_mobile_views.rb +1 -1
  3. metadata +5 -4
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # has_mobile_views
2
+
3
+ has_mobile_views allows for rendering special versions of views and partials
4
+ for mobile devices. It'll detect those devices using the browser's HTTP_USER_AGENT
5
+ string.
6
+ The nice thing is that it falls back to the standard views/partials if there's
7
+ no dedicated mobile version available.
8
+
9
+ # Installation
10
+ ## As a gem
11
+ Add the following line to your **config/environment.rb** file:
12
+ config.gem 'has_mobile_views'
13
+
14
+ ## As a plugin
15
+ script/plugin install git://github.com/aduffeck/has_mobile_views.git
16
+
17
+ # Usage
18
+ Just call the **has_mobile_views** class method in the *ApplicationController:*
19
+
20
+ class ApplicationController < ActionController::Base
21
+ has_mobile_views
22
+ ...
23
+ end
24
+
25
+ and create a **app/mobile_views** directory.
26
+
27
+ Mobile devices will then be served the views from **app/mobile_views** if available,
28
+ e.g.
29
+
30
+ app/mobile_views/layouts/application.html.haml
31
+
32
+ will have precedence over
33
+
34
+ app/views/layouts/application.html.haml
35
+
36
+ # Helpers
37
+ has_mobile_views adds a **switch_view_mode_link** helper which will render the
38
+ appropriate link to switch to either the normal or the mobile version of your
39
+ site, depending on the mode you're currently in.
40
+
41
+ # TODO
42
+ - Test/fix Rails3 support
43
+
44
+ # Credits
45
+ has_mobile_views was created by Andre Duffeck and Thomas Schmidt.
46
+
47
+
48
+ Copyright (c) 2011 Andre Duffeck, released under the MIT license
@@ -35,7 +35,7 @@ module ActionController
35
35
  end
36
36
 
37
37
  def mobile_browser?
38
- request.env["HTTP_USER_AGENT"] && !!request.env["HTTP_USER_AGENT"][/(iPhone|iPod|iPad|Android)/]
38
+ request.env["HTTP_USER_AGENT"] && !!request.env["HTTP_USER_AGENT"][/(iPhone|iPod|Android)/]
39
39
  end
40
40
  end
41
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_mobile_views
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Andr\xC3\xA9 Duffeck"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-26 00:00:00 +01:00
18
+ date: 2011-01-28 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -32,6 +32,7 @@ files:
32
32
  - lib/has_mobile_views.rb
33
33
  - lib/has_mobile_views_helper.rb
34
34
  - lib/tasks/has_mobile_views.rake
35
+ - README.md
35
36
  - Rakefile
36
37
  - rails/init.rb
37
38
  - test/has_mobile_views_test.rb