From c823ee5b737a56850658934ac71d2a1af6a04daf Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 29 Jan 2024 04:44:46 +0000 Subject: [PATCH 1/4] fix --- modules/templates/util_avatar.go | 6 ++++++ templates/repo/diff/comments.tmpl | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/templates/util_avatar.go b/modules/templates/util_avatar.go index 462668588a316..e8febd9ce8ec4 100644 --- a/modules/templates/util_avatar.go +++ b/modules/templates/util_avatar.go @@ -79,3 +79,9 @@ func (au *AvatarUtils) AvatarByEmail(email, name string, others ...any) template return "" } + +// AvatarDefault renders default avatars. +func (au *AvatarUtils) AvatarDefault(others ...any) template.HTML { + size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) + return AvatarHTML(avatars.DefaultAvatarLink(), size, class, "") +} diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 1e9af5c4a1f64..3d44120dfa185 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -3,7 +3,7 @@ {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
{{if .OriginalAuthor}} - + {{ctx.AvatarUtils.AvatarDefault}} {{else}} {{template "shared/user/avatarlink" dict "user" .Poster}} {{end}} From eb45970ebde249654232df08bc50ff83f4b37fea Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 30 Jan 2024 00:26:25 +0000 Subject: [PATCH 2/4] improve --- modules/templates/util_avatar.go | 8 ++------ templates/repo/diff/comments.tmpl | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/templates/util_avatar.go b/modules/templates/util_avatar.go index e8febd9ce8ec4..f63528eb01ca4 100644 --- a/modules/templates/util_avatar.go +++ b/modules/templates/util_avatar.go @@ -57,6 +57,8 @@ func (au *AvatarUtils) Avatar(item any, others ...any) template.HTML { if src != "" { return AvatarHTML(src, size, class, t.AsUser().DisplayName()) } + default: + return AvatarHTML(avatars.DefaultAvatarLink(), size, class, "") } return "" @@ -79,9 +81,3 @@ func (au *AvatarUtils) AvatarByEmail(email, name string, others ...any) template return "" } - -// AvatarDefault renders default avatars. -func (au *AvatarUtils) AvatarDefault(others ...any) template.HTML { - size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) - return AvatarHTML(avatars.DefaultAvatarLink(), size, class, "") -} diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 3d44120dfa185..2fbfe2fd6a07d 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -3,7 +3,7 @@ {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
{{if .OriginalAuthor}} - {{ctx.AvatarUtils.AvatarDefault}} + {{ctx.AvatarUtils.Avatar nil}} {{else}} {{template "shared/user/avatarlink" dict "user" .Poster}} {{end}} From 3218862a5f95bd9b5662ff03d74c38e5563562e4 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 30 Jan 2024 00:34:31 +0000 Subject: [PATCH 3/4] fix --- templates/repo/issue/view_content.tmpl | 2 +- templates/repo/issue/view_content/comments.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 9967997b92411..ed444f6dcee4c 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -12,7 +12,7 @@