use IO::Scalar;
use Params::Validate qw(validate_with :types);
+use Digest::MD5 qw(md5_hex);
+use Debbugs::Mail qw(get_addresses);
use Debbugs::MIME qw(decode_rfc1522 create_mime_message);
use Debbugs::CGI qw(:url :html :util);
use Debbugs::Common qw(globify_scalar english_join);
not $param{terse} and
not exists $param{att}) {
my $header = $entity->head;
- print {$param{output}} "<pre class=\"headers\">\n";
+ print {$param{output}} "<div class=\"headers\">\n";
if ($param{trim_headers}) {
my @headers;
foreach (qw(From To Cc Subject Date)) {
my $head_field = $head->get($_);
next unless defined $head_field and $head_field ne '';
- push @headers, qq(<b>$_:</b> ) . html_escape(decode_rfc1522($head_field));
+ if ($_ eq 'From') {
+ my $libravatar_url = __libravatar_url(decode_rfc1522($head_field));
+ if (defined $libravatar_url and length $libravatar_url) {
+ push @headers,q(<img src=").$libravatar_url.q(">);
+ }
+ }
+ push @headers, qq(<p><span class="header">$_:</span> ) . html_escape(decode_rfc1522($head_field))."</p>";
}
print {$param{output}} join(qq(), @headers);
} else {
- print {$param{output}} html_escape(decode_rfc1522($entity->head->stringify));
+ print {$param{output}} "<pre>".html_escape(decode_rfc1522($entity->head->stringify))."</pre>\n";
}
- print {$param{output}} "</pre>\n";
+ print {$param{output}} "</div>\n";
}
if (not (($param{outer} and $type =~ m{^text(?:/plain)?(?:;|$)})
}
+sub __libravatar_url {
+ my ($email) = @_;
+ if (not defined $config{libravatar_uri} or not length $config{libravatar_uri}) {
+ return undef;
+ }
+ ($email) = get_addresses($email);
+ return $config{libravatar_uri}.md5_hex(lc($email)).($config{libravatar_uri_options}//'');
+}
+
1;
set_default(\%config,'bug_subscription_domain',$config{list_domain});
+=head2 CGI Options
+
+=over
+
+=item libravatar_uri
+
+URI to a libravatar configuration. If empty or undefined, libravatar
+support will be disabled. Defaults to
+http://cdn.libravatar.org/avatar/ which uses a federated Avatar system
+and falls back to gravatar if necessary.
+
+=cut
+
+set_default(\%config,'libravatar_uri',"http://cdn.libravatar.org/avatar/");
+
+=item libravatar_uri_options
+
+Options to append to the md5_hex of the e-mail. This sets the default
+avatar used when an avatar isn't available. Currently defaults to
+'?d=retro', which causes a bitmap-looking avatar to be displayed for
+unknown e-mails.
+
+Other options which make sense include ?d=404, ?d=wavatar, etc. See
+the API of libravatar for details.
+
+=cut
+
+set_default(\%config,'libravatar_uri_options','?d=retro');
+
+
+=back
+
=head2 Misc Options
=over
(closes: #691573). Thanks to Jonathan Nieder.
* Fix failure to forcibly merge/merge when found/fixed is not qualified
(closes: #670456). Thanks to Jonathan Nieder and Bernhard Schmidt.
+ * Add libravatar support.
[Thanks to Arnout Engelen: ]
* Add Homepage (closes: #670555).