From: Ian Campbell Date: Sun, 18 Nov 2012 16:44:14 +0000 (+0000) Subject: Add a reply mailto link X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e0e644b3db59f29b48d97cf08059dc808f08c08d;p=people%2Faperard%2Femesinae.git Add a reply mailto link --- diff --git a/CGI/bug.pl b/CGI/bug.pl index 681cb3f..65606fd 100755 --- a/CGI/bug.pl +++ b/CGI/bug.pl @@ -8,6 +8,8 @@ use POSIX qw/strftime/; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); +use URI::Escape; + use Bugs::Bug; use Bugs::Common; @@ -80,6 +82,36 @@ sub archive_list { return @archives; } +sub resubject { + my $m = shift; + my $s = $m->{subject}->text; + $s = "Re: $s" unless $s =~ m/^Re: /; + return "$s"; +} +sub reply_link { + my $m = shift; + my $p = $m->{present}; + + my %hdrs = ( + "In-Reply-To" => $m->{msgid}, + ); + + my $to = join(",",$m->{from}->addresses); + + my @cc; + push @cc, $m->{to}->addresses if $p; + push @cc, $m->{cc}->addresses if $p; + + $hdrs{cc} = join(",",@cc) if @cc; + + $hdrs{subject} = + $p ? resubject($m) + : "Re: Bug ".$bug->{id}.": " . $bug->{title}; + + my $args = join("&", map { $_."=".uri_escape($hdrs{$_}) } keys %hdrs); + return a({href=>"mailto:${to}?$args"}, "Reply to this message"); +} + foreach my $m ( sort msgcmp $bug->messages ) { print comment("Message ".$m->{id}.": ". $m->{msgid}) . "\n"; @@ -91,8 +123,6 @@ foreach my $m ( sort msgcmp $bug->messages ) { @body = ( "Message not present in archive" ); } my @archives = archive_list($m->{msgid}); - print p({-class=>"banner"}, - "[ Archives: " . join(", ", @archives) . " ]") . "\n"; print pre({-class=>"headers"}, join("\n", grep { $_ } (hdr("From", $m->{from}->stringify), hdr("To", $m->{to}->stringify), @@ -100,10 +130,16 @@ foreach my $m ( sort msgcmp $bug->messages ) { hdr("Subject", $m->{subject}->stringify), hdr("Date", $m->{date}->stringify), hdr("Message-ID", $m->{msgid}) - ))) . "\n"; + )) + ) . "\n"; print pre({-class=>"body"}, htmlsanit(join("\n",@body)) ) . "\n"; + print p({-class=>"msgfooter"}, + "[ ".reply_link($m)."; ". + "Archives: " . join(", ", @archives) . + " ]" + ) . "\n"; print hr . "\n"; } diff --git a/css/style.css b/css/style.css index 1dddd1c..4a35f08 100644 --- a/css/style.css +++ b/css/style.css @@ -1,6 +1,6 @@ -p.banner { +p.msgfooter { font-family: sans-serif; - font-size: 90%; + font-size: 60%; color: #686868; }