X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fpkgindex.cgi;h=8adbfb86c18714eba413c515d1dd387b2acad717;hb=969cae121449f73db709ed09894c7ca985833a21;hp=a2c73e501cd3a440404f4de4c076ca671338aef1;hpb=30477d1013d3a142bfcca88a2000d5d59846b89b;p=debbugs.git diff --git a/cgi/pkgindex.cgi b/cgi/pkgindex.cgi index a2c73e5..8adbfb8 100755 --- a/cgi/pkgindex.cgi +++ b/cgi/pkgindex.cgi @@ -1,55 +1,66 @@ #!/usr/bin/perl -wT -package debbugs; - +use warnings; use strict; -use POSIX qw(strftime tzset nice); - -#require '/usr/lib/debbugs/errorlib'; -require './common.pl'; +use POSIX qw(strftime nice); -require '/etc/debbugs/config'; -require '/etc/debbugs/text'; +use Debbugs::Config; +use CGI::Simple; +use Debbugs::CGI qw(:util :url :html); +use Debbugs::Common qw(getmaintainers); +use Debbugs::Bugs qw(count_bugs); +use Debbugs::Status qw(:status); nice(5); -my %param = readparse(); +my $q = new CGI::Simple; +my %param = cgi_parameters(query => $q, + single => [qw(indexon repeatmerged archive sortby), + qw(skip max_results first), + ], + default => {indexon => 'pkg', + repeatmerged => 'yes', + archive => 'no', + sortby => 'alpha', + skip => 0, + max_results => 100, + }, + ); + +if (defined $param{first}) { + # rip out all non-words from first + $param{first} =~ s/\W//g; +} +if (defined $param{next}) { + $param{skip}+=$param{max_results}; +} +elsif (defined $param{prev}) { + $param{skip}-=$param{max_results}; + $param{skip} = 0 if $param{skip} < 0; +} -my $indexon = $param{'indexon'} || 'pkg'; -if ($indexon !~ m/^(pkg|src|maint|submitter)$/) { +my $indexon = $param{indexon}; +if ($param{indexon} !~ m/^(pkg|src|maint|submitter|tag)$/) { quitcgi("You have to choose something to index on"); } -my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes"; -my $archive = ($param{'archive'} || "no") eq "yes"; -my $sortby = $param{'sortby'} || 'alpha'; +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"); } -#my $include = $param{'include'} || ""; -#my $exclude = $param{'exclude'} || ""; - my $Archived = $archive ? " Archived" : ""; my %maintainers = %{&getmaintainers()}; my %strings = (); -$ENV{"TZ"} = 'UTC'; -tzset(); - -my $dtime = strftime "%a, %e %b %Y %T UTC", localtime; -my $tail_html = $debbugs::gHTMLTail; -$tail_html = $debbugs::gHTMLTail; +my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime; +my $tail_html = '';#$gHTMLTail; +$tail_html = '';#$gHTMLTail; $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/; -set_option("repeatmerged", $repeatmerged); -set_option("archive", $archive); -#set_option("include", { map {($_,1)} (split /[\s,]+/, $include) }) -# if ($include); -#set_option("exclude", { map {($_,1)} (split /[\s,]+/, $exclude) }) -# if ($exclude); - my %count; my $tag; my $note; @@ -57,22 +68,42 @@ 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"})}); + if (defined $param{first}) { + %count = map { + if (/^\Q$param{first}\E/) { + ($_,$count{$_}); + } + else { + (); + } + } keys %count; + } $note = "

Note that with multi-binary packages there may be other\n"; $note .= "reports filed under the different binary package names.

\n"; foreach my $pkg (keys %count) { $sortkey{$pkg} = lc $pkg; $htmldescrip{$pkg} = sprintf('%s (%s)', - pkgurl($pkg), - htmlsanit($pkg), - htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: ' + pkg_url(pkg => $pkg), + html_escape($pkg), + htmlize_maintlinks(sub { $_[0] == 1 ? 'maintainer: ' : 'maintainers: ' }, $maintainers{$pkg})); } } elsif ($indexon eq "src") { $tag = "source package"; my $pkgsrc = getpkgsrc(); - %count = countbugs(sub {my %d=@_; + if (defined $param{first}) { + %count = map { + if (/^\Q$param{first}\E/) { + ($_,$count{$_}); + } + else { + (); + } + } keys %count; + } + %count = countbugs(function => sub {my %d=@_; return map { $pkgsrc->{$_} || $_ } splitpackages($d{"pkg"}); @@ -82,15 +113,15 @@ if ($indexon eq "pkg") { $sortkey{$src} = lc $src; $htmldescrip{$src} = sprintf('%s (%s)', srcurl($src), - htmlsanit($src), - htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: ' + 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) { @@ -100,30 +131,73 @@ if ($indexon eq "pkg") { map { $_->address } @me; } splitpackages($d{"pkg"}); }); + if (defined $param{first}) { + %count = map { + if (/^\Q$param{first}\E/) { + ($_,$count{$_}); + } + else { + (); + } + } keys %count; + } $note = "

Note that maintainers may use different Maintainer fields for\n"; $note .= "different packages, so there may be other reports filed under\n"; $note .= "different addresses.

\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=@_; my $f = $d{"submitter"} || ""; - my $em = emailfromrfc822($f); - $fullname{$em} = $f if (!defined $fullname{$em}); - return $em; - }); + %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; + }); + if (defined $param{first}) { + %count = map { + if (/^\Q$param{first}\E/) { + ($_,$count{$_}); + } + else { + (); + } + } keys %count; + } foreach my $sub (keys %count) { $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 = count_bugs(function => sub {my %d=@_; return split ' ', $d{tags}; }); + if (defined $param{first}) { + %count = map { + if (/^\Q$param{first}\E/) { + ($_,$count{$_}); + } + else { + (); + } + } keys %count; + } + $note = ""; + foreach my $keyword (keys %count) { + $sortkey{$keyword} = lc $keyword; + $htmldescrip{$keyword} = sprintf('%s', + tagurl($keyword), + html_escape($keyword)); + } } my $result = "