chiark / gitweb /
Some stylistic fixups; get rid of warning when processing pre-publish-rejection log...
[modbot-mtm.git] / xlog / bin / report
index ee3022ea17cfaa444fb3be9e198cae58e01f83ab..d25071787b7f4be2d53ff78865d6518fb05e5973 100755 (executable)
@@ -1,15 +1,16 @@
 #!/usr/bin/perl -w
 
-our ($ng,@ARGV) = @ARGV;
+our ($ng,$staticfiles,@ARGV) = @ARGV;
 chdir $ng or die $!;
 
 use strict (qw(vars));
 use IO::Handle;
 use POSIX;
-use CGI qw/:standard *table end_*/;
+use CGI qw/:standard *table end_* -no_xhtml/;
 
 our @lines= ();
 our @s;
+our $oddeven = "o";
 
 our ($processline,$needmap);
 our ($selectmid,$selectnum);
@@ -20,8 +21,10 @@ sub processlog ($$) {
     while (<F>) {
        chomp;
        @s= split /\t/;
+       push @s, '' if @s<=6;
         $s[0]= strftime "%Y-%m-%d %H:%M:%S %Z", localtime $s[0];
        &$processline();
+       $oddeven =~ y/oe/eo/;
     }
 }
 sub processlogs ($) {
@@ -34,7 +37,9 @@ sub processlogs ($) {
 sub processline_print () {
     my @sp= @s;
     $sp[3] =~ s/\@\w{0,2}/ at .. /;
-    my @sp= map { escapeHTML($_) } @sp;
+    @sp= map { escapeHTML($_) } @sp[0..5];
+    $sp[3] =~ s/&lt;/\<br>&lt;/;
+    $sp[2]=~s/\@/\@<span class='hole'><\/span>/;
     my @spu= map {
        s/\W/ sprintf "%%%02x", ord $& /ge;
        $_;
@@ -42,11 +47,16 @@ sub processline_print () {
     if (length $s[1] && length $s[2]) {
        my $url= url().'/message/'.$spu[1].'/'.$spu[2];
        foreach my $i (qw(1 2)) {
-           $sp[$i]= a({ href=>$url }, $sp[$i] );
+           $sp[$i]= a({ href=>$url }, $sp[$i]."<br>" );
        }
     }
-#print STDERR join('|',@sp),"\n";
-    print Tr(td([@sp]));
+    if (length $s[6]) {
+       $sp[5]= a({ href=>"$staticfiles/nr-$s[6].txt" }, $sp[5] );
+    }
+
+    print "<tr class='$oddeven'><td>$sp[0]</td>";
+    print "<td class='ref'>$sp[1] $sp[2]</td>";
+    print td([@sp[3..5]]),"</tr>\n";
 }
 
 sub processline_print_ifsingle () {
@@ -87,7 +97,7 @@ if ($pi =~ m,^/message/(\d+)/(.*)$,) {
     $title= "Single message ".escapeHTML($selectmid);
     $processline= \&processline_print_ifsingle;
 } elsif ($pi =~ m/^$/) {
-    $title= "Recent activity";
+    $title= "Recent activity - $ng";
 } elsif ($pi =~ m,^/queue,) {
     $title= "Activity regarding still-queued messages";
     $processline= \&processline_queue_prescan;
@@ -95,12 +105,19 @@ if ($pi =~ m,^/message/(\d+)/(.*)$,) {
     $processline= \&processline_queue;
 }
 
-print header(), start_html($title), h1($title), table();
+my $css=<<EOJ;
+span.hole:before { content: " "; }
+td.ref { font-size: 0.75em; }
+tr.o { background: #ddddff; }
+EOJ
+
+print header(),
+  start_html(-title=>$title, -style=>{'-code'=>$css}),
+  h1($title), start_table();
 
 print Tr(td([map { strong($_) } (qw(
                                Date
-                               Reference
-                               Message-ID
+                               Reference/Message-ID
                                From
                                Subject
                                Event