]> git.donarmstrong.com Git - debbugs.git/commitdiff
add libravatar support to the bts
authorDon Armstrong <don@donarmstrong.com>
Thu, 14 Mar 2013 01:12:12 +0000 (18:12 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 14 Mar 2013 01:12:12 +0000 (18:12 -0700)
Debbugs/CGI/Bugreport.pm
html/bugs.css

index 154ee0470fc4b3079fe5726ca303e5657fdff590..56a8b4023ee9983208fe40f916fcc2884ba5b66c 100644 (file)
@@ -32,6 +32,8 @@ use base qw(Exporter);
 
 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(convert_to_utf8 decode_rfc1522 create_mime_message);
 use Debbugs::CGI qw(:url :html :util);
 use Debbugs::Common qw(globify_scalar english_join);
@@ -132,19 +134,22 @@ sub display_entity {
        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') {
+                       push @headers,q(<img src=").__libravatar_url(decode_rfc1522($head_field)).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)?(?:;|$)})
@@ -425,6 +430,12 @@ sub handle_record{
 }
 
 
+sub __libravatar_url {
+    my ($email) = @_;
+    ($email) = get_addresses($email);
+    return "http://cdn.libravatar.org/avatar/".md5_hex(lc($email))."?d=retro";
+}
+
 
 1;
 
index db1d34b1d8c2265accc5320fe5a18d2d0a6254aa..8e324454f30371c2b97b14d0fd6e432c8c076311 100644 (file)
@@ -126,6 +126,29 @@ pre.headers {
     line-height: 120%
 }
 
+div.headers { 
+    border: #a7a7a7 1px solid;
+    background-color: #f0f0f0;
+    padding: 2px;
+ }
+
+div.headers p {
+    font-family: sans-serif;
+    font-size: 95%;
+    color: #3c3c3c;
+    padding: 0px;
+    line-height: 120%;
+    margin: 0px;
+}
+
+div.headers img {  
+    float: right;
+}
+
+span.header { 
+  font-weight: bold
+ };
+
 pre.mime {
     font-family: monospace;
     font-size: 95%;