SlideShare uma empresa Scribd logo
1 de 96
Baixar para ler offline
Jpmobile
Lay Rails on “Galapagos”
Jpmobile: A Rails Plugin for Japanese Mobile Phones
œ {Ruby             c200 8   Sf[^



   œ { Œ ^ Cg       Ł




   œ { Œ ^ Cg   ¨




   œ { Œ ^ Cg       Ł


                                   Photo taken by Kath B
http://flickr.com/photos/kathb/2196643434/
   œ { Œ ^ Cg   ¨
The Market of Japanese Cellphones
                          œ {Ruby             c200 8   Sf[^




has evolved Exclusively,
                         œ { Œ ^ Cg       Ł




just like Galapagos.     œ { Œ ^ Cg   ¨




                         œ { Œ ^ Cg       Ł


                                                         Photo taken by Kath B
                      http://flickr.com/photos/kathb/2196643434/
                         œ { Œ ^ Cg   ¨
Japanese mobile phones have a lot of
fascinating features ...




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
However, these features are provided
with Cell-phone-operator-specific
specifications,




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
which is sometimes undocumented.




                          œ {Ruby              c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
Example.
Requesting GPS location of device:




                         œ {Ruby              c200 8   Sf[^



                         œ { Œ ^ Cg       Ł




                         œ { Œ ^ Cg   ¨




                         œ { Œ ^ Cg       Ł




                         œ { Œ ^ Cg   ¨
for DoCoMo:
<a href=quot;[URL]quot; lcs>GPS</a>
for au:
<a href=quot;device:gpsone?url=
[URL]&amp;ver=1&amp;datum=0&amp;unit=0
quot;>GPS</a>            (officially undocumented)
for SoftBank 3G:
<a href=location:auto?[URL]>GPS</a>
for SoftBank 2G:
<a href=quot;[URL]quot; z>GPS</a>       œ {Ruby              c200 8   Sf[^




for Willcom:
                                œ { Œ ^ Cg       Ł




<a href=quot;http://location.request/
                                œ { Œ ^ Cg   ¨




dummy.cgi?my=[URL]&pos=$locationquot;>GPS</a>
                                œ { Œ ^ Cg       Ł




                                œ { Œ ^ Cg   ¨
Of course, the responses are also in
various formats!




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
I guess you shouldn’t want to know
them!




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
In short,




            œ {Ruby              c200 8   Sf[^



            œ { Œ ^ Cg       Ł




            œ { Œ ^ Cg   ¨




            œ { Œ ^ Cg       Ł




            œ { Œ ^ Cg   ¨
working on websites for Japanese
mobiles is




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
collecting boring “know-hows.”




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
But we cannot give up the fascinating
features of Japanese mobile phones ...




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
Motivation:
want to build websites for Japanese
mobile phones in Rails way.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
My answer:




             œ {Ruby              c200 8   Sf[^



             œ { Œ ^ Cg       Ł




             œ { Œ ^ Cg   ¨




             œ { Œ ^ Cg       Ł




             œ { Œ ^ Cg   ¨
for DoCoMo:
<a href=quot;[URL]quot; lcs>GPS</a>
for au:
<a href=quot;device:gpsone?url=




     before
[URL]&amp;ver=1&amp;datum=0&amp;unit=0
quot;>GPS</a>            (officially undocumented)
for SoftBank 3G:
<a href=location:auto?[URL]>GPS</a>
for SoftBank 2G:
<a href=quot;[URL]quot; z>GPS</a>       œ {Ruby              c200 8   Sf[^




for Willcom:
                                œ { Œ ^ Cg       Ł




<a href=quot;http://location.request/
                                œ { Œ ^ Cg   ¨




dummy.cgi?my=[URL]&pos=$locationquot;>GPS</a>
                                œ { Œ ^ Cg       Ł




                                œ { Œ ^ Cg   ¨
after
 for all Japanese mobiles:
<%= get_position_link_to quot;GPSquot;,
                         :action=> ... %>
                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
Jpmobile is introduced in ...




                                œ {Ruby              c200 8   Sf[^



                                œ { Œ ^ Cg       Ł




                                œ { Œ ^ Cg   ¨




                                œ { Œ ^ Cg       Ł




                                œ { Œ ^ Cg   ¨
Who am I?




            œ {Ruby              c200 8   Sf[^



            œ { Œ ^ Cg       Ł




            œ { Œ ^ Cg   ¨




            œ { Œ ^ Cg       Ł




            œ { Œ ^ Cg   ¨
SHIDARA Yohji dara
‣ Jpmobile         the author of Jpmobile
‣ http://d.hatena.ne.jp/darashi
    http://twitter.com/darashi
    in Japanese)
‣
  born in Sapporo, live in Sapporo,
  love Sapporo
  -- 1.5hrs. from Tokyo by air œ {Ruby              c200 8   Sf[^




‣            a graduate studentœ { Œ ^ Cg       Ł




‣ Ruby Sapporo Staff
                               œ { Œ ^ Cg   ¨




‣ RubyKaigi2008 Staff          œ { Œ ^ Cg       Ł




                               œ { Œ ^ Cg   ¨
My recent work:




                  œ {Ruby              c200 8   Sf[^



                  œ { Œ ^ Cg       Ł




                  œ { Œ ^ Cg   ¨




                  œ { Œ ^ Cg       Ł




                  œ { Œ ^ Cg   ¨
http://buzztter.com
extracts buzzphrases from twitter.com




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
By the way,




              œ {Ruby              c200 8   Sf[^



              œ { Œ ^ Cg       Ł




              œ { Œ ^ Cg   ¨




              œ { Œ ^ Cg       Ł




              œ { Œ ^ Cg   ¨
I love soupcurry!
(a typical Sapporo food)




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
œ {Ruby              c200 8   Sf[^



œ { Œ ^ Cg       Ł




œ { Œ ^ Cg   ¨




œ { Œ ^ Cg       Ł




œ { Œ ^ Cg   ¨
œ {Ruby              c200 8   Sf[^



œ { Œ ^ Cg       Ł




œ { Œ ^ Cg   ¨




œ { Œ ^ Cg       Ł




œ { Œ ^ Cg   ¨
so that I made a website:




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




http://soupcurry.info
                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




http://soupcurry.info
                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
You can find the nearby soupcurry
restaurants with your mobile (using
GPS). -- if you are in Japan ;-)




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
You can find the nearby soupcurry
restaurants with your mobile (using
GPS). -- if you are in Japan ;-)




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
The reusable component dragged out
from soupcurry.info is the origin of
Jpmobile.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
Features of Jpmobile




                       œ {Ruby              c200 8   Sf[^



                       œ { Œ ^ Cg       Ł




                       œ { Œ ^ Cg   ¨




                       œ { Œ ^ Cg       Ł




                       œ { Œ ^ Cg   ¨
Detecting mobile phones and its
operator




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
is the most fundamental procedure to
handle mobile phones




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
It’s not so easy ...


Various User-Agents:
‣ DoCoMo/2.0 SH902i(c100;TB;W24H12)
‣ KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0
‣ SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/
    NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1
‣   Vodafone/1.0/V903SH/SHJ001/SN000000000000000
    Browser/UP.Browser/7.0.2.1 Profile/MIDP-2.0
    Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-
    V-Profile/VSCL-2.0.0                 œ {Ruby              c200 8   Sf[^



‣   J-PHONE/4.3/V603SH/SNXXXX0000000 SH/0007aa Profile/
                                         œ { Œ ^ Cg       Ł




    MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/
    JSCL-1.3.2                           œ { Œ ^ Cg   ¨




‣   Mozilla/3.0(WILLCOM;KYOCERA/WX310K/
    2;1.2.2.16.000000/0.1/C100) Opera 7.0
                                         œ { Œ ^ Cg       Ł




                                         œ { Œ ^ Cg   ¨
with Jpmobile,




     <% if request.mobile? %>
       from mobile!
     <% else %>
       from PC!
     <% end %>          œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
case request.mobile
when Jpmobile::Mobile::Docomo
  # for DoCoMo
when Jpmobile::Mobile::Au
  # for au
when Jpmobile::Mobile::Softbank
  # for SoftBank
when Jpmobile::Mobile::Willcom
  # for Willcom
when Jpmobile::Mobile::Emobile
  # for EMOBILE         œ {Ruby              c200 8   Sf[^




else
                        œ { Œ ^ Cg       Ł




  # for PC              œ { Œ ^ Cg   ¨




end                     œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
Switching templates for mobiles




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
If you want to switch templates for PCs
and for mobiles, or for each operator,




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
just put mytemplate.html.erb and
mytemplate_mobile.html.erb, or




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
put mytemplate_mobile_docomo.html.erb
and mytemplate_mobile_au.html.erb.
(DoCoMo and au are cell-phone-operators)




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
Supporse that we have these templates.




  mytemplate_mobile_docomo.html.erb


  mytemplate_mobile.html.erb
                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




  mytemplate.html.erb      œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
Access from PC:




  mytemplate_mobile_docomo.html.erb


  mytemplate_mobile.html.erb
                          œ {Ruby              c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




  mytemplate.html.erb     œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
Access from DoCoMo:




  mytemplate_mobile_docomo.html.erb


  mytemplate_mobile.html.erb
                          œ {Ruby              c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




  mytemplate.html.erb     œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
Access from mobiles except DoCoMo:




  mytemplate_mobile_docomo.html.erb


  mytemplate_mobile.html.erb
                           œ {Ruby             c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




  mytemplate.html.erb     œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
Getting position of mobile-phones




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
in a view:

<%= get_position_link_to quot;GPSquot;,
                       :action=> :gps %>

in a controller, ‘gps’ action:


  request.mobile.position.lat
                                 œ {Ruby              c200 8   Sf[^



                                 œ { Œ ^ Cg       Ł




                                 œ { Œ ^ Cg   ¨




  request.mobile.position.lng
                                 œ { Œ ^ Cg       Ł




                                 œ { Œ ^ Cg   ¨
Getting production-numbers and/or
subscriber-identifiers.




                          œ {Ruby              c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
It should be frustrating to input the
password with your mobile every time
you are going to login.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
Usually the identifier of the device or
the subscriber can be obtained.




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
Of course they are based on the various
specifications!




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
with Jpmobile,




request.mobile.ident_device
request.mobile.ident_subscriber

request.mobile.ident
 = ident_subscriber || ident_device
                        œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
Note that they are not creditable
because these identifiers are just
passed as plain text.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
The security will be slightly improved
with combining IP-address verification.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
Validation of IP-address range




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
We may want to block PCs for some
(marketing?) reasons,




                          œ {Ruby              c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
or we may want to check if the
identifiers (for a device or a subscribe)
is surely passed from mobile.




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
The operators provides the information
of the IP-address ranges on the website




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
of course in various formats, and even
worse, usually they are not machine
readable (dirty scraping is needed).




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
Since Jpmobile contains the tables
obtained from these machine-unfriendly
websites,




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
Just do




     request.mobile.valid_ip?


                        œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
Adding session IDs to URL and FORM




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
Some devices does not support cookies.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
For them, you need to pass the session
ID via URL and FORM parameters.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
class MyController <
           ApplicationController
  trans_sid
end
                        œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
Getting specs of the screen




                              œ {Ruby              c200 8   Sf[^



                              œ { Œ ^ Cg       Ł




                              œ { Œ ^ Cg   ¨




                              œ { Œ ^ Cg       Ł




                              œ { Œ ^ Cg   ¨
The screensize differs according to the
model.




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
In order to optimize the output, we
need the information about the screen.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
The information may be passed via
HTTP header, or not.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
We need to scrape the official websites
in case that the information in the
header is not available.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
request.mobile.display.colors
request.mobile.display.width
request.mobile.display.height

                      œ {Ruby              c200 8   Sf[^



                      œ { Œ ^ Cg       Ł




                      œ { Œ ^ Cg   ¨




                      œ { Œ ^ Cg       Ł




                      œ { Œ ^ Cg   ¨
Conversion of the Emoticons




                              œ {Ruby              c200 8   Sf[^



                              œ { Œ ^ Cg       Ł




                              œ { Œ ^ Cg   ¨




                              œ { Œ ^ Cg       Ł




                              œ { Œ ^ Cg   ¨
Lots of lovely emoticons are available
in Japanese mobiles.




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
Each operator have own set of
emoticons and own encoding.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
The specifications are so complex that I
can make another presentation.




                             œ {Ruby             c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
The mappings (between operators) are
also complex and not publicly available
in machine-readable format.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
Jpmobile maps all emoticons (of all
operators) into Unicode Private Area,
and




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
the output is transparently converted
into the format appropriate for the
target device.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
in a controller:


class MyController <
            ApplicationController
  mobile_filter
end
                        œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
I’m going to add the feature to send
emoticons PCs with embedding images.




                          œ {Ruby              c200 8   Sf[^



                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨




                          œ { Œ ^ Cg       Ł




                          œ { Œ ^ Cg   ¨
Some mobiles do not support UTF-8 or
stop sending emoticons under UTF-8
communication.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
We need to communicate with them in
Shift-JIS (a legacy but one of the most
commonly used encoding).




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
in a controller:


class MyController <
            ApplicationController
  mobile_filter
end
                        œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
Summary:




           œ {Ruby              c200 8   Sf[^



           œ { Œ ^ Cg       Ł




           œ { Œ ^ Cg   ¨




           œ { Œ ^ Cg       Ł




           œ { Œ ^ Cg   ¨
Japanese mobile phones have a lot of
fascinating features.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
But we need lots of boring know-hows
to build websites for Japanese mobile
phones.




                           œ {Ruby              c200 8   Sf[^



                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨




                           œ { Œ ^ Cg       Ł




                           œ { Œ ^ Cg   ¨
Jpmobile helps you!




                      œ {Ruby              c200 8   Sf[^



                      œ { Œ ^ Cg       Ł




                      œ { Œ ^ Cg   ¨




                      œ { Œ ^ Cg       Ł




                      œ { Œ ^ Cg   ¨
Finally, I want to ask your help:




                              œ {Ruby              c200 8   Sf[^



                              œ { Œ ^ Cg       Ł




                              œ { Œ ^ Cg   ¨




                              œ { Œ ^ Cg       Ł




                              œ { Œ ^ Cg   ¨
I’m a student, so I don’t have many
mobile-phones to test Jpmobile on.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
I often ask my colleagues for help,
paying a canned coffee.




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
So, if you find out some problems or if
you make any improvement of
Jpmobile, please let me know.




                            œ {Ruby              c200 8   Sf[^



                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨




                            œ { Œ ^ Cg       Ł




                            œ { Œ ^ Cg   ¨
It may take long, but I’d like to work
on it.




                             œ {Ruby              c200 8   Sf[^



                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨




                             œ { Œ ^ Cg       Ł




                             œ { Œ ^ Cg   ¨
œ {Ruby              c200 8   Sf[^



                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨




http://jpmobile-rails.org
                        œ { Œ ^ Cg       Ł




                        œ { Œ ^ Cg   ¨
œ {Ruby              c200 8   Sf[^



œ { Œ ^ Cg       Ł




œ { Œ ^ Cg   ¨




œ { Œ ^ Cg       Ł




œ { Œ ^ Cg   ¨

Mais conteúdo relacionado

Mais de Yoji Shidara

Sinatraで鼻歌混じりのWeb開発 @OSC2009-Do
Sinatraで鼻歌混じりのWeb開発 @OSC2009-DoSinatraで鼻歌混じりのWeb開発 @OSC2009-Do
Sinatraで鼻歌混じりのWeb開発 @OSC2009-DoYoji Shidara
 
Sinatraで鼻歌まじりのWeb開発
Sinatraで鼻歌まじりのWeb開発Sinatraで鼻歌まじりのWeb開発
Sinatraで鼻歌まじりのWeb開発Yoji Shidara
 
SAPICAの利用履歴を可視化する
SAPICAの利用履歴を可視化するSAPICAの利用履歴を可視化する
SAPICAの利用履歴を可視化するYoji Shidara
 
Twitter4Rでつくるゆるふわ愛されTwitter bot
Twitter4Rでつくるゆるふわ愛されTwitter botTwitter4Rでつくるゆるふわ愛されTwitter bot
Twitter4Rでつくるゆるふわ愛されTwitter botYoji Shidara
 
Ruby on Rails でつくるアタシ好みの愛され Web サービス
Ruby on Rails でつくるアタシ好みの愛され Web サービスRuby on Rails でつくるアタシ好みの愛され Web サービス
Ruby on Rails でつくるアタシ好みの愛され Web サービスYoji Shidara
 
RubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こう
RubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こうRubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こう
RubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こうYoji Shidara
 
Twitter分散クロールの野望
Twitter分散クロールの野望Twitter分散クロールの野望
Twitter分散クロールの野望Yoji Shidara
 
Buzztterの裏側とその周辺技術
Buzztterの裏側とその周辺技術Buzztterの裏側とその周辺技術
Buzztterの裏側とその周辺技術Yoji Shidara
 
Pluginが広げるRailsの魅力
Pluginが広げるRailsの魅力Pluginが広げるRailsの魅力
Pluginが広げるRailsの魅力Yoji Shidara
 
Rubyistからみたsoupcurry.info
Rubyistからみたsoupcurry.infoRubyistからみたsoupcurry.info
Rubyistからみたsoupcurry.infoYoji Shidara
 

Mais de Yoji Shidara (10)

Sinatraで鼻歌混じりのWeb開発 @OSC2009-Do
Sinatraで鼻歌混じりのWeb開発 @OSC2009-DoSinatraで鼻歌混じりのWeb開発 @OSC2009-Do
Sinatraで鼻歌混じりのWeb開発 @OSC2009-Do
 
Sinatraで鼻歌まじりのWeb開発
Sinatraで鼻歌まじりのWeb開発Sinatraで鼻歌まじりのWeb開発
Sinatraで鼻歌まじりのWeb開発
 
SAPICAの利用履歴を可視化する
SAPICAの利用履歴を可視化するSAPICAの利用履歴を可視化する
SAPICAの利用履歴を可視化する
 
Twitter4Rでつくるゆるふわ愛されTwitter bot
Twitter4Rでつくるゆるふわ愛されTwitter botTwitter4Rでつくるゆるふわ愛されTwitter bot
Twitter4Rでつくるゆるふわ愛されTwitter bot
 
Ruby on Rails でつくるアタシ好みの愛され Web サービス
Ruby on Rails でつくるアタシ好みの愛され Web サービスRuby on Rails でつくるアタシ好みの愛され Web サービス
Ruby on Rails でつくるアタシ好みの愛され Web サービス
 
RubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こう
RubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こうRubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こう
RubyKaigi2008弾丸レポート / ガラパゴスに線路を敷こう
 
Twitter分散クロールの野望
Twitter分散クロールの野望Twitter分散クロールの野望
Twitter分散クロールの野望
 
Buzztterの裏側とその周辺技術
Buzztterの裏側とその周辺技術Buzztterの裏側とその周辺技術
Buzztterの裏側とその周辺技術
 
Pluginが広げるRailsの魅力
Pluginが広げるRailsの魅力Pluginが広げるRailsの魅力
Pluginが広げるRailsの魅力
 
Rubyistからみたsoupcurry.info
Rubyistからみたsoupcurry.infoRubyistからみたsoupcurry.info
Rubyistからみたsoupcurry.info
 

ガラパゴスに線路を敷こう: 携帯電話用RailsプラグインJpmobile

  • 1. Jpmobile Lay Rails on “Galapagos” Jpmobile: A Rails Plugin for Japanese Mobile Phones
  • 2. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł Photo taken by Kath B http://flickr.com/photos/kathb/2196643434/ œ { Œ ^ Cg ¨
  • 3. The Market of Japanese Cellphones œ {Ruby c200 8 Sf[^ has evolved Exclusively, œ { Œ ^ Cg Ł just like Galapagos. œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł Photo taken by Kath B http://flickr.com/photos/kathb/2196643434/ œ { Œ ^ Cg ¨
  • 4. Japanese mobile phones have a lot of fascinating features ... œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 5. However, these features are provided with Cell-phone-operator-specific specifications, œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 6. which is sometimes undocumented. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 7. Example. Requesting GPS location of device: œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 8. for DoCoMo: <a href=quot;[URL]quot; lcs>GPS</a> for au: <a href=quot;device:gpsone?url= [URL]&amp;ver=1&amp;datum=0&amp;unit=0 quot;>GPS</a> (officially undocumented) for SoftBank 3G: <a href=location:auto?[URL]>GPS</a> for SoftBank 2G: <a href=quot;[URL]quot; z>GPS</a> œ {Ruby c200 8 Sf[^ for Willcom: œ { Œ ^ Cg Ł <a href=quot;http://location.request/ œ { Œ ^ Cg ¨ dummy.cgi?my=[URL]&pos=$locationquot;>GPS</a> œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 9. Of course, the responses are also in various formats! œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 10. I guess you shouldn’t want to know them! œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 11. In short, œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 12. working on websites for Japanese mobiles is œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 13. collecting boring “know-hows.” œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 14. But we cannot give up the fascinating features of Japanese mobile phones ... œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 15. Motivation: want to build websites for Japanese mobile phones in Rails way. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 16. My answer: œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 17. for DoCoMo: <a href=quot;[URL]quot; lcs>GPS</a> for au: <a href=quot;device:gpsone?url= before [URL]&amp;ver=1&amp;datum=0&amp;unit=0 quot;>GPS</a> (officially undocumented) for SoftBank 3G: <a href=location:auto?[URL]>GPS</a> for SoftBank 2G: <a href=quot;[URL]quot; z>GPS</a> œ {Ruby c200 8 Sf[^ for Willcom: œ { Œ ^ Cg Ł <a href=quot;http://location.request/ œ { Œ ^ Cg ¨ dummy.cgi?my=[URL]&pos=$locationquot;>GPS</a> œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 18. after for all Japanese mobiles: <%= get_position_link_to quot;GPSquot;, :action=> ... %> œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 19. Jpmobile is introduced in ... œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 20. Who am I? œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 21. SHIDARA Yohji dara ‣ Jpmobile the author of Jpmobile ‣ http://d.hatena.ne.jp/darashi http://twitter.com/darashi in Japanese) ‣ born in Sapporo, live in Sapporo, love Sapporo -- 1.5hrs. from Tokyo by air œ {Ruby c200 8 Sf[^ ‣ a graduate studentœ { Œ ^ Cg Ł ‣ Ruby Sapporo Staff œ { Œ ^ Cg ¨ ‣ RubyKaigi2008 Staff œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 22. My recent work: œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 23. http://buzztter.com extracts buzzphrases from twitter.com œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 24. By the way, œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 25. I love soupcurry! (a typical Sapporo food) œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 26. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 27. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 28. so that I made a website: œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 29. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł http://soupcurry.info œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 30. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł http://soupcurry.info œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 31. You can find the nearby soupcurry restaurants with your mobile (using GPS). -- if you are in Japan ;-) œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 32. You can find the nearby soupcurry restaurants with your mobile (using GPS). -- if you are in Japan ;-) œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 33. The reusable component dragged out from soupcurry.info is the origin of Jpmobile. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 34. Features of Jpmobile œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 35. Detecting mobile phones and its operator œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 36. is the most fundamental procedure to handle mobile phones œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 37. It’s not so easy ... Various User-Agents: ‣ DoCoMo/2.0 SH902i(c100;TB;W24H12) ‣ KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0 ‣ SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/ NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1 ‣ Vodafone/1.0/V903SH/SHJ001/SN000000000000000 Browser/UP.Browser/7.0.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext- V-Profile/VSCL-2.0.0 œ {Ruby c200 8 Sf[^ ‣ J-PHONE/4.3/V603SH/SNXXXX0000000 SH/0007aa Profile/ œ { Œ ^ Cg Ł MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/ JSCL-1.3.2 œ { Œ ^ Cg ¨ ‣ Mozilla/3.0(WILLCOM;KYOCERA/WX310K/ 2;1.2.2.16.000000/0.1/C100) Opera 7.0 œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 38. with Jpmobile, <% if request.mobile? %> from mobile! <% else %> from PC! <% end %> œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 39. case request.mobile when Jpmobile::Mobile::Docomo # for DoCoMo when Jpmobile::Mobile::Au # for au when Jpmobile::Mobile::Softbank # for SoftBank when Jpmobile::Mobile::Willcom # for Willcom when Jpmobile::Mobile::Emobile # for EMOBILE œ {Ruby c200 8 Sf[^ else œ { Œ ^ Cg Ł # for PC œ { Œ ^ Cg ¨ end œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 40. Switching templates for mobiles œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 41. If you want to switch templates for PCs and for mobiles, or for each operator, œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 42. just put mytemplate.html.erb and mytemplate_mobile.html.erb, or œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 43. put mytemplate_mobile_docomo.html.erb and mytemplate_mobile_au.html.erb. (DoCoMo and au are cell-phone-operators) œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 44. Supporse that we have these templates. mytemplate_mobile_docomo.html.erb mytemplate_mobile.html.erb œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł mytemplate.html.erb œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 45. Access from PC: mytemplate_mobile_docomo.html.erb mytemplate_mobile.html.erb œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł mytemplate.html.erb œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 46. Access from DoCoMo: mytemplate_mobile_docomo.html.erb mytemplate_mobile.html.erb œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł mytemplate.html.erb œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 47. Access from mobiles except DoCoMo: mytemplate_mobile_docomo.html.erb mytemplate_mobile.html.erb œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł mytemplate.html.erb œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 48. Getting position of mobile-phones œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 49. in a view: <%= get_position_link_to quot;GPSquot;, :action=> :gps %> in a controller, ‘gps’ action: request.mobile.position.lat œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ request.mobile.position.lng œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 50. Getting production-numbers and/or subscriber-identifiers. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 51. It should be frustrating to input the password with your mobile every time you are going to login. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 52. Usually the identifier of the device or the subscriber can be obtained. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 53. Of course they are based on the various specifications! œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 54. with Jpmobile, request.mobile.ident_device request.mobile.ident_subscriber request.mobile.ident = ident_subscriber || ident_device œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 55. Note that they are not creditable because these identifiers are just passed as plain text. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 56. The security will be slightly improved with combining IP-address verification. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 57. Validation of IP-address range œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 58. We may want to block PCs for some (marketing?) reasons, œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 59. or we may want to check if the identifiers (for a device or a subscribe) is surely passed from mobile. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 60. The operators provides the information of the IP-address ranges on the website œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 61. of course in various formats, and even worse, usually they are not machine readable (dirty scraping is needed). œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 62. Since Jpmobile contains the tables obtained from these machine-unfriendly websites, œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 63. Just do request.mobile.valid_ip? œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 64. Adding session IDs to URL and FORM œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 65. Some devices does not support cookies. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 66. For them, you need to pass the session ID via URL and FORM parameters. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 67. class MyController < ApplicationController trans_sid end œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 68. Getting specs of the screen œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 69. The screensize differs according to the model. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 70. In order to optimize the output, we need the information about the screen. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 71. The information may be passed via HTTP header, or not. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 72. We need to scrape the official websites in case that the information in the header is not available. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 73. request.mobile.display.colors request.mobile.display.width request.mobile.display.height œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 74. Conversion of the Emoticons œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 75. Lots of lovely emoticons are available in Japanese mobiles. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 76. Each operator have own set of emoticons and own encoding. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 77. The specifications are so complex that I can make another presentation. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 78. The mappings (between operators) are also complex and not publicly available in machine-readable format. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 79. Jpmobile maps all emoticons (of all operators) into Unicode Private Area, and œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 80. the output is transparently converted into the format appropriate for the target device. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 81. in a controller: class MyController < ApplicationController mobile_filter end œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 82. I’m going to add the feature to send emoticons PCs with embedding images. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 83. Some mobiles do not support UTF-8 or stop sending emoticons under UTF-8 communication. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 84. We need to communicate with them in Shift-JIS (a legacy but one of the most commonly used encoding). œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 85. in a controller: class MyController < ApplicationController mobile_filter end œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 86. Summary: œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 87. Japanese mobile phones have a lot of fascinating features. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 88. But we need lots of boring know-hows to build websites for Japanese mobile phones. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 89. Jpmobile helps you! œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 90. Finally, I want to ask your help: œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 91. I’m a student, so I don’t have many mobile-phones to test Jpmobile on. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 92. I often ask my colleagues for help, paying a canned coffee. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 93. So, if you find out some problems or if you make any improvement of Jpmobile, please let me know. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 94. It may take long, but I’d like to work on it. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 95. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ http://jpmobile-rails.org œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨
  • 96. œ {Ruby c200 8 Sf[^ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨ œ { Œ ^ Cg Ł œ { Œ ^ Cg ¨