use HTTP::BrowserDetect for browser detection
This commit is contained in:
parent
5e75631f6b
commit
6fa07671cd
7 changed files with 31 additions and 58 deletions
|
|
@ -1067,36 +1067,6 @@
|
|||
# "extrasExclude": ["tinymce", "^blah$"]
|
||||
# },
|
||||
|
||||
#A list of UserAgents of recognized mobile platforms. If useMobileStyle is set in the
|
||||
#Admin settings, then the mobile style will be used for these browsers.
|
||||
"mobileUserAgents" : [
|
||||
"AvantGo",
|
||||
"DoCoMo",
|
||||
"Vodafone",
|
||||
"EudoraWeb",
|
||||
"Minimo",
|
||||
"UP\\.Browser",
|
||||
"PLink",
|
||||
"Plucker",
|
||||
"NetFront",
|
||||
"^WM5 PIE$",
|
||||
"Xiino",
|
||||
"iPhone",
|
||||
"Opera Mobi",
|
||||
"BlackBerry",
|
||||
"Opera Mini",
|
||||
"HP iPAQ",
|
||||
"IEMobile",
|
||||
"Profile/MIDP",
|
||||
"Smartphone",
|
||||
"Symbian ?OS",
|
||||
"J2ME/MIDP",
|
||||
"PalmSource",
|
||||
"PalmOS",
|
||||
"Windows CE",
|
||||
"Opera Mini"
|
||||
],
|
||||
|
||||
# For the siteIndex content plugin. Whether or not the auto-generated siteIndex should
|
||||
# show hidden pages
|
||||
"siteIndex" : {
|
||||
|
|
|
|||
|
|
@ -1044,7 +1044,7 @@ sub www_drawGanttChart {
|
|||
}
|
||||
|
||||
#Adjust top for MSIE
|
||||
my $isMSIE = ($session->env->request->user_agent =~ /msie/i);
|
||||
my $isMSIE = $session->request->browser->ie;
|
||||
my $divTop = $isMSIE ? 45 : 45;
|
||||
#Start at 45 px and add 20px as the start of the new task
|
||||
#Set the propert mutiplier
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ sub process {
|
|||
# Fix box size
|
||||
my $boxSize = $param[0];
|
||||
$boxSize = 12 unless ($boxSize);
|
||||
if (index(lc($session->request->user_agent),"msie") < 0) {
|
||||
if ($session->request->browser->ie) {
|
||||
$boxSize = int($boxSize=$boxSize*2/3);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package WebGUI::Session::Request;
|
|||
use strict;
|
||||
use parent qw(Plack::Request);
|
||||
use WebGUI::Session::Response;
|
||||
use HTTP::BrowserDetect;
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
|
@ -21,6 +22,19 @@ is created.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 browser
|
||||
|
||||
Returns a HTTP::BrowserDetect object for the request.
|
||||
|
||||
=cut
|
||||
|
||||
sub browser {
|
||||
my $self = shift;
|
||||
return $self->env->{'webgui.browser'} ||= HTTP::BrowserDetect->new($self->user_agent);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 clientIsSpider ( )
|
||||
|
||||
Returns true is the client/agent is a spider/indexer or some other non-human interface, determined
|
||||
|
|
@ -29,29 +43,12 @@ by checking the user agent against a list of known spiders.
|
|||
=cut
|
||||
|
||||
sub clientIsSpider {
|
||||
|
||||
my $self = shift;
|
||||
my $userAgent = $self->user_agent;
|
||||
|
||||
return 1 if $userAgent eq ''
|
||||
|| $userAgent =~ m<(^wre\/| # the WRE wget's http://localhost/ every 2-3 minutes 24 hours a day...
|
||||
^morpheus|
|
||||
libwww|
|
||||
s[pb]ider|
|
||||
bot|
|
||||
robo|
|
||||
sco[ou]t|
|
||||
crawl|
|
||||
miner|
|
||||
reaper|
|
||||
finder|
|
||||
search|
|
||||
engine|
|
||||
download|
|
||||
fetch|
|
||||
scan|
|
||||
slurp)>ix;
|
||||
|
||||
return 1
|
||||
if $self->user_agent eq ''
|
||||
|| $self->user_agent =~ /^wre/
|
||||
|| $self->browser->robot;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,11 +130,9 @@ sub useMobileStyle {
|
|||
if (! $session->setting->get('useMobileStyle')) {
|
||||
return $self->{_useMobileStyle} = 0;
|
||||
}
|
||||
my $ua = $session->request->user_agent;
|
||||
for my $mobileUA (@{ $self->session->config->get('mobileUserAgents') }) {
|
||||
if ($ua =~ m/$mobileUA/) {
|
||||
return $self->{_useMobileStyle} = 1;
|
||||
}
|
||||
|
||||
if ($session->request->browser->mobile) {
|
||||
return $self->{_useMobileStyle} = 1;
|
||||
}
|
||||
return $self->{_useMobileStyle} = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ checkModule('Net::Twitter', "3.13006" );
|
|||
checkModule('Number::Format', );
|
||||
checkModule('Email::Valid', );
|
||||
checkModule('Facebook::Graph', '0.0505' );
|
||||
checkModule('HTTP::BrowserDetect', );
|
||||
|
||||
failAndExit("Required modules are missing, running no more checks.") if $missingModule;
|
||||
|
||||
|
|
|
|||
7
share/upgrades/7.9.13-8.0.0/removeMobileUserAgents.pl
Normal file
7
share/upgrades/7.9.13-8.0.0/removeMobileUserAgents.pl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use WebGUI::Upgrade::Script;
|
||||
|
||||
start_step "Removing mobile agent list";
|
||||
|
||||
config->delete('mobileUserAgents');
|
||||
|
||||
done;
|
||||
Loading…
Add table
Add a link
Reference in a new issue