Sha256: 1b477fe28402df39cd8439eadc663fd57455e692384c6c7fdf318d83013efca7
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
module SMKLib module Browsers def is_mobile_browser?(ua) mobile_browsers = [ 'DoCoMo', 'alcatel', 'auditautomatic', 'ericsson', 'lg-g7000', 'mitsu', 'mot-.*', 'nokian-gage', 'opwv-sdk', 'panasonic-[xg].*', 'philips-.*', 'r380', 'r600', 'sagem-3xxx', 'sagem-9xx', 'sagem-myx-.*', 'samsung-sgh-[xevtasrn][0-9][0-9][0-9].*', 'sec-sgh[cpqsavdex][0-9][0-9][0-9]', 'sharp-tq-gx[0-9][0-9]', 'sonyericsson', 'alcatel', 'ericssona2628s', 'ericssonr320', 'lg-[cfgltG0-9]*', 'sie-[acfxvmniedsklt0-9]*', 'sagem-m.*', 'mot-[-abvcetdf0-9]*', 'nokia[0-9]*', 'panasonic', 't66', 'n21i', 'n22i', 'ts21i', 'portalmmm', 'ipcheck', 'cnf2' ] is_it = false modified_ua = ua.gsub(/[+ ]/, '_') mobile_browsers.each do |x| is_it = true if modified_ua.match(/^#{x}/) end return is_it end def user_agent ua = request.env['HTTP_USER_AGENT'] if ua.nil? "31337_h4x0r" elsif ua.match(/Opera/) "Opera" elsif ua.match(/MSIE/) "MSIE" elsif ua.match(/Safari/) "Safari" elsif ua.match(/KHTML/) "KHTML" elsif is_mobile_browser?(ua) "Mobile" else # we are not making a difference for other browsers. "Mozilla" # standard end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
smklib-1.2.0 | lib/smklib/browsers.rb |
smklib-1.1.2 | lib/smklib/browsers.rb |
smklib-1.1.1 | lib/smklib/browsers.rb |
smklib-1.1.0 | lib/smklib/browsers.rb |
smklib-1.0.6 | lib/smklib/browsers.rb |