X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fpkgindex.cgi;h=a43428a6cd7f6362433a1c3ace25a6b2b04b3b07;hb=235a779bdb026b6357e95053e1d7faaab87e8931;hp=c667aacab0e2d11905e2a9cd81b45f28347479ff;hpb=c6d8b358aee776d0b4d7ced29f086d7e32c2b21a;p=debbugs.git diff --git a/cgi/pkgindex.cgi b/cgi/pkgindex.cgi index c667aac..a43428a 100755 --- a/cgi/pkgindex.cgi +++ b/cgi/pkgindex.cgi @@ -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); @@ -39,14 +43,14 @@ elsif (defined $param{prev}) { my $indexon = $param{indexon}; if ($param{indexon} !~ m/^(pkg|src|maint|submitter|tag)$/) { - quitcgi("You have to choose something to index on"); + quitcgi("You have to choose something to index on", '400 Bad Request'); } my $repeatmerged = $param{repeatmerged} eq 'yes'; my $archive = $param{archive} eq "yes"; my $sortby = $param{sortby}; if ($sortby !~ m/^(alpha|count)$/) { - quitcgi("Don't know how to sort like that"); + quitcgi("Don't know how to sort like that", '400 Bad Request'); } my $Archived = $archive ? " Archived" : ""; @@ -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,11 +85,9 @@ if ($indexon eq "pkg") { foreach my $pkg (keys %count) { $sortkey{$pkg} = lc $pkg; $htmldescrip{$pkg} = sprintf('%s (%s)', - pkgurl($pkg), - htmlsanit($pkg), - htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: ' - : 'maintainers: ' }, - $maintainers{$pkg})); + package_links(package => $pkg, links_only=>1), + html_escape($pkg), + package_links(maint=>$maintainers{$pkg}//[''])); } } elsif ($indexon eq "src") { $tag = "source package"; @@ -101,25 +102,25 @@ 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('%s (%s)', - srcurl($src), - htmlsanit($src), - htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: ' - : 'maintainers: ' }, - $maintainers{$src})); + package_links(src => $src, links_only=>1), + html_escape($src), + package_links(maint => $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 +129,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 +147,21 @@ if ($indexon eq "pkg") { $note .= "different addresses.

\n"; foreach my $maint (keys %count) { $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)"; - $htmldescrip{$maint} = htmlmaintlinks('', $email2maint{$maint}); + $htmldescrip{$maint} = package_links(maint => $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 +176,16 @@ if ($indexon eq "pkg") { $sortkey{$sub} = lc $fullname{$sub}; $htmldescrip{$sub} = sprintf('%s', submitterurl($sub), - htmlsanit($fullname{$sub})); + html_escape($fullname{$sub})); } $note = "

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.

\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 +201,7 @@ if ($indexon eq "pkg") { $sortkey{$keyword} = lc $keyword; $htmldescrip{$keyword} = sprintf('%s', tagurl($keyword), - htmlsanit($keyword)); + html_escape($keyword)); } } @@ -219,41 +226,16 @@ $result .= "\n"; print "Content-Type: text/html\n\n"; -print "\n"; -print "\n" . - "$debbugs::gProject$Archived $debbugs::gBug reports by $tag\n" . - "\n" . - '' . - "\n"; -print "

" . "$debbugs::gProject$Archived $debbugs::gBug report logs by $tag" . - "

\n"; +print fill_in_template(template=>'cgi/pkgindex.tmpl', + variables => {count => \%count, + param => \%param, + result => $result, + html_escape => \&Debbugs::CGI::html_escape, + archived => $Archived, + note => $note, + tag => $tag, + }, + hole_var => {'&strftime' => \&POSIX::strftime, + }, + ); -print $note; -print < - - - - - - -END -if (defined $param{first}) { - print qq(\n); -} -else { - print q(

); - if ($param{skip} > 0) { - print q(); - } - if (keys %count > ($param{skip} + $param{max_results})) { - print q(); - } - print qq(

\n); -} -print $result; - -print "
\n"; -print "

$tail_html"; - -print "\n";