use HTTP::BrowserDetect for browser detection

This commit is contained in:
Graham Knop 2010-09-11 03:09:27 -05:00
parent 5e75631f6b
commit 6fa07671cd
7 changed files with 31 additions and 58 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}