work on output formatting
[pspp] / results2html
index 8f8725f82f3067c85358951d6fb711bb138af7a7..abc520d3db5033cad7701e7725f29a09c7113adf 100755 (executable)
@@ -6,17 +6,8 @@ use warnings;
 use HTML::Entities;
 
 open (LOG, '<', "LOG");
-open (INDEX, '>','index.html');
 open (LOG_HTML, '>', "log.html");
 
-print INDEX <<EOF;
-<html>
-<head>
-  <link rel="stylesheet" href="build.css">
-</head>
-<body>
-EOF
-
 print LOG_HTML <<EOF;
 <html>
 <head>
@@ -39,22 +30,12 @@ sub read_vars {
     }
     return %vars;
 }
-
 my (%vars) = read_vars ('VARS');
-print INDEX "<h2>Build Properties</h2>\n";
-print INDEX "<table>\n";
-print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
-foreach my $key (sort (keys (%vars))) {
-    print INDEX "<tr>";
-    print INDEX "<td>", encode_entities ($key), "</td>";
-    print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
-    print INDEX "</tr>\n";
-}
-print INDEX "</table>\n";
 
 my (@products);
 my (@steps);
 my ($new_page) = 0;
+my ($result) = "failure";
 while (<LOG>) {
     my $ln = $.;
     chomp;
@@ -69,11 +50,12 @@ while (<LOG>) {
     if ($new_page) {
        $new_page = 0;
        $log_class = "step";
-       if (my ($product) = /^Saving (.*)$/) {
+       if (my ($name, $product) = /^Saving(?:([^:]*):)?\s+(.*)$/) {
            my $href = "$product/index.html";
            $href = $product if ! -e $href;
 
            my (%p);
+           $p{NAME} = $name if defined ($name);
            $p{PRODUCT} = $product;
            $p{HREF} = $href;
            $p{LN} = $ln;
@@ -85,10 +67,11 @@ while (<LOG>) {
            $s{LN} = $ln;
            push (@steps, \%s);
        }
+       $result = 'success' if $_ eq 'Success';
     } else {
-       if (my ($diagnostic) = /(error|warning):/) {
+       if (my ($diagnostic) = /(error|warning):/i) {
            my (%d);
-           $d{DIAGNOSTIC} = $diagnostic;
+           $d{DIAGNOSTIC} = lc ($diagnostic);
            $d{MESSAGE} = $_;
            $d{LN} = $ln;
            push (@{$steps[$#steps]{CHILDREN}}, \%d);
@@ -104,10 +87,35 @@ while (<LOG>) {
     }
 }
 
+open (INDEX, '>','index.html');
+
+print INDEX <<EOF;
+<html>
+<head>
+  <link rel="stylesheet" href="build.css">
+</head>
+<body>
+EOF
+
+print INDEX "<h1>Build ", $vars{"build_number"}, ": $result</h1>\n";
+
+print INDEX "<h2>Build Properties</h2>\n";
+print INDEX "<table>\n";
+print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
+foreach my $key (sort (keys (%vars))) {
+    print INDEX "<tr>";
+    print INDEX "<td>", encode_entities ($key), "</td>";
+    print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
+    print INDEX "</tr>\n";
+}
+print INDEX "</table>\n";
+
 print INDEX "<h2>Build Products</h2>\n";
 print INDEX "<ul>\n";
 foreach my $p (@products) {
-    print INDEX "<li><a href=\"", encode_entities ($p->{HREF}), "\">";
+    print INDEX "<li>";
+    print INDEX encode_entities ($p->{NAME}), ": " if defined ($p->{NAME});
+    print INDEX "<a href=\"", encode_entities ($p->{HREF}), "\">";
     print INDEX encode_entities ($p->{PRODUCT});
     print INDEX "</a></li>\n";
 }
@@ -132,7 +140,9 @@ foreach my $s (@steps) {
        } else {
            print INDEX "<p>&rarr; <a href=\"", encode_entities ($c->{HREF}), "\">";
            print INDEX encode_entities ($c->{PRODUCT});
-           print INDEX "</a></p>\n";
+           print INDEX "</a> ";
+           print INDEX log_link ($c->{LN});
+           print INDEX "</p>\n";
        }
     }
     print INDEX "</li>\n";