galakei 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.rdoc +12 -0
- data/Rakefile +7 -0
- data/galakei.gemspec +1 -1
- data/lib/galakei/docomo_css/inline_stylesheet.rb +1 -1
- data/lib/galakei/docomo_css/railtie.rb +1 -1
- data/lib/galakei/docomo_css/stylesheet.rb +2 -2
- data/lib/galakei/docomo_css.rb +32 -0
- data/lib/galakei/email/au_mail_interceptor.rb +1 -2
- data/lib/galakei/email/railtie.rb +2 -1
- data/lib/galakei/emoji_table.rb +1 -1
- data/lib/galakei/filter/base.rb +1 -1
- data/lib/galakei/filter/content_type.rb +1 -0
- data/lib/galakei/filter/haml.rb +4 -2
- data/lib/galakei/filter/hankaku.rb +4 -0
- data/lib/galakei/filter/non_standard_char.rb +6 -0
- data/lib/galakei/filter/recode.rb +2 -1
- data/lib/galakei/filter/views.rb +4 -0
- data/lib/galakei/helper_methods.rb +6 -2
- data/lib/galakei/input_mode.rb +56 -43
- data/lib/galakei/session_id_parameter/in_form.rb +1 -1
- data/lib/galakei/session_id_parameter/in_url.rb +1 -1
- data/lib/galakei/session_id_parameter/railtie.rb +1 -1
- data/lib/galakei/session_id_parameter.rb +9 -0
- data/lib/galakei/spacer.rb +1 -1
- data/lib/galakei/version.rb +2 -1
- data/lib/galakei.rb +16 -1
- data/spec/acceptance/input_mode_spec.rb +16 -13
- data/spec/acceptance/support/input_mode_matchers.rb +29 -0
- metadata +16 -14
- data/README.md +0 -70
data/README.rdoc
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
= Galakei: Japanese feature phone support
|
2
|
+
|
3
|
+
{Japanese feature phones}[http://www.mobalean.com/en/keitai_web_technology_guide] (a.k.a., keitai, galakei) have a number of restrictions over normal web browsers. This library adds support for them.
|
4
|
+
|
5
|
+
== Documentation
|
6
|
+
|
7
|
+
See {the galakei site}[http://galakei.mobalean.com/] for more details.
|
8
|
+
|
9
|
+
== Thanks
|
10
|
+
|
11
|
+
* To {jpmobile}[https://github.com/jpmobile/jpmobile] for offering the most mature Rails plugin for Rails
|
12
|
+
* To {docomo_css}[https://github.com/milk1000cc/docomo_css] for providing the inspiration for galakei/docomo_css
|
data/Rakefile
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
require 'rspec/core/rake_task'
|
3
|
+
require 'rdoc/task'
|
3
4
|
Bundler::GemHelper.install_tasks
|
4
5
|
|
5
6
|
task :default => :spec
|
6
7
|
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
RDoc::Task.new :rdoc do |rdoc|
|
10
|
+
rdoc.main = "README.rdoc"
|
11
|
+
rdoc.title = "Galakei RDoc"
|
12
|
+
rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
13
|
+
end
|
data/galakei.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Paul McMahon", "Michael Reinsch", "Yuki Akamatsu"]
|
9
9
|
s.email = "info@mobalean.com"
|
10
|
-
s.homepage = "http://
|
10
|
+
s.homepage = "http://galakei.mobalean.com/"
|
11
11
|
s.summary = "Japanese feature phones support"
|
12
12
|
s.description = "Japanese feature phones (a.k.a., keitai, galakei) have a number of restrictions over normal web browsers. This library adds support for them"
|
13
13
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'css_parser'
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
|
-
class Galakei::DocomoCss::InlineStylesheet
|
5
|
+
class Galakei::DocomoCss::InlineStylesheet # :nodoc: all
|
6
6
|
def self.filter(controller)
|
7
7
|
return unless controller.request.imode_browser_1_0?
|
8
8
|
doc = Nokogiri::HTML(controller.response.body)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "css_parser"
|
2
2
|
require 'nokogiri'
|
3
3
|
|
4
|
-
class Galakei::DocomoCss::Stylesheet
|
4
|
+
class Galakei::DocomoCss::Stylesheet # :nodoc: all
|
5
5
|
def initialize(parsed_stylesheet)
|
6
6
|
@parsed_stylesheet = parsed_stylesheet
|
7
7
|
end
|
@@ -103,7 +103,7 @@ EOD
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
class BackGroundAdapter < GenericAdapter
|
106
|
+
class BackGroundAdapter < GenericAdapter
|
107
107
|
def self.apply?(property)
|
108
108
|
property == 'background-color'
|
109
109
|
end
|
data/lib/galakei/docomo_css.rb
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
=begin
|
2
|
+
== Inlining Styles
|
3
|
+
|
4
|
+
=== Basic Inlining
|
5
|
+
|
6
|
+
Old docomo handsets {don't support external stylesheets}[http://www.keitai-dev.net/CSS]. Additionally, only very limited CSS is supported. galakei/docomo_css automatically inlines CSS and manipulates markup to overcome these limitations.
|
7
|
+
|
8
|
+
# css file
|
9
|
+
h1 { color: red; background-color: blue}
|
10
|
+
|
11
|
+
# source html
|
12
|
+
<h1>Foo</h1>
|
13
|
+
|
14
|
+
# outputted html
|
15
|
+
<div style="background-color: blue;"><h1><span style="color:red;">Foo</span></h1>/div>
|
16
|
+
|
17
|
+
=== Borders
|
18
|
+
|
19
|
+
Furthermore, the css border property is supported through the "spacer.gif" technique.
|
20
|
+
|
21
|
+
# css file
|
22
|
+
div { border-bottom: 5px solid #000000; }
|
23
|
+
|
24
|
+
# source html
|
25
|
+
<div>Foo</div>
|
26
|
+
|
27
|
+
# outputted html
|
28
|
+
<div>Foo</div>
|
29
|
+
<img src="/galakei/spacer/000000" width="100%" height="5">
|
30
|
+
|
31
|
+
This will generate a 1px by 1px image, emulating the effect of borders on old docomo handsets.
|
32
|
+
=end
|
1
33
|
module Galakei::DocomoCss
|
2
34
|
autoload :Stylesheet, "galakei/docomo_css/stylesheet"
|
3
35
|
autoload :InlineStylesheet, "galakei/docomo_css/inline_stylesheet"
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
1
|
# au-kddi handsets render html mail properly only when
|
3
2
|
# all mime parts are in a flat multipart/alternate structure
|
4
|
-
class Galakei::Email::AuMailInterceptor
|
3
|
+
class Galakei::Email::AuMailInterceptor # :nodoc:
|
5
4
|
def self.delivering_email(message)
|
6
5
|
|
7
6
|
if message.to.first =~ /^.+@ezweb\.ne\.jp$/
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
class Galakei::Email::Railtie < Rails::Railtie # :nodoc:
|
2
3
|
initializer "galakei.register.method.for.mail" do
|
3
4
|
ActiveSupport.on_load :action_mailer do
|
4
5
|
ActionMailer::Base.register_interceptor Galakei::Email::AuMailInterceptor
|
data/lib/galakei/emoji_table.rb
CHANGED
data/lib/galakei/filter/base.rb
CHANGED
data/lib/galakei/filter/haml.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
=begin
|
2
|
+
haml is great for building galakei sites, as it enforces well formed markup. galakei takes care of setting the haml template format for you, so you'll generate xhtml.
|
3
|
+
=end
|
3
4
|
class Galakei::Filter::Haml < Galakei::Filter::Base
|
5
|
+
# :stopdoc:
|
4
6
|
def filter
|
5
7
|
old_format = ::Haml::Template.options[:format]
|
6
8
|
Rails.logger.debug("[galakei] galakei detected, switching HAML to use :xhtml")
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
=begin
|
3
|
+
For galakei, zenkaku katakana such as カタカナ will be converted to hankaku like カタカナ automatically when rendering html. This is standard practice, as zenkaku katakana taxes up too much screen space.
|
4
|
+
=end
|
2
5
|
class Galakei::Filter::Hankaku < Galakei::Filter::Base
|
3
6
|
zenkaku = %w(ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ ヴ ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン ャ ュ ョ ァ ィ ゥ ェ ォ ッ ー)
|
4
7
|
hankaku = %w(ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ ヴ ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン ャ ュ ョ ァ ィ ゥ ェ ォ ッ ー)
|
8
|
+
# :stopdoc:
|
5
9
|
MAPPING = zenkaku.zip(hankaku)
|
6
10
|
|
7
11
|
def condition?
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
=begin
|
3
|
+
Each of the following characters has a different unicode values:
|
4
|
+
⋅··∙・•
|
5
|
+
Some are supported on galakei, but others aren't. The correct version will be used.
|
6
|
+
=end
|
2
7
|
class Galakei::Filter::NonStandardChar < Galakei::Filter::Base
|
8
|
+
# :stopdoc:
|
3
9
|
def condition?
|
4
10
|
response.content_type =~ %r{text/html|application/xhtml+xml} &&
|
5
11
|
(response.charset || Rails.application.config.encoding).downcase == "utf-8"
|
@@ -1,6 +1,7 @@
|
|
1
|
-
# Takes care of recoding pages to Shift-JIS for some handsets when required
|
2
1
|
require 'nkf'
|
2
|
+
# On au SSL pages, only Shift-JIS encoding is supported by some handsets, so pages will be reencoded.
|
3
3
|
module Galakei::Filter::Recode
|
4
|
+
# :stopdoc:
|
4
5
|
def self.condition?(c)
|
5
6
|
c.request.ssl? && c.request.au?
|
6
7
|
end
|
data/lib/galakei/filter/views.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
=begin
|
2
|
+
Have a PC site that you want to add galakei templates for? Put your views in app/views.galakei and they'll be used in preference to your normal app/views
|
3
|
+
=end
|
1
4
|
class Galakei::Filter::Views < Galakei::Filter::Base
|
5
|
+
# :stopdoc:
|
2
6
|
def filter
|
3
7
|
logger.debug("appending galakei views")
|
4
8
|
prepend_view_path(::Rails.root.join('app','views.galakei'))
|
@@ -1,15 +1,19 @@
|
|
1
1
|
module Galakei
|
2
2
|
module HelperMethods
|
3
|
-
def self.included(klass)
|
3
|
+
def self.included(klass) # :nodoc:
|
4
4
|
klass.helper_method :galakei?
|
5
5
|
klass.helper_method :emoji_table
|
6
6
|
end
|
7
|
-
protected
|
8
7
|
|
8
|
+
# Does the current request come from a galakei?
|
9
9
|
def galakei?
|
10
10
|
request.galakei?
|
11
11
|
end
|
12
12
|
|
13
|
+
# Returns the carrier specific {Emoji}[http://www.keitai-dev.net/Emoji]. Falls back to Unicode
|
14
|
+
# emoji.
|
15
|
+
#
|
16
|
+
# emoji_table.white_smiling_face # "☺"
|
13
17
|
def emoji_table
|
14
18
|
if request.docomo?
|
15
19
|
EmojiTable.docomo
|
data/lib/galakei/input_mode.rb
CHANGED
@@ -1,51 +1,64 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
=begin
|
2
|
+
Galakei support switching between different input modes (alphabetic, hiragana, hankaku, and numeric). The input mode will be automatically changed based on the {HTML5 input type}[http://dev.w3.org/html5/spec/Overview.html#attr-input-type]. The following summarizes the mapping:
|
3
|
+
|
4
|
+
[alphabetic] +url+, +email+
|
5
|
+
[numeric] +tel+, +datetime+, +date+, +month+, +week+, +time+, +number+, +color+
|
6
|
+
|
7
|
+
Additionally, the input mode can be explicitly specified by setting the +inputmode+ attribute to one of +alphabet+, +hiragana+, +hankaku_kana+, or +number+.
|
8
|
+
=end
|
9
|
+
module Galakei::InputMode
|
10
|
+
# :stopdoc:
|
11
|
+
INPUT_MODES = {
|
12
|
+
"alphabet" => {
|
13
|
+
:docomo_wap_input_format => "en",
|
14
|
+
:other_wap_input_format => 'm',
|
15
|
+
:mode => 'alphabet',
|
16
|
+
:istyle => '3'
|
17
|
+
},
|
18
|
+
"hiragana" => {
|
19
|
+
:docomo_wap_input_format => 'h',
|
20
|
+
:other_wap_input_format => 'M',
|
21
|
+
:mode => 'hiragana',
|
22
|
+
:istyle => '1'
|
23
|
+
},
|
24
|
+
"hankaku_kana" => {
|
25
|
+
:docomo_wap_input_format => 'hk',
|
26
|
+
:other_wap_input_format => 'M',
|
27
|
+
:mode => 'hankakukana',
|
28
|
+
:istyle => '2'
|
29
|
+
},
|
30
|
+
"number" => {
|
31
|
+
:docomo_wap_input_format => 'n',
|
32
|
+
:other_wap_input_format => 'N',
|
33
|
+
:mode => 'numeric',
|
34
|
+
:istyle => '4'
|
28
35
|
}
|
36
|
+
}
|
29
37
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
38
|
+
def text_field(object_name, method, options = {})
|
39
|
+
if request.galakei?
|
40
|
+
inputmode = if options[:type] == "number"
|
41
|
+
options.delete(:type)
|
42
|
+
elsif %w[tel date datetime date month week time color].include?(options[:type])
|
43
|
+
options.delete(:type)
|
44
|
+
"number"
|
45
|
+
elsif %w[email url].include?(options[:type])
|
46
|
+
options.delete(:type)
|
47
|
+
"alphabet"
|
48
|
+
else
|
49
|
+
options.delete(:inputmode)
|
50
|
+
end
|
51
|
+
if inputmode = INPUT_MODES[inputmode]
|
52
|
+
if request.docomo?
|
53
|
+
style = inputmode[:docomo_wap_input_format]
|
54
|
+
options[:style] = %Q{-wap-input-format:"*<ja:#{style}>"}
|
34
55
|
else
|
35
|
-
options
|
36
|
-
|
37
|
-
|
38
|
-
if request.docomo?
|
39
|
-
style = inputmode[:docomo_wap_input_format]
|
40
|
-
options[:style] = %Q{-wap-input-format:"*<ja:#{style}>"}
|
41
|
-
else
|
42
|
-
options[:istyle] = inputmode[:istyle]
|
43
|
-
options[:mode] = inputmode[:mode]
|
44
|
-
options[:style] ||= %Q{-wap-input-format:*#{inputmode[:other_wap_input_format]}}
|
45
|
-
end
|
56
|
+
options[:istyle] = inputmode[:istyle]
|
57
|
+
options[:mode] = inputmode[:mode]
|
58
|
+
options[:style] ||= %Q{-wap-input-format:*#{inputmode[:other_wap_input_format]}}
|
46
59
|
end
|
47
60
|
end
|
48
|
-
super(object_name, method, options)
|
49
61
|
end
|
62
|
+
super(object_name, method, options)
|
50
63
|
end
|
51
64
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# When making a get request from a form, query string parameters are ignored.
|
2
2
|
# Instead, the parameters must be added as hidden fields. This module ensures
|
3
3
|
# that the session id parameter is properly injected into forms.
|
4
|
-
module Galakei::SessionIdParameter::InForm
|
4
|
+
module Galakei::SessionIdParameter::InForm # :nodoc:
|
5
5
|
def extra_tags_for_form(html_options)
|
6
6
|
return super unless html_options["method"] == :get
|
7
7
|
session_id = extract_session_id!(html_options["action"])
|
@@ -1,4 +1,13 @@
|
|
1
1
|
module Galakei
|
2
|
+
=begin
|
3
|
+
Old docomo handsets {don't support cookies}[http://www.keitai-dev.net/Cookies]. Furthermore, although Softbank and Au handsets support cookies, when accessing SSL pages, different cookies may be used. Galakei works around this by injecting a session id parameter into your URLs and forms (as long as you use a standard rails method for creating them). To enable this functionality, you will need to modify your session_store.rb initializer to allow the use of session parameters and use a non cookie-based store.
|
4
|
+
|
5
|
+
MyApp::Application.config.session_store :active_record_store, :key => '_sid', :cookie_only => false
|
6
|
+
|
7
|
+
You'll also need to enable this option in galakei
|
8
|
+
|
9
|
+
config.galakei.session_id_parameter = true
|
10
|
+
=end
|
2
11
|
module SessionIdParameter
|
3
12
|
autoload :InForm, "galakei/session_id_parameter/in_form"
|
4
13
|
autoload :InUrl, "galakei/session_id_parameter/in_url"
|
data/lib/galakei/spacer.rb
CHANGED
data/lib/galakei/version.rb
CHANGED
data/lib/galakei.rb
CHANGED
@@ -2,6 +2,21 @@ require 'galakei/request'
|
|
2
2
|
require 'galakei/docomo_css'
|
3
3
|
require 'galakei/session_id_parameter'
|
4
4
|
|
5
|
+
=begin
|
6
|
+
== Functionality
|
7
|
+
|
8
|
+
* {Convert to and from Shift-JIS when necessary}[rdoc-ref:Galakei::Filter::Recode]
|
9
|
+
* {Correct Content-Type}[rdoc-ref:Galakei::Filter::ContentType]
|
10
|
+
* {HTML Email}[rdoc-ref:Galakei::Email]
|
11
|
+
* {Inlining of CSS}[rdoc-ref:Galakei::DocomoCss]
|
12
|
+
* {Input Mode Switching}[rdoc-ref:Galakei::InputMode]
|
13
|
+
* {Maintaining Session}[rdoc-ref:Galakei::SessionIdParameter]
|
14
|
+
* {Substitution of Unsupported Characters}[rdoc-ref:Galakei::Filter::NonStandardChar]
|
15
|
+
* {Unicode compatible Emoji}[rdoc-ref:Galakei::HelperMethods#emoji_table]
|
16
|
+
* {Zenkaku to Hankaku conversion}[rdoc-ref:Galakei::Filter::Hankaku]
|
17
|
+
* {galakei specific views}[rdoc-ref:Galakei::Filter::Views]
|
18
|
+
* {haml support}[rdoc-ref:Galakei::Filter::Haml]
|
19
|
+
=end
|
5
20
|
module Galakei
|
6
21
|
autoload :Email, "galakei/email"
|
7
22
|
autoload :HelperMethods, "galakei/helper_methods"
|
@@ -9,7 +24,7 @@ module Galakei
|
|
9
24
|
autoload :EmojiTable, "galakei/emoji_table"
|
10
25
|
autoload :SessionIdParameterInForm, "galakei/session_id_parameter_in_form"
|
11
26
|
autoload :Spacer, "galakei/spacer"
|
12
|
-
module Filter
|
27
|
+
module Filter # :nodoc:
|
13
28
|
autoload :Base, "galakei/filter/base"
|
14
29
|
autoload :ContentType, "galakei/filter/content_type"
|
15
30
|
autoload :Haml, "galakei/filter/haml"
|
@@ -5,7 +5,7 @@ class InputModeController < ApplicationController
|
|
5
5
|
class User
|
6
6
|
extend ActiveModel::Naming
|
7
7
|
include ActiveModel::Conversion
|
8
|
-
attr_accessor :hiragana, :hankaku_kana, :alphabet, :number_input_mode, :
|
8
|
+
attr_accessor :hiragana, :hankaku_kana, :alphabet, :number_input_mode, :number, :tel, :url, :email, :date, :month, :week, :color, :datetime, :time
|
9
9
|
def persisted?; false end
|
10
10
|
end
|
11
11
|
def index
|
@@ -16,25 +16,28 @@ class InputModeController < ApplicationController
|
|
16
16
|
<%= f.text_field :hankaku_kana, :inputmode => "hankaku_kana" %>
|
17
17
|
<%= f.text_field :alphabet, :inputmode => "alphabet" %>
|
18
18
|
<%= f.text_field :number_input_mode, :inputmode => "number" %>
|
19
|
-
|
19
|
+
<% %w[ number tel url email datetime date month week color time ].each do |s| %>
|
20
|
+
<%= f.text_field s, :type => s %>
|
21
|
+
<% end %>
|
20
22
|
<% end %>
|
21
23
|
EOD
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
27
|
feature 'input mode' do
|
28
|
+
include InputModeMatchers
|
26
29
|
scenario 'for docomo', :driver => :docomo do
|
27
30
|
visit '/input_mode'
|
28
31
|
within 'form' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
find("#input_mode_controller_user_hiragana").should be_docomo_hiragana
|
33
|
+
find("#input_mode_controller_user_hankaku_kana").should be_docomo_hankaku
|
34
|
+
find("#input_mode_controller_user_alphabet").should be_docomo_alphabetic
|
35
|
+
find("#input_mode_controller_user_number_input_mode").should be_docomo_numeric
|
36
|
+
%w[url email].each do |s|
|
37
|
+
page.find("#input_mode_controller_user_#{s}").should be_docomo_alphabetic
|
38
|
+
end
|
39
|
+
%w[number tel datetime date month week time color].each do |s|
|
40
|
+
page.find("#input_mode_controller_user_#{s}").should be_docomo_numeric
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
@@ -60,8 +63,8 @@ feature 'input mode' do
|
|
60
63
|
e["mode"].should == 'alphabet'
|
61
64
|
e["istyle"].should == '3'
|
62
65
|
|
63
|
-
%w[
|
64
|
-
e = page.find("#
|
66
|
+
%w[number_input_mode number].each do |s|
|
67
|
+
e = page.find("#input_mode_controller_user_#{s}")
|
65
68
|
e["style"].should == '-wap-input-format:*N'
|
66
69
|
e["mode"].should == 'numeric'
|
67
70
|
e["istyle"].should == '4'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module InputModeMatchers
|
2
|
+
{ :hiragana => '-wap-input-format:"*<ja:h>"',
|
3
|
+
:hankaku => '-wap-input-format:"*<ja:hk>"',
|
4
|
+
:alphabetic => '-wap-input-format:"*<ja:en>"',
|
5
|
+
:numeric => '-wap-input-format:"*<ja:n>"'
|
6
|
+
}.each do |mode, style|
|
7
|
+
define_method("be_docomo_#{mode}") { DocomoInputMode.new style }
|
8
|
+
end
|
9
|
+
|
10
|
+
class DocomoInputMode
|
11
|
+
def initialize(expected)
|
12
|
+
@expected = expected
|
13
|
+
end
|
14
|
+
|
15
|
+
def matches?(target)
|
16
|
+
@target = target
|
17
|
+
@target["style"].eql?(@expected)
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message_for_should
|
21
|
+
"expected #{@target.native} to have style='#{@expected}'"
|
22
|
+
end
|
23
|
+
|
24
|
+
def failure_message_for_should_not
|
25
|
+
"expected #{@target.native} not to have style='#{@expected}'"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: galakei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-10-
|
14
|
+
date: 2011-10-28 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: actionpack
|
18
|
-
requirement: &
|
18
|
+
requirement: &2157631620 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 3.0.3
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2157631620
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack
|
29
|
-
requirement: &
|
29
|
+
requirement: &2157631060 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: 1.2.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2157631060
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: css_parser
|
40
|
-
requirement: &
|
40
|
+
requirement: &2157630640 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *2157630640
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: nokogiri
|
51
|
-
requirement: &
|
51
|
+
requirement: &2157630060 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *2157630060
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: sanitize
|
62
|
-
requirement: &
|
62
|
+
requirement: &2157629540 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *2157629540
|
71
71
|
description: Japanese feature phones (a.k.a., keitai, galakei) have a number of restrictions
|
72
72
|
over normal web browsers. This library adds support for them
|
73
73
|
email: info@mobalean.com
|
@@ -79,7 +79,7 @@ files:
|
|
79
79
|
- Gemfile
|
80
80
|
- Gemfile.lock
|
81
81
|
- LICENSE
|
82
|
-
- README.
|
82
|
+
- README.rdoc
|
83
83
|
- Rakefile
|
84
84
|
- app/controllers/galakei/spacer_controller.rb
|
85
85
|
- config/initializers/mime_types.rb
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- spec/acceptance/session_spec.rb
|
129
129
|
- spec/acceptance/support/capybara_ssl_fix.rb
|
130
130
|
- spec/acceptance/support/handsets.rb
|
131
|
+
- spec/acceptance/support/input_mode_matchers.rb
|
131
132
|
- spec/acceptance/views_spec.rb
|
132
133
|
- spec/app/.gitignore
|
133
134
|
- spec/app/app/assets/stylesheets/docomo_css/simple.css
|
@@ -143,7 +144,7 @@ files:
|
|
143
144
|
- spec/galakei/request_spec.rb
|
144
145
|
- spec/galakei/spacer_spec.rb
|
145
146
|
- spec/spec_helper.rb
|
146
|
-
homepage: http://
|
147
|
+
homepage: http://galakei.mobalean.com/
|
147
148
|
licenses: []
|
148
149
|
post_install_message:
|
149
150
|
rdoc_options: []
|
@@ -168,3 +169,4 @@ signing_key:
|
|
168
169
|
specification_version: 3
|
169
170
|
summary: Japanese feature phones support
|
170
171
|
test_files: []
|
172
|
+
has_rdoc:
|
data/README.md
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# Galakei: Japanese feature phone support
|
2
|
-
|
3
|
-
[Japanese feature phones](http://www.mobalean.com/en/keitai_web_technology_guide) (a.k.a., keitai, galakei) have a number of restrictions over normal web browsers. This library adds support for them.
|
4
|
-
|
5
|
-
## Goals
|
6
|
-
|
7
|
-
* Provide support for 3G handsets from the major 3 carriers in Japan (docomo, au, SoftBank)
|
8
|
-
* Avoid modifying Rails internals as much as possible
|
9
|
-
|
10
|
-
## Features
|
11
|
-
|
12
|
-
### Inlining Styles
|
13
|
-
|
14
|
-
Old docomo handsets [don't support external stylesheets](http://www.keitai-dev.net/CSS). Additionally, only very limited CSS is supported. galakei/docomo_css automatically inlines CSS and manipulates markup to overcome these limitations.
|
15
|
-
|
16
|
-
# css file
|
17
|
-
h1 { color: red; background-color: blue}
|
18
|
-
|
19
|
-
# source html
|
20
|
-
<h1>Foo</h1>
|
21
|
-
|
22
|
-
# outputted html
|
23
|
-
<div style="background-color: blue;"><h1><span style="color:red;">Foo</span></h1>/div>
|
24
|
-
|
25
|
-
Furthermore, the css border property is supported through the "spacer.gif" technique.
|
26
|
-
|
27
|
-
# css file
|
28
|
-
div { border-bottom: 5px solid #000000; }
|
29
|
-
|
30
|
-
# source html
|
31
|
-
<div>Foo</div>
|
32
|
-
|
33
|
-
# outputted html
|
34
|
-
<div>Foo</div>
|
35
|
-
<img src="/galakei/spacer/000000" width="100%" height="5">
|
36
|
-
|
37
|
-
This will generate a 1px by 1px image, emulating the effect of borders on old docomo handsets.
|
38
|
-
|
39
|
-
### Maintaing sessions
|
40
|
-
|
41
|
-
Old docomo handsets [don't support cookies](http://www.keitai-dev.net/Cookies). Furthermore, although Softbank and Au handsets support cookies, when accessing SSL pages, different cookies may be used. Galakei works around this by injecting a session id parameter into your URLs and forms (as long as you use a standard rails method for creating them). To enable this functionality, you will need to modify your session_store.rb initializer to allow the use of session parameters and use a non cookie-based store.
|
42
|
-
|
43
|
-
MyApp::Application.config.session_store :active_record_store, :key => '_sid', :cookie_only => false
|
44
|
-
|
45
|
-
You'll also need to enable this option in galakei
|
46
|
-
|
47
|
-
config.galakei.session_id_parameter = true
|
48
|
-
|
49
|
-
### Emoji
|
50
|
-
|
51
|
-
Easily use [Emoji](http://www.keitai-dev.net/Emoji) in your templates with emoji_table! emoji_table will return the correct emoji for your browser, including normal PC browsers:
|
52
|
-
|
53
|
-
emoji_table.white_smiling_face # "☺"
|
54
|
-
|
55
|
-
### Alternate galakei views
|
56
|
-
|
57
|
-
Have a PC site that you want to add galakei templates for? Put your views in app/views.galakei and they'll be used in preference to your normal app/views
|
58
|
-
|
59
|
-
### haml
|
60
|
-
|
61
|
-
haml is great for building galakei sites, as it enforces well formed markup. galakei takes care of setting the haml template format for you, so you'll generate xhtml.
|
62
|
-
|
63
|
-
### Zenkaku to Hankaku Katakana Conversion
|
64
|
-
|
65
|
-
For galakei, zenkaku katakana such as カタカナ will be converted to hankaku like カタカナ automatically when rendering html. This is standard practice, as zenkaku katakana taxes up too much screen space.
|
66
|
-
|
67
|
-
## Thanks
|
68
|
-
|
69
|
-
* To [jpmobile](https://github.com/jpmobile/jpmobile) for offering the most mature Rails plugin for Rails
|
70
|
-
* To [docomo_css](https://github.com/milk1000cc/docomo_css) for providing the inspiration for galakei/docomo_css
|