]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2003-09-17 23:28:14 by doogie]
authordoogie <>
Thu, 18 Sep 2003 06:28:14 +0000 (22:28 -0800)
committerdoogie <>
Thu, 18 Sep 2003 06:28:14 +0000 (22:28 -0800)
* Add user-agent detection.  This currently doesn't change anything,
  howeever.
* Add options show_list_(head|foot)er.

cgi/common.pl
cgi/pkgreport.cgi
debian/changelog

index 762a71da0aeb532e0c04ec778e6e3c3fceb7038b..ba944a0ffb15c3a0f5f79253f05b0c93ec2aeea2 100644 (file)
@@ -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 .= "</ul>\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;
 }
 
index 6332888d5af3cb9459cedb8709c083ec793e9ea1..07ff3a2ee841b260f1aa76cdcc81f3da88d8e133 100755 (executable)
@@ -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;
index a9652bc9970fcea57cff13a31a161c7ddc624712..872661019b7362ae459f32d7652514fc7491005b 100644 (file)
@@ -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 <cjwatson@debian.org>  Fri, 20 Jun 2003 18:57:25 +0100