mobile_rails 0.0.2 → 0.0.3
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/README.md +80 -0
- data/lib/mobile_rails/version.rb +1 -1
- metadata +4 -4
- data/README +0 -1
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
Mobile Rails
|
2
|
+
---------------
|
3
|
+
|
4
|
+
Mobile_rails is a gem designed for integrating cross-platform mobile web application with rails application.
|
5
|
+
|
6
|
+
What mobile_rails does:
|
7
|
+
|
8
|
+
* Adding plubming for detecting mobile device browser
|
9
|
+
* Setting up a mobile mime type as rails response format
|
10
|
+
* Adding a session variable to allow user switch between mobile and web interfaces.
|
11
|
+
|
12
|
+
Mobile_rails can be used with mobile_rails_jqm which is a gem packaged jQuery Mobile 1.0 final with a mobile_rails layout generator.
|
13
|
+
|
14
|
+
How mobile_rails works:
|
15
|
+
--------------
|
16
|
+
|
17
|
+
1 Web request stays the same.
|
18
|
+
|
19
|
+
2 Mobile request comes in, mobile layout is selected and request mime format is set to .mobile.
|
20
|
+
|
21
|
+
3 User gets a mobile optimized view of your app.
|
22
|
+
|
23
|
+
4 A link/action can be used to set a session variable for viewing the full web version on mobile device.
|
24
|
+
|
25
|
+
Getting Started
|
26
|
+
---------------
|
27
|
+
|
28
|
+
Include the Gem
|
29
|
+
|
30
|
+
```
|
31
|
+
gem 'mobile_rails'
|
32
|
+
```
|
33
|
+
|
34
|
+
Run this:
|
35
|
+
|
36
|
+
```
|
37
|
+
$ bundle install
|
38
|
+
$ rails g mobile_rails:install
|
39
|
+
```
|
40
|
+
|
41
|
+
Add this in your app/controller/application_controller.rb
|
42
|
+
|
43
|
+
```
|
44
|
+
has_mobile_rails
|
45
|
+
```
|
46
|
+
|
47
|
+
Remove require_tree . from both application.js and css.js in your app/assets directory to not load mobile.js and mobile.css.
|
48
|
+
|
49
|
+
You are almost done.
|
50
|
+
Next step is to choose a javascript mobile framework you like, create a mobile.mobile.haml(or .erb) layout in your app/view/layout folder.
|
51
|
+
Then in your controller allow respond_to mobile format and treat your mobile page like normal view but with a name like 'index.mobile.haml'. Web request will render the html version and mobile request will look for the .mobile.haml file.
|
52
|
+
|
53
|
+
More Info
|
54
|
+
-------------
|
55
|
+
* A 'mobile?' helper method is added to your controller and view to detect if the user is using a mobile devise.
|
56
|
+
* 'session[:mobile_session]' is used to turn on and off mobile rendering. set to '1' for on and '0' for off.
|
57
|
+
|
58
|
+
i.e.
|
59
|
+
If you want to give user a choice to view full web version on their mobile device:
|
60
|
+
|
61
|
+
add this to your view:
|
62
|
+
|
63
|
+
```
|
64
|
+
= link_to "Web Version", home_web_url, :rel => "external"
|
65
|
+
```
|
66
|
+
|
67
|
+
then in your home_controller:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
def web
|
71
|
+
session[:mobile_session] = 0
|
72
|
+
redirect_to root_url
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
If you want to use jQuery Mobile, please checkout [mobile_rails_jqm](https://github.com/hisea/mobile_rails_jqm).
|
77
|
+
|
78
|
+
Example of how this gem can be used: [mobile_rails_example](https://github.com/hisea/mobile_rails_example)
|
79
|
+
|
80
|
+
|
data/lib/mobile_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobile_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-15 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70209047366720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70209047366720
|
25
25
|
description: Gem for easy creation of mobile enabled rails app.
|
26
26
|
email:
|
27
27
|
- zyinghai@gmail.com
|
@@ -34,7 +34,7 @@ files:
|
|
34
34
|
- CHANGELOG.md
|
35
35
|
- Gemfile
|
36
36
|
- MIT-LICENSE
|
37
|
-
- README
|
37
|
+
- README.md
|
38
38
|
- Rakefile
|
39
39
|
- init.rb
|
40
40
|
- lib/generators/mobile_rails/install/install_generator.rb
|
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Mobile Rails
|