]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgindex.cgi
Fix lack of archive support in pkgindex.cgi.
[debbugs.git] / cgi / pkgindex.cgi
index c667aacab0e2d11905e2a9cd81b45f28347479ff..a0e91ae8978b6af7904175e7482e58d3f0ada75d 100755 (executable)
@@ -4,10 +4,14 @@ use warnings;
 use strict;
 use POSIX qw(strftime nice);
 
-use Debbugs::Config;
+use Debbugs::Config qw(:globals :text :config);
 use CGI::Simple;
-use Debbugs::CGI qw(cgi_parameters);
-require './common.pl';
+use Debbugs::CGI qw(:util :url :html);
+use Debbugs::Common qw(getmaintainers getparsedaddrs);
+use Debbugs::Bugs qw(count_bugs);
+use Debbugs::Status qw(:status);
+use Debbugs::Packages qw(getpkgsrc);
+use Debbugs::Text qw(:templates);
 
 nice(5);
 
@@ -55,9 +59,6 @@ my %maintainers = %{&getmaintainers()};
 my %strings = ();
 
 my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime;
-my $tail_html = '';#$gHTMLTail;
-$tail_html = '';#$gHTMLTail;
-$tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
 
 my %count;
 my $tag;
@@ -66,7 +67,9 @@ my %htmldescrip = ();
 my %sortkey = ();
 if ($indexon eq "pkg") {
   $tag = "package";
-  %count = countbugs(sub {my %d=@_; return splitpackages($d{"pkg"})});
+  %count = count_bugs(function => sub {my %d=@_; return splitpackages($d{"pkg"})},
+                    archive => $archive,
+                    );
   if (defined $param{first}) {
        %count = map {
            if (/^\Q$param{first}\E/) {
@@ -82,9 +85,9 @@ if ($indexon eq "pkg") {
   foreach my $pkg (keys %count) {
     $sortkey{$pkg} = lc $pkg;
     $htmldescrip{$pkg} = sprintf('<a href="%s">%s</a> (%s)',
-                           pkgurl($pkg),
-                           htmlsanit($pkg),
-                           htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: '
+                           package_links(package => $pkg, links_only=>1),
+                           html_escape($pkg),
+                           htmlize_maintlinks(sub { $_[0] == 1 ? 'maintainer: '
                                                            : 'maintainers: ' },
                                           $maintainers{$pkg}));
   }
@@ -101,25 +104,27 @@ if ($indexon eq "pkg") {
            } 
        } keys %count;
   }
-  %count = countbugs(sub {my %d=@_;
+  %count = count_bugs(function => sub {my %d=@_;
                           return map {
                             $pkgsrc->{$_} || $_
                           } splitpackages($d{"pkg"});
-                         });
+                         },
+                    archive => $archive,
+                    );
   $note = "";
   foreach my $src (keys %count) {
     $sortkey{$src} = lc $src;
     $htmldescrip{$src} = sprintf('<a href="%s">%s</a> (%s)',
-                           srcurl($src),
-                           htmlsanit($src),
-                           htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: '
+                           package_links(src => $src, links_only=>1),
+                           html_escape($src),
+                           htmlize_maintlinks(sub { $_[0] == 1 ? 'maintainer: '
                                                            : 'maintainers: ' },
                                           $maintainers{$src}));
   }
 } elsif ($indexon eq "maint") {
   $tag = "maintainer";
   my %email2maint = ();
-  %count = countbugs(sub {my %d=@_;
+  %count = count_bugs(function => sub {my %d=@_;
                           return map {
                             my @me = getparsedaddrs($maintainers{$_});
                             foreach my $addr (@me) {
@@ -128,7 +133,9 @@ if ($indexon eq "pkg") {
                             }
                             map { $_->address } @me;
                           } splitpackages($d{"pkg"});
-                         });
+                         },
+                    archive => $archive,
+                    );
   if (defined $param{first}) {
        %count = map {
            if (/^\Q$param{first}\E/) {
@@ -144,19 +151,21 @@ if ($indexon eq "pkg") {
   $note .= "different addresses.</p>\n";
   foreach my $maint (keys %count) {
     $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)";
-    $htmldescrip{$maint} = htmlmaintlinks('', $email2maint{$maint});
+    $htmldescrip{$maint} = htmlize_maintlinks('', $email2maint{$maint});
   }
 } elsif ($indexon eq "submitter") {
   $tag = "submitter";
   my %fullname = ();
-  %count = countbugs(sub {my %d=@_;
+  %count = count_bugs(function => sub {my %d=@_;
                           my @se = getparsedaddrs($d{"submitter"} || "");
                           foreach my $addr (@se) {
                             $fullname{$addr->address} = $addr->format
                               unless exists $fullname{$addr->address};
                           }
                           map { $_->address } @se;
-                         });
+                         },
+                    archive => $archive,
+                    );
   if (defined $param{first}) {
        %count = map {
            if (/^\Q$param{first}\E/) {
@@ -171,14 +180,16 @@ if ($indexon eq "pkg") {
     $sortkey{$sub} = lc $fullname{$sub};
     $htmldescrip{$sub} = sprintf('<a href="%s">%s</a>',
                            submitterurl($sub),
-                          htmlsanit($fullname{$sub}));
+                          html_escape($fullname{$sub}));
   }
   $note = "<p>Note that people may use different email accounts for\n";
   $note .= "different bugs, so there may be other reports filed under\n";
   $note .= "different addresses.</p>\n";
 } elsif ($indexon eq "tag") {
   $tag = "tag";
-  %count = countbugs(sub {my %d=@_; return split ' ', $d{tags}; });
+  %count = count_bugs(function => sub {my %d=@_; return split ' ', $d{tags}; },
+                     archive => $archive,
+                    );
   if (defined $param{first}) {
        %count = map {
            if (/^\Q$param{first}\E/) {
@@ -194,7 +205,7 @@ if ($indexon eq "pkg") {
     $sortkey{$keyword} = lc $keyword;
     $htmldescrip{$keyword} = sprintf('<a href="%s">%s</a>',
                                tagurl($keyword),
-                               htmlsanit($keyword));
+                               html_escape($keyword));
   }
 }
 
@@ -221,11 +232,12 @@ print "Content-Type: text/html\n\n";
 
 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
 print "<HTML><HEAD>\n" . 
-    "<TITLE>$debbugs::gProject$Archived $debbugs::gBug reports by $tag</TITLE>\n" .
+    "<TITLE>$gProject$Archived $gBug reports by $tag</TITLE>\n" .
+    qq(<LINK REL="stylesheet" HREF="$gWebHostBugDir/css/bugs.css" TYPE="text/css">) .
     "</HEAD>\n" .
     '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
     "\n";
-print "<H1>" . "$debbugs::gProject$Archived $debbugs::gBug report logs by $tag" .
+print "<H1>" . "$gProject$Archived $gBug report logs by $tag" .
       "</H1>\n";
 
 print $note;
@@ -254,6 +266,8 @@ else {
 print $result;
 
 print "<hr>\n";
-print "<p>$tail_html";
-
+print fill_in_template(template=>'html/html_tail',
+                       hole_var => {'&strftime' => \&POSIX::strftime,
+                                   },
+                      );
 print "</body></html>\n";