Subject: [PATCH] Show avatars from Libravatar.
From: Felix Lechner <[email-masked]>
To: [email-masked]
Cc: Felix Lechner <[email-masked]>
Date: Fri, 10 May 2024 20:20:08 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Requires guile-avatar from here:

    https://codeberg.org/lechner/guile-avatar

The packaging code for guile-avatar can be added to Guix by accepting
this patch:

    https://debbugs.gnu.org/70870

In Guix, the package should then be mentioned as an "input" to mumi,
together with an updated commit hash or version for mumi.

A live preview of this change is available at:

    https://patchwise.org/38809
---
 mumi/web/view/html.scm | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/mumi/web/view/html.scm b/mumi/web/view/html.scm
index 2275799..bd5caec 100644
--- a/mumi/web/view/html.scm
+++ b/mumi/web/view/html.scm
@@ -19,6 +19,7 @@
 ;;; <http://www.gnu.org/licenses/>.
 
 (define-module (mumi web view html)
+  #:use-module (avatar url)
   #:use-module (email email)
   #:use-module (mumi config)
   #:use-module (mumi debbugs)
@@ -451,12 +452,12 @@ failed to process associated messages.")
          ,(map (match-lambda
                  ((message-number message)
                   `(li
-                    (div
-                     (@ (class "avatar")
-                        (style ,(string-append "background-color:"
-                                               (avatar-color (sender-email message)
-                                                             (map extract-email parties)))))
-                     ,(string-upcase (string-take (sender-name message) 1)))
+                    (img (@ (class "avatar")
+                            (style ,(string-append "background-color:"
+                                                   (avatar-color (sender-email message)
+                                                                 (map extract-email parties))))
+                            (src ,(libravatar-url (sender-email message) #:default "404"))
+                            (alt ,(string-upcase (string-take (sender-name message) 1)))))
                     (span (@ (class "date"))
                           (a (@ (href ,(string-append "#" (number->string
                                                            message-number))))
@@ -621,12 +622,12 @@ currently disabled."))
              (id ,(number->string message-number))))
        (a (@ (class "message-anchor")
              (id ,(format #false "msgid-~a" (msgid-hash (message-id message))))))
-       (div
-        (@ (class "avatar")
-           (style ,(string-append "background-color:"
-                                  (avatar-color (sender-email message)
-                                                (map extract-email parties)))))
-        ,(string-upcase (string-take (sender-name message) 1)))
+       (img (@ (class "avatar")
+               (style ,(string-append "background-color:"
+                                      (avatar-color (sender-email message)
+                                                    (map extract-email parties))))
+               (src ,(libravatar-url (sender-email message) #:default "404"))
+               (alt ,(string-upcase (string-take (sender-name message) 1)))))
        (article
         (@ (class "message"))
         (header

base-commit: 394c90d4a176756b9f0f4a716a2646ab98d8f167
-- 
2.41.0