jpmobile 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -3
- data/.rubocop.yml +123 -0
- data/CONTRIBUTING.md +16 -14
- data/Gemfile +6 -0
- data/Gemfile.lock +198 -0
- data/README.md +409 -0
- data/Rakefile +9 -9
- data/circle.yml +14 -0
- data/jpmobile.gemspec +9 -10
- data/lib/jpmobile.rb +6 -5
- data/lib/jpmobile/datum_conv.rb +35 -35
- data/lib/jpmobile/docomo_guid.rb +7 -8
- data/lib/jpmobile/email.rb +12 -12
- data/lib/jpmobile/emoticon.rb +85 -76
- data/lib/jpmobile/emoticon/au.rb +1284 -1284
- data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
- data/lib/jpmobile/emoticon/docomo.rb +252 -252
- data/lib/jpmobile/emoticon/google.rb +9 -9
- data/lib/jpmobile/emoticon/softbank.rb +471 -471
- data/lib/jpmobile/emoticon/unicode.rb +9 -9
- data/lib/jpmobile/emoticon/z_combine.rb +20 -23
- data/lib/jpmobile/encoding.rb +1 -1
- data/lib/jpmobile/fallback_view_selector.rb +2 -3
- data/lib/jpmobile/filter.rb +44 -47
- data/lib/jpmobile/helpers.rb +38 -38
- data/lib/jpmobile/hook_action_view.rb +7 -7
- data/lib/jpmobile/hook_test_request.rb +0 -1
- data/lib/jpmobile/lookup_context.rb +1 -2
- data/lib/jpmobile/mail.rb +156 -134
- data/lib/jpmobile/mailer.rb +4 -4
- data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
- data/lib/jpmobile/mobile/android.rb +0 -1
- data/lib/jpmobile/mobile/android_tablet.rb +0 -1
- data/lib/jpmobile/mobile/au.rb +40 -28
- data/lib/jpmobile/mobile/black_berry.rb +0 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -2
- data/lib/jpmobile/mobile/docomo.rb +47 -36
- data/lib/jpmobile/mobile/emobile.rb +1 -2
- data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
- data/lib/jpmobile/mobile/ipad.rb +0 -1
- data/lib/jpmobile/mobile/iphone.rb +0 -1
- data/lib/jpmobile/mobile/smart_phone.rb +0 -1
- data/lib/jpmobile/mobile/softbank.rb +24 -20
- data/lib/jpmobile/mobile/tablet.rb +0 -1
- data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
- data/lib/jpmobile/mobile/vodafone.rb +0 -1
- data/lib/jpmobile/mobile/willcom.rb +7 -7
- data/lib/jpmobile/mobile/windows_phone.rb +0 -1
- data/lib/jpmobile/path_set.rb +1 -1
- data/lib/jpmobile/position.rb +30 -14
- data/lib/jpmobile/rack/filter.rb +4 -4
- data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
- data/lib/jpmobile/rack/params_filter.rb +7 -6
- data/lib/jpmobile/rails.rb +3 -4
- data/lib/jpmobile/request_with_mobile.rb +9 -6
- data/lib/jpmobile/resolver.rb +23 -17
- data/lib/jpmobile/session/active_record_store.rb +7 -9
- data/lib/jpmobile/session/mem_cache_store.rb +7 -9
- data/lib/jpmobile/sinatra.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +15 -20
- data/lib/jpmobile/util.rb +61 -77
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +35 -28
- data/spec/rack/jpmobile/android_spec.rb +5 -5
- data/spec/rack/jpmobile/au_spec.rb +74 -59
- data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
- data/spec/rack/jpmobile/docomo_spec.rb +77 -64
- data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
- data/spec/rack/jpmobile/filter_spec.rb +149 -128
- data/spec/rack/jpmobile/iphone_spec.rb +9 -8
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
- data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
- data/spec/rack/jpmobile/softbank_spec.rb +49 -42
- data/spec/rack/jpmobile/willcom_spec.rb +22 -18
- data/spec/rack/jpmobile/windows_phone.rb +5 -5
- data/spec/rack_helper.rb +9 -8
- data/spec/spec_helper.rb +5 -6
- data/spec/unit/decorated_mail_spec.rb +8 -9
- data/spec/unit/email_spec.rb +44 -44
- data/spec/unit/emoticon_spec.rb +57 -58
- data/spec/unit/encoding_spec.rb +35 -36
- data/spec/unit/is_carrier_spec.rb +49 -49
- data/spec/unit/mail_spec.rb +153 -143
- data/spec/unit/mobile/iphone_spec.rb +6 -7
- data/spec/unit/receive_mail_spec.rb +172 -173
- data/spec/unit/spec_helper.rb +6 -6
- data/spec/unit/util_spec.rb +125 -46
- data/spec/unit/valid_ip_spec.rb +35 -35
- data/spec/unit/variants_spec.rb +18 -19
- data/test/rails/overrides/Gemfile +54 -0
- data/test/rails/overrides/Gemfile.jpmobile +1 -2
- data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
- data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
- data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
- data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
- data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
- data/test/rails/overrides/autotest/discover.rb +2 -2
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
- data/test/rails/overrides/config/routes.rb +95 -2
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
- data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
- data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
- data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
- data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
- data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
- data/test/rails/overrides/spec/rails_helper.rb +1 -1
- data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
- data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
- data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
- data/test/sinatra/test/filter_test.rb +10 -11
- data/tools/e4u_conv.rb +0 -1
- metadata +18 -14
- data/README +0 -0
- data/README.rdoc +0 -308
@@ -15,7 +15,7 @@ Jpmobile::Emoticon::UNICODE_TO_DOCOMO_UNICODE = {
|
|
15
15
|
0x1F30B => 0x3013,
|
16
16
|
0x1F30C => 0xE6B3,
|
17
17
|
0x26C4 => 0xE641,
|
18
|
-
0x26C5 =>
|
18
|
+
0x26C5 => '',
|
19
19
|
0x2614 => 0xE640,
|
20
20
|
0x26A1 => 0xE642,
|
21
21
|
0x1F30F => 0x3013,
|
@@ -238,7 +238,7 @@ Jpmobile::Emoticon::UNICODE_TO_DOCOMO_UNICODE = {
|
|
238
238
|
0x1F3E6 => 0xE667,
|
239
239
|
0x1F3E7 => 0xE668,
|
240
240
|
0x1F3E8 => 0xE669,
|
241
|
-
0x1F3E9 =>
|
241
|
+
0x1F3E9 => '',
|
242
242
|
0x1F3EA => 0xE66A,
|
243
243
|
0x1F3EB => 0xE73E,
|
244
244
|
0x1F3EC => 0x3013,
|
@@ -748,7 +748,7 @@ Jpmobile::Emoticon::UNICODE_TO_DOCOMO_UNICODE = {
|
|
748
748
|
0x1F44E => 0xE700,
|
749
749
|
0x1F450 => 0xE695,
|
750
750
|
0x261D => 0x3013,
|
751
|
-
}
|
751
|
+
}.freeze
|
752
752
|
Jpmobile::Emoticon::UNICODE_TO_AU_UNICODE = {
|
753
753
|
0x2600 => 0xE488,
|
754
754
|
0x2601 => 0xE48D,
|
@@ -940,7 +940,7 @@ Jpmobile::Emoticon::UNICODE_TO_AU_UNICODE = {
|
|
940
940
|
0x1F637 => 0xEAC7,
|
941
941
|
0x1F633 => 0xEAC8,
|
942
942
|
0x1F603 => 0xE471,
|
943
|
-
0x1F605 =>
|
943
|
+
0x1F605 => '',
|
944
944
|
0x1F606 => 0xEAC5,
|
945
945
|
0x1F601 => 0xEB80,
|
946
946
|
0x1F602 => 0xEB64,
|
@@ -1499,7 +1499,7 @@ Jpmobile::Emoticon::UNICODE_TO_AU_UNICODE = {
|
|
1499
1499
|
0x1F44E => 0xEAD5,
|
1500
1500
|
0x1F450 => 0xEAD6,
|
1501
1501
|
0x261D => 0xE4F6,
|
1502
|
-
}
|
1502
|
+
}.freeze
|
1503
1503
|
Jpmobile::Emoticon::UNICODE_TO_SOFTBANK_UNICODE = {
|
1504
1504
|
0x2600 => 0xF04A,
|
1505
1505
|
0x2601 => 0xF049,
|
@@ -1517,7 +1517,7 @@ Jpmobile::Emoticon::UNICODE_TO_SOFTBANK_UNICODE = {
|
|
1517
1517
|
0x1F30B => 0x3013,
|
1518
1518
|
0x1F30C => 0xF44B,
|
1519
1519
|
0x26C4 => 0xF048,
|
1520
|
-
0x26C5 =>
|
1520
|
+
0x26C5 => ',',
|
1521
1521
|
0x2614 => 0xF04B,
|
1522
1522
|
0x26A1 => 0xF13D,
|
1523
1523
|
0x1F30F => 0x3013,
|
@@ -1691,7 +1691,7 @@ Jpmobile::Emoticon::UNICODE_TO_SOFTBANK_UNICODE = {
|
|
1691
1691
|
0x1F637 => 0xF40C,
|
1692
1692
|
0x1F633 => 0xF40D,
|
1693
1693
|
0x1F603 => 0xF057,
|
1694
|
-
0x1F605 =>
|
1694
|
+
0x1F605 => ',',
|
1695
1695
|
0x1F606 => 0xF40A,
|
1696
1696
|
0x1F601 => 0xF404,
|
1697
1697
|
0x1F602 => 0xF412,
|
@@ -2001,7 +2001,7 @@ Jpmobile::Emoticon::UNICODE_TO_SOFTBANK_UNICODE = {
|
|
2001
2001
|
0x1F4FB => 0xF128,
|
2002
2002
|
0x1F4FC => 0xF129,
|
2003
2003
|
0x1F48B => 0xF003,
|
2004
|
-
0x1F48C =>
|
2004
|
+
0x1F48C => ',',
|
2005
2005
|
0x1F48D => 0xF034,
|
2006
2006
|
0x1F48E => 0xF035,
|
2007
2007
|
0x1F48F => 0xF111,
|
@@ -2250,4 +2250,4 @@ Jpmobile::Emoticon::UNICODE_TO_SOFTBANK_UNICODE = {
|
|
2250
2250
|
0x1F44E => 0xF421,
|
2251
2251
|
0x1F450 => 0xF422,
|
2252
2252
|
0x261D => 0xF00F,
|
2253
|
-
}
|
2253
|
+
}.freeze
|
@@ -3,46 +3,43 @@ module Jpmobile
|
|
3
3
|
GETA_CODE = 0x3013
|
4
4
|
GETA = [GETA_CODE].pack('U')
|
5
5
|
|
6
|
-
SJIS_TO_UNICODE = {}
|
7
|
-
SJIS_TO_UNICODE.update(DOCOMO_SJIS_TO_UNICODE)
|
8
|
-
SJIS_TO_UNICODE.update(AU_SJIS_TO_UNICODE)
|
9
|
-
SJIS_TO_UNICODE.freeze
|
6
|
+
SJIS_TO_UNICODE = {}.update(DOCOMO_SJIS_TO_UNICODE).update(AU_SJIS_TO_UNICODE).freeze
|
10
7
|
UNICODE_TO_SJIS = SJIS_TO_UNICODE.invert.freeze
|
11
8
|
|
12
9
|
# for au email
|
13
|
-
SJIS_TO_EMAIL_JIS = {0x81ac => 0x222E}
|
14
|
-
SJIS_TO_EMAIL_JIS.update(AU_SJIS_TO_EMAIL_JIS)
|
15
|
-
SJIS_TO_EMAIL_JIS.freeze
|
10
|
+
SJIS_TO_EMAIL_JIS = { 0x81ac => 0x222E }.update(AU_SJIS_TO_EMAIL_JIS).freeze
|
16
11
|
|
17
|
-
SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
18
|
-
SOFTBANK_WEBCODE_REGEXP = Regexp.union(*([/(?!)/n]+SOFTBANK_WEBCODE_TO_UNICODE.keys.map{|x| "\x1b\x24#{x}\x0f"}))
|
12
|
+
SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map { |s| Jpmobile::Util.sjis_regexp(s) })
|
13
|
+
SOFTBANK_WEBCODE_REGEXP = Regexp.union(*([/(?!)/n] + SOFTBANK_WEBCODE_TO_UNICODE.keys.map { |x| "\x1b\x24#{x}\x0f" }))
|
19
14
|
|
20
|
-
DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
21
|
-
AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
22
|
-
SOFTBANK_UNICODE_REGEXP = Regexp.union(*SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|x| [x].pack('U')}).freeze
|
15
|
+
DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map { |s| Jpmobile::Util.sjis_regexp(s) })
|
16
|
+
AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map { |s| Jpmobile::Util.sjis_regexp(s) })
|
17
|
+
SOFTBANK_UNICODE_REGEXP = Regexp.union(*SOFTBANK_UNICODE_TO_WEBCODE.keys.map { |x| [x].pack('U') }).freeze
|
23
18
|
|
24
|
-
EMOTICON_UNICODES = UNICODE_TO_SJIS.keys|SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|k|k+0x1000}
|
25
|
-
UTF8_REGEXP = Regexp.union(*EMOTICON_UNICODES.map{|x| [x].pack('U')}).freeze
|
19
|
+
EMOTICON_UNICODES = UNICODE_TO_SJIS.keys | SOFTBANK_UNICODE_TO_WEBCODE.keys.map { |k| k + 0x1000 }
|
20
|
+
UTF8_REGEXP = Regexp.union(*EMOTICON_UNICODES.map { |x| [x].pack('U') }).freeze
|
26
21
|
|
27
22
|
# for PC conversion "GETA"
|
28
|
-
CONVERSION_TABLE_TO_PC_EMAIL = Hash[*(CONVERSION_TABLE_TO_SOFTBANK.keys|CONVERSION_TABLE_TO_DOCOMO.keys|CONVERSION_TABLE_TO_AU.keys).map{|k| [k, GETA]}.flatten]
|
23
|
+
CONVERSION_TABLE_TO_PC_EMAIL = Hash[*(CONVERSION_TABLE_TO_SOFTBANK.keys | CONVERSION_TABLE_TO_DOCOMO.keys | CONVERSION_TABLE_TO_AU.keys).map { |k| [k, GETA] }.flatten]
|
29
24
|
|
30
|
-
SOFTBANK_SJIS_REGEXP = Regexp.union(*SOFTBANK_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)}).freeze
|
31
|
-
AU_EMAILJIS_REGEXP = Regexp.union(*AU_EMAILJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.jis_regexp(s)})
|
25
|
+
SOFTBANK_SJIS_REGEXP = Regexp.union(*SOFTBANK_SJIS_TO_UNICODE.keys.map { |s| Jpmobile::Util.sjis_regexp(s) }).freeze
|
26
|
+
AU_EMAILJIS_REGEXP = Regexp.union(*AU_EMAILJIS_TO_UNICODE.keys.map { |s| Jpmobile::Util.jis_regexp(s) })
|
32
27
|
|
33
28
|
# for unicode/google emoticons
|
34
|
-
UNICODE_EMOTICONS = (UNICODE_TO_DOCOMO_UNICODE.keys|UNICODE_TO_AU_UNICODE.keys|UNICODE_TO_SOFTBANK_UNICODE.keys).uniq
|
35
|
-
GOOGLE_EMOTICONS = (GOOGLE_TO_DOCOMO_UNICODE.keys|GOOGLE_TO_AU_UNICODE.keys|GOOGLE_TO_SOFTBANK_UNICODE.keys).uniq
|
29
|
+
UNICODE_EMOTICONS = (UNICODE_TO_DOCOMO_UNICODE.keys | UNICODE_TO_AU_UNICODE.keys | UNICODE_TO_SOFTBANK_UNICODE.keys).uniq
|
30
|
+
GOOGLE_EMOTICONS = (GOOGLE_TO_DOCOMO_UNICODE.keys | GOOGLE_TO_AU_UNICODE.keys | GOOGLE_TO_SOFTBANK_UNICODE.keys).uniq
|
36
31
|
|
37
|
-
UNICODE_EMOTICON_REGEXP = Regexp.union(*UNICODE_EMOTICONS.map{|x| x.
|
38
|
-
GOOGLE_EMOTICON_REGEXP = Regexp.union(*GOOGLE_EMOTICONS.map{|x| x.
|
32
|
+
UNICODE_EMOTICON_REGEXP = Regexp.union(*UNICODE_EMOTICONS.map { |x| x.is_a?(Array) ? x.pack('UU') : [x].pack('U') }).freeze
|
33
|
+
GOOGLE_EMOTICON_REGEXP = Regexp.union(*GOOGLE_EMOTICONS.map { |x| x.is_a?(Array) ? x.pack('UU') : [x].pack('U') }).freeze
|
39
34
|
|
40
35
|
UNICODE_EMOTICON_TO_CARRIER_EMOTICON = UNICODE_TO_DOCOMO_UNICODE.merge(UNICODE_TO_AU_UNICODE.merge(UNICODE_TO_SOFTBANK_UNICODE))
|
41
36
|
GOOGLE_EMOTICON_TO_CARRIER_EMOTICON = GOOGLE_TO_SOFTBANK_UNICODE.merge(GOOGLE_TO_AU_UNICODE.merge(GOOGLE_TO_DOCOMO_UNICODE))
|
42
37
|
|
43
38
|
CONVERSION_TABLE_TO_UNICODE_EMOTICON = Jpmobile::Util.invert_table(UNICODE_TO_DOCOMO_UNICODE).merge(
|
44
|
-
Jpmobile::Util.invert_table(UNICODE_TO_AU_UNICODE).merge(Jpmobile::Util.invert_table(UNICODE_TO_SOFTBANK_UNICODE))
|
39
|
+
Jpmobile::Util.invert_table(UNICODE_TO_AU_UNICODE).merge(Jpmobile::Util.invert_table(UNICODE_TO_SOFTBANK_UNICODE))
|
40
|
+
)
|
45
41
|
CONVERSION_TABLE_TO_GOOGLE_EMOTICON = Jpmobile::Util.invert_table(GOOGLE_TO_SOFTBANK_UNICODE).merge(
|
46
|
-
Jpmobile::Util.invert_table(GOOGLE_TO_AU_UNICODE).merge(Jpmobile::Util.invert_table(GOOGLE_TO_DOCOMO_UNICODE))
|
42
|
+
Jpmobile::Util.invert_table(GOOGLE_TO_AU_UNICODE).merge(Jpmobile::Util.invert_table(GOOGLE_TO_DOCOMO_UNICODE))
|
43
|
+
)
|
47
44
|
end
|
48
45
|
end
|
data/lib/jpmobile/encoding.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# params を UTF-8 にする拡張
|
3
2
|
module Jpmobile
|
4
3
|
module Encoding
|
@@ -10,6 +9,7 @@ module Jpmobile
|
|
10
9
|
# 変換
|
11
10
|
@parameters = Jpmobile::Util.deep_convert(@parameters) do |value|
|
12
11
|
value = Jpmobile::Util.utf8(value)
|
12
|
+
value
|
13
13
|
end
|
14
14
|
|
15
15
|
@jpmobile_params_converted = true
|
@@ -1,11 +1,10 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require 'jpmobile/lookup_context'
|
3
2
|
|
4
3
|
module Jpmobile
|
5
4
|
module FallbackViewSelector
|
6
5
|
def render_to_body(options)
|
7
|
-
if Jpmobile.config.fallback_view_selector
|
8
|
-
|
6
|
+
if Jpmobile.config.fallback_view_selector &&
|
7
|
+
lookup_context.mobile.present? && !lookup_context.mobile.empty?
|
9
8
|
begin
|
10
9
|
expected_view_file = lookup_context.find_template(options[:template], options[:prefixes])
|
11
10
|
|
data/lib/jpmobile/filter.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# = 半角変換フィルター
|
3
2
|
# thanks to masuidrive <masuidrive (at) masuidrive.jp>
|
4
3
|
|
5
4
|
ActiveSupport.on_load(:action_controller) do
|
6
|
-
def self.hankaku_filter(options={})
|
5
|
+
def self.hankaku_filter(options = {})
|
7
6
|
before_action Jpmobile::HankakuFilter.new(options)
|
8
7
|
after_action Jpmobile::HankakuFilter.new(options)
|
9
8
|
end
|
@@ -13,28 +12,28 @@ module Jpmobile
|
|
13
12
|
class HankakuFilter
|
14
13
|
cattr_accessor(:zen_to_han_table) do
|
15
14
|
{
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
15
|
+
'ガ' => 'ガ', 'ギ' => 'ギ', 'グ' => 'グ', 'ゲ' => 'ゲ', 'ゴ' => 'ゴ',
|
16
|
+
'ザ' => 'ザ', 'ジ' => 'ジ', 'ズ' => 'ズ', 'ゼ' => 'ゼ', 'ゾ' => 'ゾ',
|
17
|
+
'ダ' => 'ダ', 'ヂ' => 'ヂ', 'ヅ' => 'ヅ', 'デ' => 'デ', 'ド' => 'ド',
|
18
|
+
'バ' => 'バ', 'ビ' => 'ビ', 'ブ' => 'ブ', 'ベ' => 'ベ', 'ボ' => 'ボ',
|
19
|
+
'パ' => 'パ', 'ピ' => 'ピ', 'プ' => 'プ', 'ペ' => 'ペ', 'ポ' => 'ポ',
|
20
|
+
'ヴ' => 'ヴ',
|
21
|
+
'ア' => 'ア', 'イ' => 'イ', 'ウ' => 'ウ', 'エ' => 'エ', 'オ' => 'オ',
|
22
|
+
'カ' => 'カ', 'キ' => 'キ', 'ク' => 'ク', 'ケ' => 'ケ', 'コ' => 'コ',
|
23
|
+
'サ' => 'サ', 'シ' => 'シ', 'ス' => 'ス', 'セ' => 'セ', 'ソ' => 'ソ',
|
24
|
+
'タ' => 'タ', 'チ' => 'チ', 'ツ' => 'ツ', 'テ' => 'テ', 'ト' => 'ト',
|
25
|
+
'ナ' => 'ナ', 'ニ' => 'ニ', 'ヌ' => 'ヌ', 'ネ' => 'ネ', 'ノ' => 'ノ',
|
26
|
+
'ハ' => 'ハ', 'ヒ' => 'ヒ', 'フ' => 'フ', 'ヘ' => 'ヘ', 'ホ' => 'ホ',
|
27
|
+
'マ' => 'マ', 'ミ' => 'ミ', 'ム' => 'ム', 'メ' => 'メ', 'モ' => 'モ',
|
28
|
+
'ヤ' => 'ヤ', 'ユ' => 'ユ', 'ヨ' => 'ヨ',
|
29
|
+
'ラ' => 'ラ', 'リ' => 'リ', 'ル' => 'ル', 'レ' => 'レ', 'ロ' => 'ロ',
|
30
|
+
'ワ' => 'ワ', 'ヲ' => 'ヲ', 'ン' => 'ン',
|
31
|
+
'ャ' => 'ャ', 'ュ' => 'ュ', 'ョ' => 'ョ',
|
32
|
+
'ァ' => 'ァ', 'ィ' => 'ィ', 'ゥ' => 'ゥ', 'ェ' => 'ェ', 'ォ' => 'ォ',
|
33
|
+
'ッ' => 'ッ',
|
34
|
+
'゛' => '゙', '゜' => '゚', 'ー' => 'ー', '。' => '。',
|
35
|
+
'「' => '「', '」' => '」',
|
36
|
+
'、' => '、', '・' => '・', '!' => '!', '?' => '?'
|
38
37
|
}
|
39
38
|
end
|
40
39
|
|
@@ -61,7 +60,7 @@ module Jpmobile
|
|
61
60
|
|
62
61
|
def initialize(options = {})
|
63
62
|
@options = {
|
64
|
-
:
|
63
|
+
input: false,
|
65
64
|
}.merge(options)
|
66
65
|
|
67
66
|
@controller = nil
|
@@ -78,7 +77,7 @@ module Jpmobile
|
|
78
77
|
# 内部コードから外部コードに変換
|
79
78
|
def after(controller)
|
80
79
|
@controller = controller
|
81
|
-
if apply_outgoing?
|
80
|
+
if apply_outgoing? && @controller.response.body.is_a?(String)
|
82
81
|
@controller.response.body = to_external(@controller.response.body)
|
83
82
|
end
|
84
83
|
end
|
@@ -92,7 +91,7 @@ module Jpmobile
|
|
92
91
|
|
93
92
|
def apply_outgoing?
|
94
93
|
@controller.request.mobile? and
|
95
|
-
[nil,
|
94
|
+
[nil, 'text/html', 'application/xhtml+xml'].include?(@controller.response.content_type)
|
96
95
|
end
|
97
96
|
|
98
97
|
def to_internal(str)
|
@@ -100,23 +99,23 @@ module Jpmobile
|
|
100
99
|
end
|
101
100
|
|
102
101
|
def to_external(str)
|
103
|
-
|
104
|
-
|
105
|
-
else
|
106
|
-
encoding = (str =~ /^\s*<[^Hh>]*html/) and str.respond_to?(:encoding)
|
102
|
+
if @options[:input]
|
103
|
+
encoding = (str =~ /^\s*<[^Hh>]*html/)
|
107
104
|
nokogiri_klass =
|
108
105
|
(str =~ /^\s*<[^Hh>]*html/) ? Nokogiri::HTML::Document : Nokogiri::HTML::DocumentFragment
|
109
106
|
doc = if encoding
|
110
|
-
nokogiri_klass.parse(str, nil,
|
107
|
+
nokogiri_klass.parse(str, nil, 'UTF-8')
|
111
108
|
else
|
112
109
|
nokogiri_klass.parse(str)
|
113
110
|
end
|
114
111
|
|
115
112
|
doc = convert_text_content(doc)
|
116
113
|
|
117
|
-
html = doc.to_html.gsub("\xc2\xa0",
|
114
|
+
html = doc.to_html.gsub("\xc2\xa0", ' ')
|
118
115
|
html = html.gsub(/charset=[a-z0-9\-]+/i, "charset=#{default_charset}") if default_charset
|
119
116
|
html
|
117
|
+
else
|
118
|
+
filter(:hankaku, str)
|
120
119
|
end
|
121
120
|
end
|
122
121
|
|
@@ -124,11 +123,8 @@ module Jpmobile
|
|
124
123
|
str = str.dup
|
125
124
|
|
126
125
|
# 一度UTF-8に変換
|
127
|
-
before_encoding =
|
128
|
-
|
129
|
-
before_encoding = str.encoding
|
130
|
-
str.force_encoding("UTF-8")
|
131
|
-
end
|
126
|
+
before_encoding = str.encoding
|
127
|
+
str.force_encoding('UTF-8')
|
132
128
|
|
133
129
|
str = self.class.send("#{method}_format", str)
|
134
130
|
|
@@ -143,18 +139,19 @@ module Jpmobile
|
|
143
139
|
# 再帰的に探す
|
144
140
|
def convert_text_content(document)
|
145
141
|
document.children.each do |element|
|
146
|
-
if element.
|
147
|
-
unless element.parent.node_name ==
|
142
|
+
if element.is_a?(Nokogiri::XML::Text)
|
143
|
+
unless element.parent.node_name == 'textarea'
|
148
144
|
# textarea 以外のテキストなら content を変換
|
149
145
|
element.content = filter(:hankaku, element.content)
|
150
146
|
end
|
151
|
-
elsif element.node_name ==
|
147
|
+
elsif (element.node_name == 'input') && %w[submit reset button].include?(element['type'])
|
152
148
|
# テキスト以外でもボタンの value は変換
|
153
|
-
element[
|
149
|
+
element['value'] = filter(:hankaku, element['value'])
|
154
150
|
elsif element.children.any?
|
155
151
|
# 子要素があれば再帰的に変換
|
156
152
|
element = convert_text_content(element)
|
157
153
|
end
|
154
|
+
element
|
158
155
|
end
|
159
156
|
|
160
157
|
document
|
@@ -168,11 +165,11 @@ module Jpmobile
|
|
168
165
|
|
169
166
|
def convert_parameters(params)
|
170
167
|
params.each do |k, v|
|
171
|
-
if params[k].respond_to?(:each)
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
168
|
+
params[k] = if params[k].respond_to?(:each)
|
169
|
+
convert_parameters(params[k])
|
170
|
+
else
|
171
|
+
to_internal(v)
|
172
|
+
end
|
176
173
|
end
|
177
174
|
end
|
178
175
|
end
|
data/lib/jpmobile/helpers.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# =位置情報等を要求するヘルパー
|
3
2
|
module Jpmobile
|
4
3
|
# 携帯電話端末に位置情報を要求するための、特殊なリンクを出力するヘルパー群。
|
@@ -9,7 +8,7 @@ module Jpmobile
|
|
9
8
|
# :show_all => +true+ とするとキャリア判別を行わず全てキャリアのリンクを返す。
|
10
9
|
# 第1引数に文字列を与えるとその文字列をアンカーテキストにする。
|
11
10
|
# 第1引数がHashの場合はデフォルトのアンカーテキストを出力する。
|
12
|
-
def get_position_link_to(str=nil, options={})
|
11
|
+
def get_position_link_to(str = nil, options = {})
|
13
12
|
if str.is_a?(Hash)
|
14
13
|
options = str
|
15
14
|
str = nil
|
@@ -23,149 +22,150 @@ module Jpmobile
|
|
23
22
|
# TODO: コード汚い
|
24
23
|
s = []
|
25
24
|
if show_all || request.mobile.instance_of?(Mobile::Docomo)
|
26
|
-
s << docomo_foma_gps_link_to(str||
|
25
|
+
s << docomo_foma_gps_link_to(str || 'DoCoMo FOMA(GPS)', options)
|
27
26
|
end
|
28
27
|
if show_all || request.mobile.instance_of?(Mobile::Au)
|
29
28
|
if show_all || request.mobile.supports_gps?
|
30
|
-
s << au_gps_link_to(str||
|
29
|
+
s << au_gps_link_to(str || 'au(GPS)', options)
|
31
30
|
end
|
32
|
-
if show_all || (!
|
33
|
-
s << au_location_link_to(str||
|
31
|
+
if show_all || (!request.mobile.supports_gps? && request.mobile.supports_location?)
|
32
|
+
s << au_location_link_to(str || 'au(antenna)', options)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
if show_all || request.mobile.instance_of?(Mobile::Vodafone) || request.mobile.instance_of?(Mobile::Softbank)
|
37
|
-
s << softbank_location_link_to(str||
|
36
|
+
s << softbank_location_link_to(str || 'Softbank 3G(GPS)', options)
|
38
37
|
end
|
39
38
|
if show_all || request.mobile.instance_of?(Mobile::Willcom)
|
40
|
-
s << willcom_location_link_to(str||
|
39
|
+
s << willcom_location_link_to(str || 'Willcom', options)
|
41
40
|
end
|
42
|
-
|
41
|
+
s.join("<br>\n").html_safe
|
43
42
|
end
|
44
43
|
|
45
44
|
# DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。
|
46
|
-
def docomo_foma_gps_link_to(str, options={})
|
45
|
+
def docomo_foma_gps_link_to(str, options = {})
|
47
46
|
url = options
|
48
47
|
if options.is_a?(Hash)
|
49
48
|
options = options.symbolize_keys
|
50
49
|
options[:only_path] = false
|
51
50
|
url = url_for(options)
|
52
51
|
end
|
53
|
-
|
52
|
+
%(<a href="#{url}" lcs>#{str}</a>).html_safe
|
54
53
|
end
|
55
54
|
|
56
55
|
# DoCoMoでオープンiエリアを取得するためのURLを返す。
|
57
|
-
def docomo_openiarea_url_for(options={})
|
56
|
+
def docomo_openiarea_url_for(options = {})
|
58
57
|
url = options
|
59
58
|
if options.is_a?(Hash)
|
60
59
|
options = options.symbolize_keys
|
61
60
|
options[:only_path] = false
|
62
|
-
posinfo = options.delete(:posinfo) ||
|
61
|
+
posinfo = options.delete(:posinfo) || '1' # 基地局情報を元に測位した緯度経度情報を要求
|
63
62
|
url = url_for(options)
|
64
63
|
else
|
65
|
-
posinfo =
|
64
|
+
posinfo = '1'
|
66
65
|
end
|
67
|
-
|
66
|
+
"http://w1m.docomo.ne.jp/cp/iarea?ecode=OPENAREACODE&msn=OPENAREAKEY&posinfo=#{posinfo}&nl=#{CGI.escape(url)}"
|
68
67
|
end
|
69
68
|
|
70
69
|
# DoCoMoでオープンiエリアを取得するためのリンクを返す。
|
71
|
-
def docomo_openiarea_link_to(str, options={})
|
70
|
+
def docomo_openiarea_link_to(str, options = {})
|
72
71
|
link_to_url(str, docomo_openiarea_url_for(options))
|
73
72
|
end
|
74
73
|
|
75
74
|
# DoCoMoで端末製造番号等を取得するためのリンクを返す。
|
76
|
-
def docomo_utn_link_to(str, options={})
|
75
|
+
def docomo_utn_link_to(str, options = {})
|
77
76
|
url = options
|
78
77
|
if options.is_a?(Hash)
|
79
78
|
options = options.symbolize_keys
|
80
79
|
options[:only_path] = false
|
81
80
|
url = url_for(options)
|
82
81
|
end
|
83
|
-
|
82
|
+
%(<a href="#{url}" utn>#{str}</a>).html_safe
|
84
83
|
end
|
85
84
|
|
86
85
|
# DoCoMoでiモードIDを取得するためのリンクを返す。
|
87
|
-
def docomo_guid_link_to(str, options={})
|
86
|
+
def docomo_guid_link_to(str, options = {})
|
88
87
|
url = options
|
89
88
|
if options.is_a?(Hash)
|
90
89
|
options = options.symbolize_keys
|
91
|
-
options[:guid] =
|
90
|
+
options[:guid] = 'ON'
|
92
91
|
url = url_for(options)
|
93
92
|
end
|
94
|
-
|
93
|
+
link_to_url(str, url)
|
95
94
|
end
|
96
95
|
|
97
96
|
# au GPS位置情報を取得するためのURLを返す。
|
98
|
-
def au_gps_url_for(options={})
|
97
|
+
def au_gps_url_for(options = {})
|
99
98
|
url = options
|
100
99
|
datum = 0 # 0:wgs84, 1:tokyo
|
101
100
|
unit = 0 # 0:dms, 1:deg
|
102
101
|
if options.is_a?(Hash)
|
103
102
|
options = options.symbolize_keys
|
104
103
|
options[:only_path] = false
|
105
|
-
datum = (options.delete(:datum) || 0
|
106
|
-
unit = (options.delete(:unit) || 0
|
104
|
+
datum = (options.delete(:datum) || 0).to_i # 0:wgs84, 1:tokyo
|
105
|
+
unit = (options.delete(:unit) || 0).to_i # 0:dms, 1:deg
|
107
106
|
url = url_for(options)
|
108
107
|
end
|
109
|
-
|
108
|
+
"device:gpsone?url=#{CGI.escape(url)}&ver=1&datum=#{datum}&unit=#{unit}&acry=0&number=0"
|
110
109
|
end
|
111
110
|
|
112
111
|
# au GPS位置情報を取得するためのリンクを返す。
|
113
|
-
def au_gps_link_to(str, options={})
|
112
|
+
def au_gps_link_to(str, options = {})
|
114
113
|
link_to_url(str, au_gps_url_for(options))
|
115
114
|
end
|
116
115
|
|
117
116
|
# au 簡易位置情報を取得するためのURLを返す。
|
118
|
-
def au_location_url_for(options={})
|
117
|
+
def au_location_url_for(options = {})
|
119
118
|
url = options
|
120
119
|
if options.is_a?(Hash)
|
121
120
|
options = options.symbolize_keys
|
122
121
|
options[:only_path] = false
|
123
122
|
url = url_for(options)
|
124
123
|
end
|
125
|
-
|
124
|
+
"device:location?url=#{CGI.escape(url)}"
|
126
125
|
end
|
127
126
|
|
128
127
|
# au 簡易位置情報を取得するためのリンクを返す。
|
129
|
-
def au_location_link_to(str, options={})
|
128
|
+
def au_location_link_to(str, options = {})
|
130
129
|
link_to_url(str, au_location_url_for(options))
|
131
130
|
end
|
132
131
|
|
133
132
|
# Softbank(含むVodafone 3G)で位置情報を取得するためのURLを返す。
|
134
|
-
def softbank_location_url_for(options={})
|
133
|
+
def softbank_location_url_for(options = {})
|
135
134
|
url = options
|
136
|
-
mode =
|
135
|
+
mode = 'auto'
|
137
136
|
if options.is_a?(Hash)
|
138
137
|
options = options.symbolize_keys
|
139
|
-
mode = options.delete(:mode) ||
|
138
|
+
mode = options.delete(:mode) || 'auto'
|
140
139
|
options[:only_path] = false
|
141
140
|
url = url_for(options)
|
142
141
|
end
|
143
142
|
url.sub!(/\?/, '&')
|
144
|
-
|
143
|
+
"location:#{mode}?url=#{url}"
|
145
144
|
end
|
146
145
|
|
147
146
|
# Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。
|
148
|
-
def softbank_location_link_to(str,options={})
|
149
|
-
link_to_url(str,softbank_location_url_for(options))
|
147
|
+
def softbank_location_link_to(str, options = {})
|
148
|
+
link_to_url(str, softbank_location_url_for(options))
|
150
149
|
end
|
151
150
|
|
152
151
|
# Willcom 基地局位置情報を取得するためのURLを返す。
|
153
|
-
def willcom_location_url_for(options={})
|
152
|
+
def willcom_location_url_for(options = {})
|
154
153
|
url = options
|
155
154
|
if options.is_a?(Hash)
|
156
155
|
options = options.symbolize_keys
|
157
156
|
options[:only_path] = false
|
158
157
|
url = url_for(options)
|
159
158
|
end
|
160
|
-
|
159
|
+
"http://location.request/dummy.cgi?my=#{url}&pos=$location"
|
161
160
|
end
|
162
161
|
|
163
162
|
# Willcom 基地局位置情報を取得するためのリンクを返す。
|
164
|
-
def willcom_location_link_to(str,options={})
|
163
|
+
def willcom_location_link_to(str, options = {})
|
165
164
|
link_to_url(str, willcom_location_url_for(options))
|
166
165
|
end
|
167
166
|
|
168
167
|
private
|
168
|
+
|
169
169
|
# 外部へのリンク
|
170
170
|
def link_to_url(str, url)
|
171
171
|
link_to str, url
|