diff --git a/activity.go b/activity.go index 8169100..fa49ca9 100644 --- a/activity.go +++ b/activity.go @@ -1470,7 +1470,11 @@ func junkuser(user *WhatAbout) junk.Junk { if ava := user.Options.Avatar; ava != "" { a["url"] = ava } else { - a["url"] = fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL)) + u := fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL)) + if user.Options.Avahex { + u += "&hex=1" + } + a["url"] = u } j["icon"] = a } else { diff --git a/avatar.go b/avatar.go index 4294f50..bfba151 100644 --- a/avatar.go +++ b/avatar.go @@ -66,7 +66,7 @@ func loadAvatarColors() { } } -func genAvatar(name string) []byte { +func genAvatar(name string, hex bool) []byte { h := sha512.New() h.Write([]byte(name)) s := h.Sum(nil) @@ -74,6 +74,27 @@ func genAvatar(name string) []byte { for i := 0; i < 64; i++ { for j := 0; j < 64; j++ { p := i*img.Stride + j*4 + if hex { + tan := 0.577 + if i < 32 { + if j < 17-int(float64(i)*tan) || j > 46+int(float64(i)*tan) { + img.Pix[p+0] = 0 + img.Pix[p+1] = 0 + img.Pix[p+2] = 0 + img.Pix[p+3] = 255 + continue + } + } else { + if j < 17-int(float64(64-i)*tan) || j > 46+int(float64(64-i)*tan) { + img.Pix[p+0] = 0 + img.Pix[p+1] = 0 + img.Pix[p+2] = 0 + img.Pix[p+3] = 255 + continue + + } + } + } xx := i/16*16 + j/16 x := s[xx] if x < 64 { diff --git a/honk.go b/honk.go index e5c6cb6..929be9b 100644 --- a/honk.go +++ b/honk.go @@ -51,10 +51,11 @@ type WhatAbout struct { type UserOptions struct { SkinnyCSS bool `json:",omitempty"` OmitImages bool `json:",omitempty"` + Avahex bool `json:",omitempty"` + MentionAll bool `json:",omitempty"` Avatar string `json:",omitempty"` MapLink string `json:",omitempty"` Reaction string `json:",omitempty"` - MentionAll bool Chats int } diff --git a/unveil.go b/unveil.go index efdba9b..f545459 100644 --- a/unveil.go +++ b/unveil.go @@ -1,3 +1,4 @@ +//go:build openbsd // +build openbsd // diff --git a/views/account.html b/views/account.html index 9aa53ce..523edca 100644 --- a/views/account.html +++ b/views/account.html @@ -10,6 +10,8 @@

+

+

diff --git a/web.go b/web.go index 72579b1..f583b4f 100644 --- a/web.go +++ b/web.go @@ -1107,6 +1107,11 @@ func saveuser(w http.ResponseWriter, r *http.Request) { } else { options.SkinnyCSS = false } + if r.FormValue("avahex") == "avahex" { + options.Avahex = true + } else { + options.Avahex = false + } if r.FormValue("omitimages") == "omitimages" { options.OmitImages = true } else { @@ -2104,7 +2109,8 @@ func avatate(w http.ResponseWriter, r *http.Request) { loadAvatarColors() } n := r.FormValue("a") - a := genAvatar(n) + hex := r.FormValue("hex") == "1" + a := genAvatar(n, hex) if !debugMode { w.Header().Set("Cache-Control", "max-age="+somedays()) }