Sha256: c8ad23618b153cbb45499730746060c47bc5900de979be6596b316b356501151

Contents?: true

Size: 646 Bytes

Versions: 15

Compression:

Stored size: 646 Bytes

Contents

require 'murlsh'

module Murlsh

  # Convert urls specifically for use on mobile devices into their non-mobile
  # equivalents.
  class AddPre40ConvertMobile < Plugin

    @hook = 'add_pre'

    TwitterRe = %r{^(http://)mobile\.(twitter\.com/.*)$}i
    WikipediaRe = %r{^(http://[a-z]+\.)m\.(wikipedia\.org/.*)$}i

    def self.unmobile(url)
      case
        when match = TwitterRe.match(url); "#{match[1]}#{match[2]}"
        when match = WikipediaRe.match(url); "#{match[1]}#{match[2]}"
        else; url
      end
    end

    def self.run(url, config)
      url.url = unmobile(url.url)
      url.via = unmobile(url.via)
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
murlsh-1.9.3 plugins/add_pre_40_convert_mobile.rb
murlsh-1.9.2 plugins/add_pre_40_convert_mobile.rb
murlsh-1.9.1 plugins/add_pre_40_convert_mobile.rb
murlsh-1.9.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.8.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.7.1 plugins/add_pre_40_convert_mobile.rb
murlsh-1.7.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.6.1 plugins/add_pre_40_convert_mobile.rb
murlsh-1.6.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.5.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.4.1 plugins/add_pre_40_convert_mobile.rb
murlsh-1.4.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.3.1 plugins/add_pre_40_convert_mobile.rb
murlsh-1.3.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.2.1 plugins/add_pre_40_convert_mobile.rb