Sha256: 8706e2dcf1e3ebedd603aa09d961107d7f7e22f6244340b2c6e5d9174fc36cfc

Contents?: true

Size: 764 Bytes

Versions: 21

Compression:

Stored size: 764 Bytes

Contents

# coding: utf-8
class Galakei::Filter::NonStandardChar < Galakei::Filter::Base
  def self.inject(klass)
    this_class = self
    klass.after_filter self, :if => lambda {|c| this_class.condition?(c) }
  end  

  def condition?
    response.content_type =~ %r{text/html|application/xhtml+xml} &&
      (response.charset || Rails.application.config.encoding).downcase == "utf-8"
  end

  def filter
    body = response.body
    full_dot = "\u30FB"
    half_dot = "\uFF65"
    body.gsub!("&middot;", full_dot) if request.docomo?
    body.gsub!("\u00B7",   half_dot) unless request.softbank?
    body.gsub!("&#xFF65;", half_dot) if request.au?
    body.gsub!("&#x30FB;", full_dot) if request.au?
    body.gsub!("&sdot;",   half_dot)
    response.body = body
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
galakei-0.12.1 lib/galakei/filter/non_standard_char.rb
galakei-0.12.0 lib/galakei/filter/non_standard_char.rb
galakei-0.11.3 lib/galakei/filter/non_standard_char.rb
galakei-0.11.2 lib/galakei/filter/non_standard_char.rb
galakei-0.11.1 lib/galakei/filter/non_standard_char.rb
galakei-0.11.0 lib/galakei/filter/non_standard_char.rb
galakei-0.10.1 lib/galakei/filter/non_standard_char.rb
galakei-0.10.0 lib/galakei/filter/non_standard_char.rb
galakei-0.9.1 lib/galakei/filter/non_standard_char.rb
galakei-0.9.0 lib/galakei/filter/non_standard_char.rb
galakei-0.8.1 lib/galakei/filter/non_standard_char.rb
galakei-0.8.0 lib/galakei/filter/non_standard_char.rb
galakei-0.7.3 lib/galakei/filter/non_standard_char.rb
galakei-0.7.2 lib/galakei/filter/non_standard_char.rb
galakei-0.7.1 lib/galakei/filter/non_standard_char.rb
galakei-0.7.0 lib/galakei/filter/non_standard_char.rb
galakei-0.6.6 lib/galakei/filter/non_standard_char.rb
galakei-0.6.5 lib/galakei/filter/non_standard_char.rb
galakei-0.6.4 lib/galakei/filter/non_standard_char.rb
galakei-0.6.3 lib/galakei/filter/non_standard_char.rb