mobile_rails 0.0.1.alpha
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/.gitignore +4 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +19 -0
- data/README +1 -0
- data/Rakefile +5 -0
- data/init.rb +1 -0
- data/lib/generators/mobile_rails/install/install_generator.rb +15 -0
- data/lib/mobile_rails/controller_additions.rb +30 -0
- data/lib/mobile_rails/version.rb +3 -0
- data/lib/mobile_rails.rb +12 -0
- data/mobile_rails.gemspec +24 -0
- data/spec/spec_helper.rb +1 -0
- metadata +70 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 Yinghai Zhao
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Mobile Rails
|
data/Rakefile
ADDED
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mobile_rails'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MobileRails
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc <<DESC
|
5
|
+
Description:
|
6
|
+
Install mobile_rails into your app.
|
7
|
+
DESC
|
8
|
+
def add_mobile_mine_type
|
9
|
+
initializer("mobile_rails.rb") do
|
10
|
+
'Mime::Type.register_alias "text/html", :mobile'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MobileRails
|
2
|
+
module ControllerAdditions
|
3
|
+
module InstanceMethods
|
4
|
+
def mobile?
|
5
|
+
request.user_agent.to_s.downcase =~ Regexp.new(MobileRails::MOBILE_USER_AGENTS)
|
6
|
+
end
|
7
|
+
|
8
|
+
def mobile_layout
|
9
|
+
mobile? ? "mobile" : 'application'
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_mobile_request
|
13
|
+
request.format = :mobile if mobile?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
module ClassMethods
|
17
|
+
def has_mobile_rails
|
18
|
+
before_filter :set_mobile_request
|
19
|
+
|
20
|
+
helper_method :mobile?
|
21
|
+
layout :mobile_layout
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
ActionController::Base.send(:extend, MobileRails::ControllerAdditions::ClassMethods)
|
29
|
+
ActionController::Base.send(:include, MobileRails::ControllerAdditions::InstanceMethods)
|
30
|
+
|
data/lib/mobile_rails.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "mobile_rails/version"
|
2
|
+
require "mobile_rails/controller_additions"
|
3
|
+
|
4
|
+
module MobileRails
|
5
|
+
MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' +
|
6
|
+
'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' +
|
7
|
+
'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' +
|
8
|
+
'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' +
|
9
|
+
'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' +
|
10
|
+
'mobile'
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "mobile_rails/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "mobile_rails"
|
7
|
+
s.version = MobileRails::VERSION
|
8
|
+
s.authors = ["Hisea"]
|
9
|
+
s.email = ["zyinghai@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/hisea/mobile_rails"
|
11
|
+
s.summary = %q{Gem for easy creation of mobile enabled rails app.}
|
12
|
+
s.description = %q{Gem for easy creation of mobile enabled rails app.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "mobile_rails"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mobile_rails'
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobile_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Hisea
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-12 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70138587269780 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70138587269780
|
25
|
+
description: Gem for easy creation of mobile enabled rails app.
|
26
|
+
email:
|
27
|
+
- zyinghai@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- .rspec
|
34
|
+
- Gemfile
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README
|
37
|
+
- Rakefile
|
38
|
+
- init.rb
|
39
|
+
- lib/generators/mobile_rails/install/install_generator.rb
|
40
|
+
- lib/mobile_rails.rb
|
41
|
+
- lib/mobile_rails/controller_additions.rb
|
42
|
+
- lib/mobile_rails/version.rb
|
43
|
+
- mobile_rails.gemspec
|
44
|
+
- spec/spec_helper.rb
|
45
|
+
homepage: https://github.com/hisea/mobile_rails
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>'
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.3.1
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project: mobile_rails
|
65
|
+
rubygems_version: 1.8.6
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Gem for easy creation of mobile enabled rails app.
|
69
|
+
test_files:
|
70
|
+
- spec/spec_helper.rb
|