From 90aef80558510207510841eeb80c2f49e28ed3f0 Mon Sep 17 00:00:00 2001 From: Xinyu Zhou Date: Mon, 21 Nov 2022 12:31:53 +0800 Subject: [PATCH 1/2] Fix vertical align for avatar rendered by email address Signed-off-by: Xinyu Zhou --- models/avatars/avatar.go | 3 +++ modules/templates/helper.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/models/avatars/avatar.go b/models/avatars/avatar.go index 61f0ac19c311a..e3965ea25101a 100644 --- a/models/avatars/avatar.go +++ b/models/avatars/avatar.go @@ -20,6 +20,9 @@ import ( "code.gitea.io/gitea/modules/setting" ) +// DefaultAvatarClass is the default class of a rendered avatar +const DefaultAvatarClass = "ui avatar vm" + // DefaultAvatarPixelSize is the default size in pixels of a rendered avatar const DefaultAvatarPixelSize = 28 diff --git a/modules/templates/helper.go b/modules/templates/helper.go index d0866d3e2c46f..95671e791a4ec 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -607,7 +607,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML { // Avatar renders user avatars. args: user, size (int), class (string) func Avatar(item interface{}, others ...interface{}) template.HTML { - size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, "ui avatar vm", others...) + size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) switch t := item.(type) { case *user_model.User: @@ -638,7 +638,7 @@ func AvatarByAction(action *activities_model.Action, others ...interface{}) temp // RepoAvatar renders repo avatars. args: repo, size(int), class (string) func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML { - size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, "ui avatar", others...) + size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) src := repo.RelAvatarLink() if src != "" { @@ -649,7 +649,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM // AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string) func AvatarByEmail(email, name string, others ...interface{}) template.HTML { - size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, "ui avatar", others...) + size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor) if src != "" { From 95f844b0d45c1b6b27fd9fc427cd31c3fe9e5562 Mon Sep 17 00:00:00 2001 From: Xinyu Zhou Date: Mon, 21 Nov 2022 17:27:17 +0800 Subject: [PATCH 2/2] apply grouping syntax to const Signed-off-by: Xinyu Zhou --- models/avatars/avatar.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/models/avatars/avatar.go b/models/avatars/avatar.go index e3965ea25101a..dec264cea4263 100644 --- a/models/avatars/avatar.go +++ b/models/avatars/avatar.go @@ -20,11 +20,12 @@ import ( "code.gitea.io/gitea/modules/setting" ) -// DefaultAvatarClass is the default class of a rendered avatar -const DefaultAvatarClass = "ui avatar vm" - -// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar -const DefaultAvatarPixelSize = 28 +const ( + // DefaultAvatarClass is the default class of a rendered avatar + DefaultAvatarClass = "ui avatar vm" + // DefaultAvatarPixelSize is the default size in pixels of a rendered avatar + DefaultAvatarPixelSize = 28 +) // EmailHash represents a pre-generated hash map (mainly used by LibravatarURL, it queries email server's DNS records) type EmailHash struct {