Show Gravatars for authors in the commit log partial
authorChuck Hagenbuch <chuck@horde.org>
Mon, 6 Dec 2010 03:27:00 +0000 (22:27 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Mon, 6 Dec 2010 03:27:00 +0000 (22:27 -0500)
chora/app/views/_logMessage.html.php
chora/lib/Chora.php
chora/themes/default/screen.css

index a02b2e0..c9be18c 100644 (file)
@@ -33,6 +33,9 @@
  <div class="commit-message"><?php echo Chora::formatLogMessage($logMessage->queryLog()) ?></div>
 
  <div class="commit-author">
+  <div class="commit-author-avatar">
+   <img src="http://www.gravatar.com/avatar/<?php echo md5(strtolower(trim(Chora::getAuthorEmail($logMessage->queryAuthor())))) ?>?d=mm&s=40">
+  </div>
   <?php echo Chora::showAuthorName($logMessage->queryAuthor(), true) ?><br>
   <?php echo Chora::formatDate($logMessage->queryDate()) ?>
  </div>
index 045bdd7..e0b84df 100644 (file)
@@ -442,6 +442,26 @@ class Chora
         return htmlspecialchars($name);
     }
 
+    public function getAuthorEmail($name)
+    {
+        try {
+            $users = $GLOBALS['VC']->getUsers($GLOBALS['conf']['paths']['cvsusers']);
+            if (isset($users[$name])) {
+                return $users[$name]['mail'];
+            }
+        } catch (Horde_Vcs_Exception $e) {}
+
+        try {
+            $parser = new Horde_Mail_Rfc822();
+            $results = $parser->parseAddressList($name);
+            if (count($results)) {
+                return $results[0]->mailbox . '@' . $results[0]->host;
+            }
+        } catch (Horde_Mail_Exception $e) {}
+
+        return $name;
+    }
+
     /**
      * Return formatted date information.
      *
index 23c6cbf..39ea79f 100644 (file)
@@ -179,7 +179,12 @@ h3.file-view-header {
     list-style: none;
     margin-bottom: .5em;
 }
-.commit-author {
+.commit-author-avatar {
+    float: left;
+    margin-right: .5em;
+    padding: 2px;
+    background: #fff;
+    border: 1px solid #ddd;
 }
 
 ul.commit-filelist {