jpmobile 0.0.3 → 0.0.4
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/CHANGELOG +4 -0
- data/README +8 -5
- data/Rakefile +6 -7
- data/lib/jpmobile.rb +12 -2
- data/lib/jpmobile/email.rb +19 -0
- data/lib/jpmobile/filter.rb +1 -15
- data/lib/jpmobile/helpers.rb +76 -34
- data/lib/jpmobile/hook_action_controller.rb +1 -0
- data/lib/jpmobile/hook_action_view.rb +79 -28
- data/lib/jpmobile/mobile/abstract_mobile.rb +13 -1
- data/lib/jpmobile/mobile/au.rb +2 -0
- data/lib/jpmobile/mobile/docomo.rb +3 -1
- data/lib/jpmobile/mobile/emobile.rb +2 -0
- data/lib/jpmobile/mobile/softbank.rb +7 -1
- data/lib/jpmobile/mobile/willcom.rb +4 -0
- data/lib/jpmobile/mobile/z_display_info_docomo.rb +85 -2
- data/lib/jpmobile/mobile/z_ip_addresses_au.rb +40 -25
- data/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +3 -1
- data/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +97 -76
- data/lib/jpmobile/position.rb +8 -2
- data/lib/jpmobile/request_with_mobile.rb +1 -1
- data/lib/jpmobile/util.rb +21 -0
- data/lib/jpmobile/version.rb +1 -1
- data/test/au_test.rb +1 -1
- data/tools/update_display_info_docomo.rb +1 -0
- data/tools/update_ip_addresses_willcom.rb +2 -1
- metadata +36 -82
- data/doc/classes/ActionController.html +0 -120
- data/doc/classes/ActionController/AbstractRequest.html +0 -118
- data/doc/classes/ActionController/CgiRequest.html +0 -160
- data/doc/classes/ActionView.html +0 -101
- data/doc/classes/DatumConv.html +0 -324
- data/doc/classes/Jpmobile/Display.html +0 -333
- data/doc/classes/Jpmobile/Emoticon.html +0 -467
- data/doc/classes/Jpmobile/Filter.html +0 -120
- data/doc/classes/Jpmobile/Filter/ApplyOnlyForMobile.html +0 -172
- data/doc/classes/Jpmobile/Filter/Base.html +0 -269
- data/doc/classes/Jpmobile/Filter/Emoticon.html +0 -118
- data/doc/classes/Jpmobile/Filter/Emoticon/Inner.html +0 -184
- data/doc/classes/Jpmobile/Filter/Emoticon/Outer.html +0 -207
- data/doc/classes/Jpmobile/Filter/FilterTable.html +0 -178
- data/doc/classes/Jpmobile/Filter/HankakuKana.html +0 -126
- data/doc/classes/Jpmobile/Filter/Sjis.html +0 -271
- data/doc/classes/Jpmobile/Helpers.html +0 -588
- data/doc/classes/Jpmobile/Mobile.html +0 -150
- data/doc/classes/Jpmobile/Mobile/AbstractMobile.html +0 -389
- data/doc/classes/Jpmobile/Mobile/Au.html +0 -420
- data/doc/classes/Jpmobile/Mobile/Ddipocket.html +0 -138
- data/doc/classes/Jpmobile/Mobile/Docomo.html +0 -411
- data/doc/classes/Jpmobile/Mobile/Emobile.html +0 -183
- data/doc/classes/Jpmobile/Mobile/Jphone.html +0 -212
- data/doc/classes/Jpmobile/Mobile/Softbank.html +0 -344
- data/doc/classes/Jpmobile/Mobile/Vodafone.html +0 -176
- data/doc/classes/Jpmobile/Mobile/Willcom.html +0 -211
- data/doc/classes/Jpmobile/Position.html +0 -384
- data/doc/classes/Jpmobile/RequestWithMobile.html +0 -263
- data/doc/created.rid +0 -1
- data/doc/files/CHANGELOG.html +0 -110
- data/doc/files/README.html +0 -455
- data/doc/files/lib/jpmobile/datum_conv_rb.html +0 -110
- data/doc/files/lib/jpmobile/emoticon/au_rb.html +0 -124
- data/doc/files/lib/jpmobile/emoticon/conversion_table_rb.html +0 -124
- data/doc/files/lib/jpmobile/emoticon/docomo_rb.html +0 -119
- data/doc/files/lib/jpmobile/emoticon/softbank_rb.html +0 -119
- data/doc/files/lib/jpmobile/emoticon/z_combine_rb.html +0 -101
- data/doc/files/lib/jpmobile/emoticon_rb.html +0 -101
- data/doc/files/lib/jpmobile/filter_rb.html +0 -115
- data/doc/files/lib/jpmobile/helpers_rb.html +0 -105
- data/doc/files/lib/jpmobile/hook_abstract_request_rb.html +0 -108
- data/doc/files/lib/jpmobile/hook_action_controller_rb.html +0 -101
- data/doc/files/lib/jpmobile/hook_action_view_rb.html +0 -110
- data/doc/files/lib/jpmobile/mobile/abstract_mobile_rb.html +0 -108
- data/doc/files/lib/jpmobile/mobile/au_rb.html +0 -112
- data/doc/files/lib/jpmobile/mobile/display_rb.html +0 -111
- data/doc/files/lib/jpmobile/mobile/docomo_rb.html +0 -105
- data/doc/files/lib/jpmobile/mobile/emobile_rb.html +0 -105
- data/doc/files/lib/jpmobile/mobile/softbank_rb.html +0 -115
- data/doc/files/lib/jpmobile/mobile/willcom_rb.html +0 -108
- data/doc/files/lib/jpmobile/mobile/z_display_info_docomo_rb.html +0 -114
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_au_rb.html +0 -114
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_docomo_rb.html +0 -124
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_emobile_rb.html +0 -111
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_softbank_rb.html +0 -124
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_willcom_rb.html +0 -114
- data/doc/files/lib/jpmobile/position_rb.html +0 -105
- data/doc/files/lib/jpmobile/request_with_mobile_rb.html +0 -111
- data/doc/files/lib/jpmobile/trans_sid_rb.html +0 -118
- data/doc/files/lib/jpmobile/version_rb.html +0 -101
- data/doc/files/lib/jpmobile_rb.html +0 -101
- data/doc/fr_class_index.html +0 -55
- data/doc/fr_file_index.html +0 -58
- data/doc/fr_method_index.html +0 -134
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
data/CHANGELOG
CHANGED
data/README
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
== インストール
|
|
18
18
|
|
|
19
|
-
===
|
|
19
|
+
=== pluginとしてインストールする場合
|
|
20
20
|
|
|
21
21
|
リリース版:
|
|
22
22
|
% ./script/plugin install http://jpmobile.rubyforge.org/svn/tags/rel-x.x.x/jpmobile
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
# gem install jpmobile
|
|
31
31
|
としてgemをインストールした後
|
|
32
|
+
|
|
32
33
|
RAILS_ROOT/config/environment.rb の Rails::Initializer.run do |config| 〜 end 内に
|
|
33
34
|
config.gem "jpmobile"
|
|
34
35
|
の行を追加する。
|
|
@@ -98,7 +99,7 @@ BUG: 現状、上記の例では index.rhtml が存在しない場合に振り
|
|
|
98
99
|
when Jpmobile::Mobile::Willcom
|
|
99
100
|
# for Willcom
|
|
100
101
|
when Jpmobile::Mobile::Emobile
|
|
101
|
-
# for
|
|
102
|
+
# for EMOBILE
|
|
102
103
|
else
|
|
103
104
|
# for PC
|
|
104
105
|
end
|
|
@@ -129,15 +130,15 @@ BUG: 現状、上記の例では index.rhtml が存在しない場合に振り
|
|
|
129
130
|
|
|
130
131
|
=== 端末情報の取得
|
|
131
132
|
|
|
132
|
-
端末側から通知されている場合、request.ident で
|
|
133
|
+
端末側から通知されている場合、request.mobile.ident で
|
|
133
134
|
契約に固有の識別子もしくは端末の製造番号を取得できる。
|
|
134
135
|
両方存在する場合は契約に固有のIDが優先される。
|
|
135
136
|
|
|
136
|
-
* 契約に固有のID (request.ident_subscriber)
|
|
137
|
+
* 契約に固有のID (request.mobile.ident_subscriber)
|
|
137
138
|
* au: EZ番号(サブスクライバ番号)
|
|
138
139
|
* DoCoMo: FOMAカード製造番号
|
|
139
140
|
* EMOBILE: EMnet対応端末から通知されるユニークなユーザID
|
|
140
|
-
* 端末製造番号 (request.ident_device)
|
|
141
|
+
* 端末製造番号 (request.mobile.ident_device)
|
|
141
142
|
* DoCoMo: 端末製造番号(FOMA, MOVA)
|
|
142
143
|
* SoftBank: 製造番号
|
|
143
144
|
|
|
@@ -203,6 +204,8 @@ mobile_filterを有効にすると以下の処理が自動で行われる。
|
|
|
203
204
|
* rails
|
|
204
205
|
* rack
|
|
205
206
|
* hpricot
|
|
207
|
+
* rspec
|
|
208
|
+
* rspec-rails
|
|
206
209
|
* spec-fixtures
|
|
207
210
|
|
|
208
211
|
== リンク
|
data/Rakefile
CHANGED
|
@@ -29,7 +29,7 @@ RDOC_OPTS = ['--quiet', '--title', "jpmobile documentation",
|
|
|
29
29
|
"--inline-source"]
|
|
30
30
|
|
|
31
31
|
desc "Packages up jpmobile gem."
|
|
32
|
-
task :default => [:test,
|
|
32
|
+
task :default => [:test, :spec]
|
|
33
33
|
task :package => [:clean]
|
|
34
34
|
|
|
35
35
|
desc 'Default: run unit tests.'
|
|
@@ -70,10 +70,10 @@ spec =
|
|
|
70
70
|
s.bindir = "bin"
|
|
71
71
|
s.require_path = "lib"
|
|
72
72
|
|
|
73
|
-
s.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
s.add_runtime_dependency('actionpack', '>=2.2.2')
|
|
74
|
+
s.add_development_dependency('rspec', '>=1.1.12')
|
|
75
|
+
s.add_development_dependency('rspec-rails', '>=1.1.12')
|
|
76
|
+
s.add_development_dependency('rspec-fixture', '>=0.0.2')
|
|
77
77
|
|
|
78
78
|
s.files = %w(README CHANGELOG Rakefile) +
|
|
79
79
|
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
|
@@ -101,7 +101,7 @@ end
|
|
|
101
101
|
|
|
102
102
|
desc "Publish the API documentation"
|
|
103
103
|
task :pdoc => [:rdoc] do
|
|
104
|
-
|
|
104
|
+
sh "rsync -azv --delete doc/ dara@rubyforge.org:/var/www/gforge-projects/jpmobile/rdoc/"
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
desc "Update misc tables"
|
|
@@ -120,5 +120,4 @@ end
|
|
|
120
120
|
|
|
121
121
|
# setup RSpec tasks
|
|
122
122
|
RAILS_ROOT = '.'
|
|
123
|
-
load 'vendor/plugins/rspec-rails/tasks/rspec.rake'
|
|
124
123
|
load 'tasks/jpmobile_tasks.rake'
|
data/lib/jpmobile.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
|
2
2
|
|
|
3
3
|
module Jpmobile
|
|
4
|
+
autoload :Email , 'jpmobile/email'
|
|
4
5
|
autoload :Emoticon, 'jpmobile/emoticon'
|
|
5
6
|
autoload :Position, 'jpmobile/position'
|
|
6
7
|
autoload :RequestWithMobile, 'jpmobile/request_with_mobile'
|
|
8
|
+
autoload :Util, 'jpmobile/util'
|
|
7
9
|
|
|
8
10
|
module Mobile
|
|
9
11
|
autoload :Docomo, 'jpmobile/mobile/docomo'
|
|
@@ -14,6 +16,14 @@ module Jpmobile
|
|
|
14
16
|
autoload :Emobile, 'jpmobile/mobile/emobile'
|
|
15
17
|
autoload :Willcom, 'jpmobile/mobile/willcom'
|
|
16
18
|
autoload :Ddipocket, 'jpmobile/mobile/willcom'
|
|
19
|
+
|
|
20
|
+
def self.carriers
|
|
21
|
+
@carriers ||= constants
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.carriers=(ary)
|
|
25
|
+
@carriers = ary
|
|
26
|
+
end
|
|
17
27
|
end
|
|
18
28
|
end
|
|
19
29
|
|
|
@@ -26,7 +36,7 @@ end
|
|
|
26
36
|
end
|
|
27
37
|
|
|
28
38
|
if defined? RAILS_ENV
|
|
29
|
-
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'jpmobile/*.rb'))].sort.each { |lib|
|
|
30
|
-
require lib
|
|
39
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'jpmobile/*.rb'))].sort.each { |lib|
|
|
40
|
+
require lib
|
|
31
41
|
}
|
|
32
42
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# =メールアドレスモジュール
|
|
2
|
+
#
|
|
3
|
+
module Jpmobile
|
|
4
|
+
# email関連の処理
|
|
5
|
+
module Email
|
|
6
|
+
|
|
7
|
+
# メールアドレスよりキャリア情報を取得する
|
|
8
|
+
# _param1_:: email メールアドレス
|
|
9
|
+
# return :: Jpmobile::Mobileで定義されている携帯キャリアクラス
|
|
10
|
+
def self.detect(email)
|
|
11
|
+
Jpmobile::Mobile.carriers.each do |const|
|
|
12
|
+
c = Jpmobile::Mobile.const_get(const)
|
|
13
|
+
return c if c::MAIL_ADDRESS_REGEXP && email =~ c::MAIL_ADDRESS_REGEXP
|
|
14
|
+
end
|
|
15
|
+
nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/jpmobile/filter.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Jpmobile
|
|
|
33
33
|
@counter += 1
|
|
34
34
|
return unless @counter == 1
|
|
35
35
|
if respond_to?(:to_internal) && apply_incoming?(controller)
|
|
36
|
-
|
|
36
|
+
Util.deep_apply(controller.params) do |value|
|
|
37
37
|
value = to_internal(value, controller)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -51,20 +51,6 @@ module Jpmobile
|
|
|
51
51
|
def apply_incoming?(controller); true; end
|
|
52
52
|
# 出力時(response.body)にこのフィルタを適用するべきか
|
|
53
53
|
def apply_outgoing?(controller); true; end
|
|
54
|
-
private
|
|
55
|
-
# ハッシュ等をなめる。
|
|
56
|
-
def deep_each(obj, &proc)
|
|
57
|
-
if obj.is_a? Hash
|
|
58
|
-
obj.each_pair do |key, value|
|
|
59
|
-
obj[key] = deep_each(value, &proc)
|
|
60
|
-
end
|
|
61
|
-
elsif obj.is_a? Array
|
|
62
|
-
obj.collect!{|value| deep_each(value, &proc)}
|
|
63
|
-
elsif not (obj==nil || obj.is_a?(TrueClass) || obj.is_a?(FalseClass))
|
|
64
|
-
obj = obj.to_param if obj.respond_to?(:to_param)
|
|
65
|
-
proc.call(obj)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
54
|
end
|
|
69
55
|
|
|
70
56
|
# 携帯電話の場合にのみ適用したい場合に Jpmobile::Base の派生クラスに include する。
|
data/lib/jpmobile/helpers.rb
CHANGED
|
@@ -13,8 +13,11 @@ module Jpmobile
|
|
|
13
13
|
options = str
|
|
14
14
|
str = nil
|
|
15
15
|
end
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
show_all = nil
|
|
17
|
+
if options.is_a?(Hash)
|
|
18
|
+
options = options.symbolize_keys
|
|
19
|
+
show_all = options.delete(:show_all)
|
|
20
|
+
end
|
|
18
21
|
|
|
19
22
|
# TODO: コード汚い
|
|
20
23
|
s = []
|
|
@@ -38,22 +41,30 @@ module Jpmobile
|
|
|
38
41
|
if show_all || request.mobile.instance_of?(Mobile::Willcom)
|
|
39
42
|
s << willcom_location_link_to(str||"Willcom", options)
|
|
40
43
|
end
|
|
41
|
-
return s.join("<br
|
|
44
|
+
return s.join("<br>\n")
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
# DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。
|
|
45
48
|
def docomo_foma_gps_link_to(str, options={})
|
|
46
|
-
|
|
47
|
-
options
|
|
48
|
-
|
|
49
|
+
url = options
|
|
50
|
+
if options.is_a?(Hash)
|
|
51
|
+
options = options.symbolize_keys
|
|
52
|
+
options[:only_path] = false
|
|
53
|
+
url = url_for(options)
|
|
54
|
+
end
|
|
55
|
+
return %{<a href="#{url}" lcs>#{str}</a>}
|
|
49
56
|
end
|
|
50
57
|
|
|
51
58
|
# DoCoMoでオープンiエリアを取得するためのURLを返す。
|
|
52
59
|
def docomo_openiarea_url_for(options={})
|
|
53
|
-
|
|
54
|
-
options
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
url = options
|
|
61
|
+
if options.is_a?(Hash)
|
|
62
|
+
options = options.symbolize_keys
|
|
63
|
+
options[:only_path] = false
|
|
64
|
+
posinfo = options.delete(:posinfo) || "1" # 基地局情報を元に測位した緯度経度情報を要求
|
|
65
|
+
url = url_for(options)
|
|
66
|
+
end
|
|
67
|
+
return "http://w1m.docomo.ne.jp/cp/iarea?ecode=OPENAREACODE&msn=OPENAREAKEY&posinfo=#{posinfo}&nl=#{CGI.escape(url)}"
|
|
57
68
|
end
|
|
58
69
|
|
|
59
70
|
# DoCoMoでオープンiエリアを取得するためのリンクを返す。
|
|
@@ -63,25 +74,39 @@ module Jpmobile
|
|
|
63
74
|
|
|
64
75
|
# DoCoMoで端末製造番号等を取得するためのリンクを返す。
|
|
65
76
|
def docomo_utn_link_to(str, options={})
|
|
66
|
-
|
|
67
|
-
options
|
|
68
|
-
|
|
77
|
+
url = options
|
|
78
|
+
if options.is_a?(Hash)
|
|
79
|
+
options = options.symbolize_keys
|
|
80
|
+
options[:only_path] = false
|
|
81
|
+
url = url_for(options)
|
|
82
|
+
end
|
|
83
|
+
return %{<a href="#{url}" utn>#{str}</a>}
|
|
69
84
|
end
|
|
70
85
|
|
|
71
86
|
# DoCoMoでiモードIDを取得するためのリンクを返す。
|
|
72
87
|
def docomo_guid_link_to(str, options={})
|
|
73
|
-
|
|
74
|
-
options
|
|
75
|
-
|
|
88
|
+
url = options
|
|
89
|
+
if options.is_a?(Hash)
|
|
90
|
+
options = options.symbolize_keys
|
|
91
|
+
options[:guid] = "ON"
|
|
92
|
+
url = url_for(options)
|
|
93
|
+
end
|
|
94
|
+
return link_to_url(str, url)
|
|
76
95
|
end
|
|
77
96
|
|
|
78
97
|
# au GPS位置情報を取得するためのURLを返す。
|
|
79
98
|
def au_gps_url_for(options={})
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
99
|
+
url = options
|
|
100
|
+
datum = 0 # 0:wgs84, 1:tokyo
|
|
101
|
+
unit = 0 # 0:dms, 1:deg
|
|
102
|
+
if options.is_a?(Hash)
|
|
103
|
+
options = options.symbolize_keys
|
|
104
|
+
options[:only_path] = false
|
|
105
|
+
datum = (options.delete(:datum) || 0 ).to_i # 0:wgs84, 1:tokyo
|
|
106
|
+
unit = (options.delete(:unit) || 0 ).to_i # 0:dms, 1:deg
|
|
107
|
+
url = url_for(options)
|
|
108
|
+
end
|
|
109
|
+
return "device:gpsone?url=#{CGI.escape(url)}&ver=1&datum=#{datum}&unit=#{unit}&acry=0&number=0"
|
|
85
110
|
end
|
|
86
111
|
|
|
87
112
|
# au GPS位置情報を取得するためのリンクを返す。
|
|
@@ -91,9 +116,13 @@ module Jpmobile
|
|
|
91
116
|
|
|
92
117
|
# au 簡易位置情報を取得するためのURLを返す。
|
|
93
118
|
def au_location_url_for(options={})
|
|
94
|
-
|
|
95
|
-
options
|
|
96
|
-
|
|
119
|
+
url = options
|
|
120
|
+
if options.is_a?(Hash)
|
|
121
|
+
options = options.symbolize_keys
|
|
122
|
+
options[:only_path] = false
|
|
123
|
+
url = url_for(options)
|
|
124
|
+
end
|
|
125
|
+
return "device:location?url=#{CGI.escape(url)}"
|
|
97
126
|
end
|
|
98
127
|
|
|
99
128
|
# au 簡易位置情報を取得するためのリンクを返す。
|
|
@@ -103,17 +132,26 @@ module Jpmobile
|
|
|
103
132
|
|
|
104
133
|
# J-PHONE 位置情報 (基地局) を取得するためのリンクを返す。
|
|
105
134
|
def jphone_location_link_to(str,options={})
|
|
106
|
-
|
|
107
|
-
options
|
|
108
|
-
|
|
135
|
+
url = options
|
|
136
|
+
if options.is_a?(Hash)
|
|
137
|
+
options = options.symbolize_keys
|
|
138
|
+
options[:only_path] = false
|
|
139
|
+
url = url_for(options)
|
|
140
|
+
end
|
|
141
|
+
return %{<a z href="#{url}">#{str}</a>}
|
|
109
142
|
end
|
|
110
143
|
|
|
111
144
|
# Softbank(含むVodafone 3G)で位置情報を取得するためのURLを返す。
|
|
112
145
|
def softbank_location_url_for(options={})
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
146
|
+
url = options
|
|
147
|
+
mode = "auto"
|
|
148
|
+
if options.is_a?(Hash)
|
|
149
|
+
options = options.symbolize_keys
|
|
150
|
+
options[:only_path] = false
|
|
151
|
+
mode = options[:mode] || "auto"
|
|
152
|
+
url = url_for(options)
|
|
153
|
+
end
|
|
154
|
+
return "location:#{mode}?url=#{url}"
|
|
117
155
|
end
|
|
118
156
|
|
|
119
157
|
# Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。
|
|
@@ -123,9 +161,13 @@ module Jpmobile
|
|
|
123
161
|
|
|
124
162
|
# Willcom 基地局位置情報を取得するためのURLを返す。
|
|
125
163
|
def willcom_location_url_for(options={})
|
|
126
|
-
|
|
127
|
-
options
|
|
128
|
-
|
|
164
|
+
url = options
|
|
165
|
+
if options.is_a?(Hash)
|
|
166
|
+
options = options.symbolize_keys
|
|
167
|
+
options[:only_path] = false
|
|
168
|
+
url = url_for(options)
|
|
169
|
+
end
|
|
170
|
+
return "http://location.request/dummy.cgi?my=#{url}&pos=$location"
|
|
129
171
|
end
|
|
130
172
|
|
|
131
173
|
# Willcom 基地局位置情報を取得するためのリンクを返す。
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
ActionView::Base.class_eval { include Jpmobile::Helpers }
|
|
9
9
|
#:startdoc:
|
|
10
10
|
|
|
11
|
+
require 'action_pack'
|
|
12
|
+
require 'action_view'
|
|
13
|
+
|
|
11
14
|
# ActionView::Base を拡張して携帯からのアクセスの場合に携帯向けビューを優先表示する。
|
|
12
15
|
# Vodafone携帯(request.mobile == Jpmobile::Mobile::Vodafone)の場合、
|
|
13
16
|
# index_mobile_vodafone.rhtml
|
|
@@ -19,51 +22,99 @@ ActionView::Base.class_eval { include Jpmobile::Helpers }
|
|
|
19
22
|
# (ダミーファイルを置くことで回避可能)。
|
|
20
23
|
|
|
21
24
|
class ActionView::Base #:nodoc:
|
|
22
|
-
|
|
23
|
-
alias render_partial_without_jpmobile render_partial #:nodoc:
|
|
25
|
+
delegate :default_url_options, :to => :controller unless respond_to?(:default_url_options)
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if ::ActionPack::VERSION::MAJOR >=2 and ::ActionPack::VERSION::MINOR >= 2
|
|
28
|
+
### Rails 2.2 or higher
|
|
29
|
+
alias _pick_template_without_jpmobile _pick_template #:nodoc:
|
|
30
|
+
alias render_partial_without_jpmobile render_partial #:nodoc:
|
|
31
|
+
|
|
32
|
+
def _pick_template(template_path)
|
|
33
|
+
mobile_path = mobile_template_path(template_path)
|
|
34
|
+
return mobile_path.nil? ? _pick_template_without_jpmobile(template_path) :
|
|
35
|
+
_pick_template_without_jpmobile(mobile_path)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def render_partial(options = {}) #:nodoc:
|
|
39
|
+
case partial_path = options[:partial]
|
|
40
|
+
when String, Symbol, NilClass
|
|
41
|
+
mobile_path = mobile_template_path(partial_path, true)
|
|
42
|
+
options = options.merge(:partial => mobile_path) if mobile_path
|
|
43
|
+
end
|
|
44
|
+
render_partial_without_jpmobile(options)
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
### Rails 2.1 or lower
|
|
48
|
+
alias render_file_without_jpmobile render_file #:nodoc:
|
|
49
|
+
alias render_partial_without_jpmobile render_partial #:nodoc:
|
|
50
|
+
|
|
51
|
+
def render_file(template_path, use_full_path = true, local_assigns = {})
|
|
52
|
+
mobile_path = mobile_template_path(template_path)
|
|
53
|
+
return mobile_path.nil? ? render_file_without_jpmobile(template_path, use_full_path, local_assigns) :
|
|
54
|
+
render_file_without_jpmobile(mobile_path, use_full_path, local_assigns)
|
|
55
|
+
end
|
|
30
56
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
def render_partial(partial_path, object_assigns = nil, local_assigns = {}) #:nodoc:
|
|
58
|
+
mobile_path = mobile_template_path(partial_path, true) if partial_path.class === "String"
|
|
59
|
+
return mobile_path.nil? ? render_partial_without_jpmobile(partial_path, object_assigns, local_assigns) :
|
|
60
|
+
render_partial_without_jpmobile(mobile_path, object_assigns, local_assigns)
|
|
61
|
+
end
|
|
35
62
|
end
|
|
36
63
|
|
|
37
|
-
def
|
|
38
|
-
if controller.is_a?(ActionController::Base) && m = controller.request.mobile
|
|
64
|
+
def mobile_template_candidates
|
|
39
65
|
candidates = []
|
|
40
|
-
c =
|
|
66
|
+
c = controller.request.mobile.class
|
|
41
67
|
while c != Jpmobile::Mobile::AbstractMobile
|
|
42
68
|
candidates << "mobile_"+c.to_s.split(/::/).last.downcase
|
|
43
69
|
c = c.superclass
|
|
44
70
|
end
|
|
45
71
|
candidates << "mobile"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def mobile_template_partial mobile_path
|
|
75
|
+
# ActionView::PartialTemplate#extract_partial_name_and_path の動作を模倣
|
|
76
|
+
if mobile_path.include?('/')
|
|
77
|
+
path = File.dirname(mobile_path)
|
|
78
|
+
partial_name = File.basename(mobile_path)
|
|
79
|
+
else
|
|
80
|
+
path = self.controller.class.controller_path
|
|
81
|
+
partial_name = mobile_path
|
|
82
|
+
end
|
|
83
|
+
File.join(path, "_#{partial_name}")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def mobile_path template_path, type
|
|
87
|
+
"#{template_path}_#{type}"
|
|
88
|
+
end
|
|
46
89
|
|
|
47
|
-
|
|
48
|
-
|
|
90
|
+
def mobile_template_path(template_path, partial=false)
|
|
91
|
+
if controller.is_a?(ActionController::Base) && m = controller.request.mobile
|
|
92
|
+
mobile_template_candidates.each do |v|
|
|
93
|
+
mpath = mobile_path template_path, v
|
|
49
94
|
if partial
|
|
50
|
-
|
|
51
|
-
if mobile_path.include?('/')
|
|
52
|
-
path = File.dirname(mobile_path)
|
|
53
|
-
partial_name = File.basename(mobile_path)
|
|
54
|
-
else
|
|
55
|
-
path = self.controller.class.controller_path
|
|
56
|
-
partial_name = mobile_path
|
|
57
|
-
end
|
|
58
|
-
full_path = File.join(path, "_#{partial_name}")
|
|
95
|
+
full_path = mobile_template_partial mpath
|
|
59
96
|
else
|
|
60
|
-
full_path =
|
|
97
|
+
full_path = mpath
|
|
61
98
|
end
|
|
62
|
-
if
|
|
63
|
-
return
|
|
99
|
+
if template_exists?(full_path)
|
|
100
|
+
return mpath
|
|
64
101
|
end
|
|
65
102
|
end
|
|
66
103
|
end
|
|
67
104
|
return nil
|
|
68
105
|
end
|
|
106
|
+
|
|
107
|
+
if ::ActionPack::VERSION::MAJOR >=2 and ::ActionPack::VERSION::MINOR >= 2
|
|
108
|
+
### Rails 2.2 or higher
|
|
109
|
+
def template_exists?(template_name)
|
|
110
|
+
send(:_pick_template_without_jpmobile, template_name) ? true : false
|
|
111
|
+
rescue ActionView::MissingTemplate
|
|
112
|
+
false
|
|
113
|
+
end
|
|
114
|
+
else
|
|
115
|
+
### Rails 2.1 or lower
|
|
116
|
+
def template_exists?(template_name)
|
|
117
|
+
finder.file_exists?(template_name)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
69
120
|
end
|