From: doogie <> Date: Thu, 18 Sep 2003 06:28:14 +0000 (-0800) Subject: [project @ 2003-09-17 23:28:14 by doogie] X-Git-Tag: release/2.6.0~789 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e3b26e5ffed8738c1a3e3e393add9a6eac5347f9;p=debbugs.git [project @ 2003-09-17 23:28:14 by doogie] * Add user-agent detection. This currently doesn't change anything, howeever. * Add options show_list_(head|foot)er. --- diff --git a/cgi/common.pl b/cgi/common.pl index 762a71d..ba944a0 100644 --- a/cgi/common.pl +++ b/cgi/common.pl @@ -4,7 +4,7 @@ use DB_File; use Fcntl qw/O_RDONLY/; use Mail::Address; use MLDBM qw/DB_File/; -use POSIX; +use POSIX qw/ceil/; $config_path = '/etc/debbugs'; $lib_path = '/usr/lib/debbugs'; @@ -25,6 +25,10 @@ my %common_reverse = ( 'pending' => 0, 'severity' => 0, ); +my %common = ( + 'show_list_header' => 1, + 'show_list_footer' => 1, +); sub exact_field_match { my ($field, $values, $status) = @_; @@ -40,6 +44,15 @@ sub contains_field_match { return 0; } +sub detect_user_agent { + my $userAgent = $ENV{HTTP_USER_AGENT}; + return { 'name' => 'links' } if ( $userAgent =~ m,^ELinks,); + return { 'name' => 'lynx' } if ( $userAgent =~ m,^Lynx,); + return { 'name' => 'wget' } if ( $userAgent =~ m,^Wget,); + return { 'name' => 'gecko' } if ( $userAgent =~ m,^Mozilla.* Gecko/,); + return { 'name' => 'ie' } if ( $userAgent =~ m,^.*MSIE.*,); + return { 'name' => 'unknown' }; +} my %field_match = ( 'subject' => \&contains_field_match, 'tags' => sub { @@ -114,6 +127,7 @@ sub filter_option($$\%) { sub set_option { my ($opt, $val) = @_; + if ($opt =~ m/^show_list_(foot|head)er$/) { $common{$opt} = $val; } if ($opt eq "archive") { $common_archive = $val; } if ($opt eq "repeatmerged") { $common_repeatmerged = $val; } if ($opt eq "exclude") { @@ -563,9 +577,9 @@ sub htmlizebugs { $footer .= "\n"; } - $result = $header . $result; + $result = $header . $result if ( $common{show_list_header} ); $result .= $debbugs::gHTMLExpireNote if $gRemoveAge and $anydone; - $result .= $footer; + $result .= $footer if ( $common{show_list_footer} ); return $result; } diff --git a/cgi/pkgreport.cgi b/cgi/pkgreport.cgi index 6332888..07ff3a2 100755 --- a/cgi/pkgreport.cgi +++ b/cgi/pkgreport.cgi @@ -20,6 +20,7 @@ if ($ENV{REQUEST_METHOD} eq 'HEAD') { nice(5); +my $userAgent = detect_user_agent(); my %param = readparse(); my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes"; @@ -37,6 +38,8 @@ my $sev_inc = $param{'&sev-inc'} || $param{'sev-inc'} || ""; my $version = $param{'version'} || undef; my $dist = $param{'dist'} || undef; my $arch = $param{'arch'} || undef; +my $show_list_header = ($param{'show_list_header'} || $userAgent->{'show_list_header'} || "yes" ) eq "yes"; +my $show_foot_header = ($param{'show_foot_header'} || $userAgent->{'show_list_footer'} || "yes" ) eq "yes"; my ($pkg, $src, $maint, $maintenc, $submitter, $severity, $status, $tag); @@ -111,6 +114,8 @@ set_option("sev-inc", $sev_inc); set_option("version", $version); set_option("dist", $dist); set_option("arch", $arch); +set_option("show_list_header", $show_list_header); +set_option("show_foot_header", $show_foot_header); my $title; my @bugs; diff --git a/debian/changelog b/debian/changelog index a9652bc..8726610 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,9 @@ debbugs (2.4.2) UNRELEASED; urgency=low - Add in a Table of Contents to pkgreport.cgi. - Display how long until a resolved bug will be archived in pkgreport.cgi. + - Add user-agent detection. This currently doesn't change anything, + however. + - Add options show_list_(head|foot)er. -- Colin Watson Fri, 20 Jun 2003 18:57:25 +0100