From 46971571d17ef3e0cdfbadb8e0d3e4d074c12604 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Fri, 12 Dec 2025 11:28:28 +0200 Subject: [PATCH] appview/pages: upload and render avatar Signed-off-by: Anirudh Oppiliappan --- appview/pages/funcmap.go | 22 +++++++ .../pages/templates/layouts/profilebase.html | 2 +- .../templates/user/fragments/editAvatar.html | 44 +++++++++++++ .../templates/user/fragments/profileCard.html | 61 ++++++++++++------- .../pages/templates/user/settings/emails.html | 6 +- .../pages/templates/user/settings/keys.html | 6 +- 6 files changed, 114 insertions(+), 27 deletions(-) create mode 100644 appview/pages/templates/user/fragments/editAvatar.html diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go index 87149d1c..c3ea8e65 100644 --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -384,6 +384,28 @@ 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 { + if profile != nil { + return p.AvatarUrl(profile.Did, size) + } + return "" + }, "langColor": enry.GetColor, "reverse": func(s any) any { if s == nil { diff --git a/appview/pages/templates/layouts/profilebase.html b/appview/pages/templates/layouts/profilebase.html index 0747a39f..7aeb4937 100644 --- a/appview/pages/templates/layouts/profilebase.html +++ b/appview/pages/templates/layouts/profilebase.html @@ -2,7 +2,7 @@ {{ define "extrameta" }} {{ $handle := resolve .Card.UserDid }} - {{ $avatarUrl := fullAvatar $handle }} + {{ $avatarUrl := profileAvatarUrl .Card.Profile "" }} diff --git a/appview/pages/templates/user/fragments/editAvatar.html b/appview/pages/templates/user/fragments/editAvatar.html new file mode 100644 index 00000000..9aa63e1a --- /dev/null +++ b/appview/pages/templates/user/fragments/editAvatar.html @@ -0,0 +1,44 @@ +{{ define "user/fragments/editAvatar" }} +
+ +

Select an image (PNG or JPEG, max 1MB)

+ +
+
+ + +
+
+{{ end }} diff --git a/appview/pages/templates/user/fragments/profileCard.html b/appview/pages/templates/user/fragments/profileCard.html index 6c5d7925..c9b5e147 100644 --- a/appview/pages/templates/user/fragments/profileCard.html +++ b/appview/pages/templates/user/fragments/profileCard.html @@ -3,9 +3,24 @@
- + + {{ if eq .FollowStatus.String "IsSelf" }} + + {{ end }}
+
+ {{ template "user/fragments/editAvatar" . }} +

{{ with .Profile }} - {{ if .Pronouns }} -

{{ .Pronouns }}

- {{ end }} + {{ if .Pronouns }} +

{{ .Pronouns }}

+ {{ end }} {{ end }}
@@ -29,7 +44,7 @@ {{ with .Profile }} {{ if .Description }} -

{{ .Description }}

+

{{ .Description }}

{{ end }}