OSDN Git Service

Mobile Deviceを利用せずに、JPMobileを利用するよう修正(社内ブランチよりマージ)
authortmatsuzawa <tmatsuzawa@06daa6dd-5c14-464e-8a85-0d68c524be32>
Tue, 12 Jan 2010 07:27:52 +0000 (07:27 +0000)
committertmatsuzawa <tmatsuzawa@06daa6dd-5c14-464e-8a85-0d68c524be32>
Tue, 12 Jan 2010 07:27:52 +0000 (07:27 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/elecoma/trunk@24 06daa6dd-5c14-464e-8a85-0d68c524be32

app/controllers/base_controller.rb
app/controllers/image_resource_controller.rb
app/controllers/inquiries_controller.rb
app/controllers/portal_controller.rb
app/controllers/questionnaires_controller.rb
app/helpers/base_helper.rb

index 55b50b4..f2e871d 100644 (file)
@@ -4,7 +4,6 @@ class BaseController < ApplicationController
   before_filter :verify_session_token
   before_filter :load_data
   before_filter :set_headers
-  before_filter :device_check
   after_filter :end_transaction
   layout 'base'
   mobile_filter
@@ -126,17 +125,6 @@ class BaseController < ApplicationController
     end
   end
 
-  def device_check
-    request.mobile? or return true
-    conditions = ['? like user_agent', request.user_agent]
-    @mobile_device = MobileDevice.find(:first, :conditions => conditions)
-    if @mobile_device.blank?
-      logger.info "device_check error #{request.user_agent}"
-      redirect_to :controller => 'portal', :action => 'unsupported_device'
-      return false
-    end
-  end
-
   alias_method :non_application_rescue_action, :rescue_action
   def rescue_action(exception)
     ActiveRecord::Base.connection.rollback_db_transaction
index 4436169..b8f8068 100644 (file)
@@ -1,5 +1,4 @@
 class ImageResourceController < BaseController
-  before_filter :set_mobile_spec
 
   #caches_page :show
   def show
@@ -10,11 +9,11 @@ class ImageResourceController < BaseController
       @res ||= ImageResource.find_by_id(params[:id])
     end
     raise ActiveRecord::RecordNotFound unless @res
-    if @mobile_spec && @mobile_spec  =~ /^(\d+)x(\d+)$/
+    if request.mobile?
       if params[:width].present? || params[:height].present?
         width, height = [params[:width].to_i, params[:height].to_i]
       else
-        width, height = [$1.to_i, $2.to_i]
+        width, height = request.mobile.display.width, request.mobile.display.height
       end
       send_file @res, @res.scaled_image(width, height)
     else
@@ -36,31 +35,4 @@ class ImageResourceController < BaseController
     end
     send_data(data, :type => content_type, :disposition => 'inline')
   end
-
-  MOBILE_SPEC = Hash[*File.read("#{RAILS_ROOT}/db/migrate/fixed_data/mobile_specs.txt").split(/\n/).compact.map{|a|a.split(/\t/)[0...2]}.flatten]
-
-  def set_mobile_spec
-    begin
-      if request.mobile?
-        ua = request.user_agent || ''
-        @mobile_spec = case request.mobile
-                       when Jpmobile::Mobile::Docomo
-                         MOBILE_SPEC["i/#{$1}"] if ua =~ %r{^DoCoMo/(?:1.0/|2.0 )(\w+)}
-                       when Jpmobile::Mobile::Au
-                         MOBILE_SPEC["a/#{$1}"] if ua =~ %r{^(?:KDDI-|UP\.Browser/.*?-)(\w+)}
-                       when Jpmobile::Mobile::Softbank
-                         MOBILE_SPEC["s/#{$1}"] if ua =~ %r{^((.*?)/(.*?)/[\w-]+)}
-                       end
-        if @mobile_device
-          @mobile_spec = "#{@mobile_device.width}x#{@mobile_device.height}"
-        end
-        @mobile_spec ||= "240x320" 
-      end
-    rescue NoMethodError
-      # テストのときは user_agent メソッドがない
-      if request.mobile?
-        @mobile_spec ||= "240x320" if is_mobile?
-      end
-    end
-  end
 end
index 6698d57..0deac41 100644 (file)
@@ -1,5 +1,4 @@
 class InquiriesController < BaseController
-#  before_filter :device_check, :except => :unsupported_device
   before_filter :init_by_params, :only=>[:new, :confirm, :complete]
 
   def show
index b40091d..6196a3f 100644 (file)
@@ -1,7 +1,5 @@
 # -*- coding: utf-8 -*-
 class PortalController < BaseController
-  before_filter :device_check, :except => :unsupported_device
-
 
   def show
     load_new_information
index de985b9..9bbf0c6 100644 (file)
@@ -1,7 +1,6 @@
 #class QuestionnairesController < ApplicationController
 class QuestionnairesController < BaseController
   before_filter :get_questionnaire
-  before_filter :device_check, :except => :unsupported_device
 
   def complete
     questionnaire_answer = QuestionnaireAnswer.new params[:respondent]
index 48fcf30..643cb1c 100644 (file)
@@ -352,7 +352,7 @@ def each_product_styles(product)
 end
 
 def image_tag_mobile(prefix, options={})
-  width = @mobile_device.width.to_i unless @mobile_device.blank?
+  width = request.mobile.display.width
   size = 'q' # q = QVGA, v = VGA
   size = 'v' if !width.blank? && width >= 480
   format = 'gif'