From a1a4459e491ba029e8411cd753b74d7036fc20a7 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Mon, 15 Dec 2025 14:51:10 +0200 Subject: [PATCH] appview/pages: render a placeholder avatar when there's no did Change-Id: ptqmznvuxylzrkuozxvtsqoskoqrruww Signed-off-by: Anirudh Oppiliappan --- appview/pages/funcmap.go | 16 ++++++++++++++++ appview/pages/templates/repo/commit.html | 5 ++++- appview/pages/templates/repo/index.html | 8 ++++++-- appview/pages/templates/repo/log.html | 6 +++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go index 602d6247..a995d47c 100644 --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -360,6 +360,22 @@ func (p *Pages) funcMap() template.FuncMap { "fullAvatar": func(handle string) string { return p.AvatarUrl(handle, "") }, + "placeholderAvatar": func(size string) template.HTML { + sizeClass := "size-6" + iconSize := "size-4" + if size == "tiny" { + sizeClass = "size-6" + iconSize = "size-4" + } else if size == "small" { + sizeClass = "size-8" + iconSize = "size-5" + } else { + sizeClass = "size-12" + iconSize = "size-8" + } + icon, _ := p.icon("user-round", []string{iconSize, "text-gray-400", "dark:text-gray-500"}) + return template.HTML(fmt.Sprintf(`
%s
`, sizeClass, icon)) + }, "profileAvatarUrl": func(profile *models.Profile, size string) string { return p.ProfileAvatarUrl(profile, size) }, diff --git a/appview/pages/templates/repo/commit.html b/appview/pages/templates/repo/commit.html index 0fe7d92a..f297ad0a 100644 --- a/appview/pages/templates/repo/commit.html +++ b/appview/pages/templates/repo/commit.html @@ -100,7 +100,10 @@ {{ if $did }} {{ template "user/fragments/picHandleLink" $did }} {{ else }} - {{ $name }} + + {{ placeholderAvatar "tiny" }} + {{ $name }} + {{ end }} {{ end }} diff --git a/appview/pages/templates/repo/index.html b/appview/pages/templates/repo/index.html index abb27b78..99264535 100644 --- a/appview/pages/templates/repo/index.html +++ b/appview/pages/templates/repo/index.html @@ -259,7 +259,7 @@ {{ define "attribution" }} {{ $commit := index . 0 }} {{ $map := index . 1 }} - + {{ $author := index $map $commit.Author.Email }} {{ $coauthors := $commit.CoAuthors }} {{ $all := list }} @@ -274,7 +274,11 @@ {{ end }} {{ end }} - {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} + {{ if $author }} + {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} + {{ else }} + {{ placeholderAvatar "tiny" }} + {{ end }} {{ if $author }}{{ resolve $author }}{{ else }}{{ $commit.Author.Name }}{{ end }} diff --git a/appview/pages/templates/repo/log.html b/appview/pages/templates/repo/log.html index a1cb4167..37473b46 100644 --- a/appview/pages/templates/repo/log.html +++ b/appview/pages/templates/repo/log.html @@ -186,7 +186,11 @@ {{ end }} {{ end }} - {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} + {{ if $author }} + {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} + {{ else }} + {{ placeholderAvatar "tiny" }} + {{ end }} {{ if $author }}{{ resolve $author }}{{ else }}{{ $commit.Author.Name }}{{ end }} -- 2.43.0