From e102ac4548e6134dc11748a4157239774e1d5f27 Mon Sep 17 00:00:00 2001 From: Amolith Date: Fri, 17 Oct 2025 19:23:27 -0600 Subject: [PATCH] feat: display git-bug identity avatars in web UI Add avatar display functionality to the bug tracking interface. Integrates with git-bug's AvatarUrl() method to fetch and render identity avatars safely in both bugs list and detail views. - Add AuthorAvatar fields to BugListItem and TimelineItem structs - Fetch avatar URLs using snap.Author.AvatarUrl() in backend - Create responsive avatar CSS styling with fallbacks - Update templates to display avatars before usernames - Implement lazy loading and referrer policies for security Implements: bug-d42c94f Co-Authored-By: Crush --- pkg/web/static/overrides.css | 17 ++++++++++ pkg/web/templates/base.html | 5 +-- pkg/web/templates/bug.html | 10 +++--- pkg/web/templates/bugs.html | 2 +- pkg/web/webui_bugs.go | 62 ++++++++++++++++++++---------------- 5 files changed, 61 insertions(+), 35 deletions(-) diff --git a/pkg/web/static/overrides.css b/pkg/web/static/overrides.css index a0efe238270208029e64b0cd82c8f8150ca84984..706e3d12bb2639c397e59f8653c88149734bb007 100644 --- a/pkg/web/static/overrides.css +++ b/pkg/web/static/overrides.css @@ -184,3 +184,20 @@ article > p:only-child { border: 2px solid color-mix(in srgb, var(--label-color) 40%, var(--pico-card-background-color)); color: var(--pico-color); } + +.avatar { + display: inline-block; + width: 1.5rem; + height: 1.5rem; + border-radius: 50%; + vertical-align: middle; + margin-right: 0.375rem; + object-fit: cover; + background-color: var(--pico-secondary-background); +} + +.avatar-timeline { + width: 2rem; + height: 2rem; + margin-right: 0.5rem; +} diff --git a/pkg/web/templates/base.html b/pkg/web/templates/base.html index edddf1d39b6b8533f23076853ec4184670b232a9..f0016035c474fb9cf7850e6d1147906e61ac4205 100644 --- a/pkg/web/templates/base.html +++ b/pkg/web/templates/base.html @@ -13,10 +13,11 @@ - + - + + {{block "page-styles" .}}{{end}} diff --git a/pkg/web/templates/bug.html b/pkg/web/templates/bug.html index 8928821759c07ad70617db3dcb8d81c6cacfe0e1..1a9d8e4642fffeafcd1c5fdfbdcaafe337621352 100644 --- a/pkg/web/templates/bug.html +++ b/pkg/web/templates/bug.html @@ -35,7 +35,7 @@ {{if eq .Type "create"}}
-

{{.Author}} opened {{if $.Edited}} (edited){{end}}

+

{{if .AuthorAvatar}}{{end}}{{.Author}} opened {{if $.Edited}} (edited){{end}}

{{if .Message}} {{.Message}} @@ -47,7 +47,7 @@ {{else if eq .Type "comment"}}
-

{{.Author}} commented {{if .Edited}} (edited){{end}}

+

{{if .AuthorAvatar}}{{end}}{{.Author}} commented {{if .Edited}} (edited){{end}}

{{if .Message}} {{.Message}} @@ -58,18 +58,18 @@ {{else if eq .Type "title"}}
-

{{.Author}} changed the title to {{.Title}}

+

{{if .AuthorAvatar}}{{end}}{{.Author}} changed the title to {{.Title}}

{{else if eq .Type "status"}}
-

{{.Author}} {{.Status}} the bug

+

{{if .AuthorAvatar}}{{end}}{{.Author}} {{.Status}} the bug

{{else if eq .Type "labels"}}

- {{.Author}} + {{if .AuthorAvatar}}{{end}}{{.Author}} {{if .AddedLabels}} added label{{if gt (len .AddedLabels) 1}}s{{end}} {{range $i, $label := .AddedLabels}}{{if $i}}, {{end}}{{$label}}{{end}} diff --git a/pkg/web/templates/bugs.html b/pkg/web/templates/bugs.html index d4be32be7ba3916ca3876ad86a774b9d2a714695..f185e84420b7411c46c97e694834bfbd02b1beae 100644 --- a/pkg/web/templates/bugs.html +++ b/pkg/web/templates/bugs.html @@ -30,7 +30,7 @@ {{.Title}}