]> xenbits.xensource.com Git - people/aperard/emesinae.git/commitdiff
bug.pl: retrieve a bug as an mbox
authorIan Campbell <ian.campbell@citrix.com>
Mon, 1 Jul 2013 10:01:05 +0000 (11:01 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 1 Jul 2013 10:02:11 +0000 (11:02 +0100)
CGI/bug.pl
CGI/common.pl
TODO
css/style.css

index 426cb8609765bd01e556b8b890121e130f1b04d1..feffd49682d5ef084d3507672030d296b41c56f0 100755 (executable)
@@ -40,12 +40,42 @@ sub fourohfour()
     exit(0);
 }
 
-my $bugid = url(-relative=>1);
-fourohfour() unless $bugid =~ m/[0-9]+/;
+# Parse path to determine bug number and (optional) mode:
+
+my $path = url(-absolute=>1);
+
+$path =~ m,^$c{CGIPath}bug/([0-9]+)(?:/(mbox))?/?$, or fourohfour();
+
+my $bugid = $1;
+my $mode = "normal";
+$mode = $2 if $2;
 
 my $bug = Emesinae::Bug->new( $dbh, ID => $bugid );
 fourohfour() unless $bug;
 
+if ( $mode eq "mbox" ) {
+    print header( -type => 'application/mbox', -charset => 'utf-8',);
+
+    foreach my $m ( sort msgcmp $bug->messages ) {
+        eval {
+            my $fh;
+
+            # Could forge a placeholder for messages which aren't present here.
+
+            $fh = $m->headers;
+            print for (<$fh>);
+
+            print "\n";
+
+            $fh = $m->body;
+            print for (<$fh>);
+        };
+        # Ignore errors...
+    }
+
+    exit(0);
+}
+
 print header( -charset => 'utf-8', );
 print start_html(
     -title => $c{TrackerName} . ": #$bugid - " . htmlsanit( $bug->{title} ),
@@ -75,6 +105,13 @@ print div(
     )
 );
 
+print p(
+       { -class => "bugcontrol" },
+       "[ "
+         . buglink($bug, "Retrieve as mbox", "/mbox")
+         . " ]"
+   ) . "\n";
+
 print hr;
 
 print "\n\n";
index 068fa34c84be75ce369e94be238f17b380c4db1c..0698b20ce9a0690e2af5c33fac8037d299f6f86e 100644 (file)
@@ -6,7 +6,9 @@ sub cgipath {
 sub buglink {
     my $b   = shift;
     my $t   = shift or $b->{title};
-    my $url = cgipath( "bug/" . $b->{id} );
+    my $p   = shift or ""; # Optional subpath
+
+    my $url = cgipath( "bug/" . $b->{id} . $p );
     return a( { href => $url }, $t );
 }
 
diff --git a/TODO b/TODO
index 0732de2d4427f6d121f03d9c1982f1162accbcdc..f9c4b548f275fa5abbf643fd6b80c78783b95b32 100644 (file)
--- a/TODO
+++ b/TODO
@@ -19,7 +19,6 @@ bugs:
 
 bug.pl:
  - offer link to followup to a bug, but not reply to a specific message.
- - retrieve bug as an mbox
 
 bugs.pl:
  - summary of the status of the bugs
index ca5c6dbd8cd5714c32466feadbf20cc08d31a708..91946f222af1ede4d40b5b2c8ff0484af7675166 100644 (file)
@@ -10,6 +10,12 @@ p.msgcontrol {
     color: #686868;
 }
 
+p.bugcontrol {
+    font-family: sans-serif;
+    font-size: 60%;
+    color: #686868;
+}
+
 pre.headers {
     font-family: sans-serif;
     font-size: 95%;