Browse Source

Add gravatar icon

Alexey Edelev 5 years ago
parent
commit
1653f3f4ac
2 changed files with 11 additions and 5 deletions
  1. 10 4
      web/mailbox.go
  2. 1 1
      web/templates/statusline.html

+ 10 - 4
web/mailbox.go

@@ -26,12 +26,15 @@
 package web
 
 import (
+	"crypto/md5"
+	"encoding/hex"
 	"encoding/json"
 	"fmt"
 	template "html/template"
 	"log"
 	"net/http"
 	"strconv"
+	"strings"
 
 	common "git.semlanik.org/semlanik/gostfix/common"
 )
@@ -172,12 +175,15 @@ func (s *Server) handleStatusLine(w http.ResponseWriter, user, email string) {
 		return
 	}
 
+	emailHash := md5.Sum([]byte(strings.Trim(email, "\t ")))
 	fmt.Fprint(w, s.templater.ExecuteStatusLine(&struct {
-		Name  string
-		Email string
+		Name      string
+		Email     string
+		EmailHash string
 	}{
-		Name:  info.FullName,
-		Email: email,
+		Name:      info.FullName,
+		Email:     email,
+		EmailHash: hex.EncodeToString(emailHash[:]),
 	}))
 }
 

+ 1 - 1
web/templates/statusline.html

@@ -1 +1 @@
-Welcome {{.Name}} {{.Email}}
+<img src="https://www.gravatar.com/avatar/{{.EmailHash}}?s=70&d=monsterid" style="border-radius: 100%; border-color: var(--primary-color); border-width: 2pt; border-style: solid;"> {{.Name}} {{.Email}}