diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-10 11:19:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 11:19:39 +0800 |
commit | a370efc13f0e1ea309e324639832832bc14cb6dc (patch) | |
tree | 3c408cf225a4ffcc49f257fabf162831c92e23bf | |
parent | 36eb3c433ae384f21beec63eb648141fb9dba676 (diff) | |
download | gitea-a370efc13f0e1ea309e324639832832bc14cb6dc.tar.gz gitea-a370efc13f0e1ea309e324639832832bc14cb6dc.zip |
Use template context function for avatar rendering (#26385)
Introduce `AvatarUtils`, no need to pass `$.Context` to every
sub-template, and simplify the template helper functions.
54 files changed, 162 insertions, 155 deletions
diff --git a/modules/context/context.go b/modules/context/context.go index b75ba9ab67..98c1a9bdb6 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -141,6 +141,7 @@ func Contexter() func(next http.Handler) http.Handler { // TODO: "install.go" also shares the same logic, which should be refactored to a general function ctx.TemplateContext = NewTemplateContext(ctx) ctx.TemplateContext["Locale"] = ctx.Locale + ctx.TemplateContext["AvatarUtils"] = templates.NewAvatarUtils(ctx) ctx.Data.MergeFrom(middleware.CommonTemplateContextData()) ctx.Data["Context"] = ctx // TODO: use "ctx" in template and remove this diff --git a/modules/templates/helper.go b/modules/templates/helper.go index d9c297411a..8fedc4076a 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -52,14 +52,11 @@ func NewFuncMap() template.FuncMap { // ----------------------------------------------------------------- // svg / avatar / icon - "svg": svg.RenderHTML, - "avatar": Avatar, - "avatarHTML": AvatarHTML, - "avatarByAction": AvatarByAction, - "avatarByEmail": AvatarByEmail, - "EntryIcon": base.EntryIcon, - "MigrationIcon": MigrationIcon, - "ActionIcon": ActionIcon, + "svg": svg.RenderHTML, + "avatarHTML": AvatarHTML, + "EntryIcon": base.EntryIcon, + "MigrationIcon": MigrationIcon, + "ActionIcon": ActionIcon, "SortArrow": SortArrow, diff --git a/modules/templates/util_avatar.go b/modules/templates/util_avatar.go index 81961041a0..462668588a 100644 --- a/modules/templates/util_avatar.go +++ b/modules/templates/util_avatar.go @@ -18,6 +18,14 @@ import ( "code.gitea.io/gitea/modules/setting" ) +type AvatarUtils struct { + ctx context.Context +} + +func NewAvatarUtils(ctx context.Context) *AvatarUtils { + return &AvatarUtils{ctx: ctx} +} + // AvatarHTML creates the HTML for an avatar func AvatarHTML(src string, size int, class, name string) template.HTML { sizeStr := fmt.Sprintf(`%d`, size) @@ -30,44 +38,44 @@ func AvatarHTML(src string, size int, class, name string) template.HTML { } // Avatar renders user avatars. args: user, size (int), class (string) -func Avatar(ctx context.Context, item any, others ...any) template.HTML { +func (au *AvatarUtils) Avatar(item any, others ...any) template.HTML { size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) switch t := item.(type) { case *user_model.User: - src := t.AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor) + src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor) if src != "" { return AvatarHTML(src, size, class, t.DisplayName()) } case *repo_model.Collaborator: - src := t.AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor) + src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor) if src != "" { return AvatarHTML(src, size, class, t.DisplayName()) } case *organization.Organization: - src := t.AsUser().AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor) + src := t.AsUser().AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor) if src != "" { return AvatarHTML(src, size, class, t.AsUser().DisplayName()) } } - return template.HTML("") + return "" } // AvatarByAction renders user avatars from action. args: action, size (int), class (string) -func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...any) template.HTML { - action.LoadActUser(ctx) - return Avatar(ctx, action.ActUser, others...) +func (au *AvatarUtils) AvatarByAction(action *activities_model.Action, others ...any) template.HTML { + action.LoadActUser(au.ctx) + return au.Avatar(action.ActUser, others...) } // AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string) -func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML { +func (au *AvatarUtils) AvatarByEmail(email, name string, others ...any) template.HTML { size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) - src := avatars.GenerateEmailAvatarFastLink(ctx, email, size*setting.Avatar.RenderedSizeFactor) + src := avatars.GenerateEmailAvatarFastLink(au.ctx, email, size*setting.Avatar.RenderedSizeFactor) if src != "" { return AvatarHTML(src, size, class, name) } - return template.HTML("") + return "" } diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index 0e232c194c..b1cb42297c 100644 --- a/routers/web/repo/blame.go +++ b/routers/web/repo/blame.go @@ -235,6 +235,7 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m var lexerName string + avatarUtils := templates.NewAvatarUtils(ctx) i := 0 commitCnt := 0 for _, part := range blameParts { @@ -257,9 +258,9 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m var avatar string if commit.User != nil { - avatar = string(templates.Avatar(ctx, commit.User, 18, "gt-mr-3")) + avatar = string(avatarUtils.Avatar(commit.User, 18, "gt-mr-3")) } else { - avatar = string(templates.AvatarByEmail(ctx, commit.Author.Email, commit.Author.Name, 18, "gt-mr-3")) + avatar = string(avatarUtils.AvatarByEmail(commit.Author.Email, commit.Author.Name, 18, "gt-mr-3")) } br.Avatar = gotemplate.HTML(avatar) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 35aff8e538..1ad7fd20bd 100644 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -57,7 +57,7 @@ {{if and .IsSigned .MustChangePassword}} <div class="ui dropdown jump item" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}"> <span class="text gt-df gt-ac"> - {{avatar $.Context .SignedUser 24 "gt-mr-2"}} + {{ctx.AvatarUtils.Avatar .SignedUser 24 "gt-mr-2"}} <span class="mobile-only gt-ml-3">{{.SignedUser.Name}}</span> <span class="not-mobile">{{svg "octicon-triangle-down"}}</span> </span> @@ -143,7 +143,7 @@ <div class="ui dropdown jump item gt-mx-0 gt-pr-3" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}"> <span class="text gt-df gt-ac"> - {{avatar $.Context .SignedUser 24 "gt-mr-2"}} + {{ctx.AvatarUtils.Avatar .SignedUser 24 "gt-mr-2"}} <span class="mobile-only gt-ml-3">{{.SignedUser.Name}}</span> <span class="not-mobile">{{svg "octicon-triangle-down"}}</span> </span> diff --git a/templates/explore/users.tmpl b/templates/explore/users.tmpl index 5e150f692f..1280f4add6 100644 --- a/templates/explore/users.tmpl +++ b/templates/explore/users.tmpl @@ -8,7 +8,7 @@ {{range .Users}} <div class="flex-item flex-item-center"> <div class="flex-item-leading"> - {{avatar $.Context . 48}} + {{ctx.AvatarUtils.Avatar . 48}} </div> <div class="flex-item-main"> <div class="flex-item-title"> diff --git a/templates/org/header.tmpl b/templates/org/header.tmpl index 6106fe5d2b..9348e14544 100644 --- a/templates/org/header.tmpl +++ b/templates/org/header.tmpl @@ -3,7 +3,7 @@ <div class="ui vertically grid head"> <div class="column"> <div class="ui header"> - {{avatar $.Context . 100}} + {{ctx.AvatarUtils.Avatar . 100}} <span class="text thin grey"><a href="{{.HomeLink}}">{{.DisplayName}}</a></span> <span class="org-visibility"> {{if .Visibility.IsLimited}}<div class="ui medium basic horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}} diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 445df520a9..766dd5b7a6 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -1,7 +1,7 @@ {{template "base/head" .}} <div role="main" aria-label="{{.Title}}" class="page-content organization profile"> <div class="ui container gt-df"> - {{avatar $.Context .Org 140 "org-avatar"}} + {{ctx.AvatarUtils.Avatar .Org 140 "org-avatar"}} <div id="org-info"> <div class="ui header gt-df gt-fw"> {{.Org.DisplayName}} @@ -61,7 +61,7 @@ {{$isMember := .IsOrganizationMember}} {{range .Members}} {{if or $isMember (call $.IsPublicMember .ID)}} - <a href="{{.HomeLink}}" title="{{.Name}}{{if .FullName}} ({{.FullName}}){{end}}">{{avatar $.Context . 48}}</a> + <a href="{{.HomeLink}}" title="{{.Name}}{{if .FullName}} ({{.FullName}}){{end}}">{{ctx.AvatarUtils.Avatar . 48}}</a> {{end}} {{end}} </div> diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index 13b7d964f7..a15254d041 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -9,7 +9,7 @@ {{$isPublic := index $.MembersIsPublicMember .ID}} <div class="flex-item {{if $.PublicOnly}}flex-item-center{{end}}"> <div class="flex-item-leading"> - <a href="{{.HomeLink}}">{{avatar $.Context . 48}}</a> + <a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 48}}</a> </div> <div class="flex-item-main"> <div class="flex-item-title"> diff --git a/templates/org/team/invite.tmpl b/templates/org/team/invite.tmpl index 55ecd049b3..60332a5f40 100644 --- a/templates/org/team/invite.tmpl +++ b/templates/org/team/invite.tmpl @@ -4,7 +4,7 @@ {{template "base/alert" .}} <div class="ui centered card"> <div class="image"> - {{avatar $.Context .Organization 140}} + {{ctx.AvatarUtils.Avatar .Organization 140}} </div> <div class="content"> <div class="header">{{.locale.Tr "org.teams.invite.title" .Team.Name .Organization.Name | Str2html}}</div> diff --git a/templates/org/team/members.tmpl b/templates/org/team/members.tmpl index a73eb7bbd3..13c60d3945 100644 --- a/templates/org/team/members.tmpl +++ b/templates/org/team/members.tmpl @@ -26,7 +26,7 @@ {{range .Team.Members}} <div class="flex-item flex-item-center"> <div class="flex-item-leading"> - <a href="{{.HomeLink}}">{{avatar $.Context . 32}}</a> + <a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 32}}</a> </div> <div class="flex-item-main"> <div class="flex-item-title"> diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 9a7dae8f32..a96dd7d6be 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -32,7 +32,7 @@ </div> <div class="ui attached segment members"> {{range .Members}} - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .}} + {{template "shared/user/avatarlink" dict "user" .}} {{end}} </div> <div class="ui bottom attached header"> diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index 6689bea220..fe4ea6022f 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -234,7 +234,7 @@ {{end}} <div class="right floated"> {{range .Assignees}} - <a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{avatar $.Context . 28 "mini gt-mr-3"}}</a> + <a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{ctx.AvatarUtils.Avatar . 28 "mini gt-mr-3"}}</a> {{end}} </div> </div> diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index f4f0aa9d6d..e73cf71f6b 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -33,7 +33,7 @@ </a> {{range .Actors}} <a class="item{{if eq .ID $.CurActor}} active{{end}}" href="{{$.Link}}?workflow={{$.CurWorkflow}}&actor={{.ID}}&status={{$.CurStatus}}"> - {{avatar $.Context . 20}} {{.GetDisplayName}} + {{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}} </a> {{end}} </div> diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index b32e8cace7..bd045995b2 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -27,7 +27,7 @@ <button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button> {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}} </div> - <p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage .RepoLink .Repository.ComposeMetas}}</span> · {{.locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime .locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "Context" $.Context "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p> + <p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage .RepoLink .Repository.ComposeMetas}}</span> · {{.locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime .locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p> </td> <td class="right aligned middle aligned overflow-visible"> {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} @@ -94,7 +94,7 @@ <button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button> {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}} </div> - <p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink $.Repository.ComposeMetas}}</span> · {{$.locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime $.locale}}{{if .DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "Context" $.Context "user" .DBBranch.Pusher}} {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p> + <p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink $.Repository.ComposeMetas}}</span> · {{$.locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime $.locale}}{{if .DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p> {{end}} </td> <td class="two wide ui"> diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index bd33a30443..06b8f1ba15 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -142,24 +142,24 @@ <div class="ui attached segment gt-df gt-ac gt-sb gt-py-2 commit-header-row gt-fw {{$class}}"> <div class="gt-df gt-ac author"> {{if .Author}} - {{avatar $.Context .Author 28 "gt-mr-3"}} + {{ctx.AvatarUtils.Avatar .Author 28 "gt-mr-3"}} {{if .Author.FullName}} <a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a> {{else}} <a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a> {{end}} {{else}} - {{avatarByEmail $.Context .Commit.Author.Email .Commit.Author.Email 28 "gt-mr-3"}} + {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "gt-mr-3"}} <strong>{{.Commit.Author.Name}}</strong> {{end}} <span class="text grey gt-ml-3" id="authored-time">{{TimeSince .Commit.Author.When $.locale}}</span> {{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}} <span class="text grey gt-mx-3">{{.locale.Tr "repo.diff.committed_by"}}</span> {{if ne .Verification.CommittingUser.ID 0}} - {{avatar $.Context .Verification.CommittingUser 28 "gt-mx-3"}} + {{ctx.AvatarUtils.Avatar .Verification.CommittingUser 28 "gt-mx-3"}} <a href="{{.Verification.CommittingUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a> {{else}} - {{avatarByEmail $.Context .Commit.Committer.Email .Commit.Committer.Name 28 "gt-mr-3"}} + {{ctx.AvatarUtils.AvatarByEmail .Commit.Committer.Email .Commit.Committer.Name 28 "gt-mr-3"}} <strong>{{.Commit.Committer.Name}}</strong> {{end}} {{end}} @@ -196,12 +196,12 @@ {{else}} <span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span> {{end}} - {{avatar $.Context .Verification.SigningUser 28 "gt-mr-3"}} + {{ctx.AvatarUtils.Avatar .Verification.SigningUser 28 "gt-mr-3"}} <a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a> {{else}} <span title="{{.locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog" 16 "gt-mr-3"}}</span> <span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by"}}:</span> - {{avatarByEmail $.Context .Verification.SigningEmail "" 28}} + {{ctx.AvatarUtils.AvatarByEmail .Verification.SigningEmail "" 28}} <strong>{{.Verification.SigningUser.GetDisplayName}}</strong> {{end}} {{else}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index ef9d065456..9f1d182158 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -18,9 +18,9 @@ {{if .User.FullName}} {{$userName = .User.FullName}} {{end}} - {{avatar $.Context .User 28 "gt-mr-2"}}<a href="{{.User.HomeLink}}">{{$userName}}</a> + {{ctx.AvatarUtils.Avatar .User 28 "gt-mr-2"}}<a href="{{.User.HomeLink}}">{{$userName}}</a> {{else}} - {{avatarByEmail $.Context .Author.Email .Author.Name 28 "gt-mr-2"}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "gt-mr-2"}} {{$userName}} {{end}} </td> diff --git a/templates/repo/commits_list_small.tmpl b/templates/repo/commits_list_small.tmpl index 57c9fd17ef..ff65d02885 100644 --- a/templates/repo/commits_list_small.tmpl +++ b/templates/repo/commits_list_small.tmpl @@ -6,9 +6,9 @@ <div class="singular-commit" id="{{$tag}}"> <span class="badge badge-commit">{{svg "octicon-git-commit"}}</span> {{if .User}} - <a class="avatar" href="{{.User.HomeLink}}">{{avatar $.root.Context .User}}</a> + <a class="avatar" href="{{.User.HomeLink}}">{{ctx.AvatarUtils.Avatar .User}}</a> {{else}} - {{avatarByEmail $.root.Context .Author.Email .Author.Name}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name}} {{end}} {{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}} diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index ce909fbbf7..2025cac566 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -21,18 +21,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index d19ac1f047..c1bb14e714 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -5,7 +5,7 @@ {{if .OriginalAuthor}} <span class="avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span> {{else}} - {{template "shared/user/avatarlink" dict "Context" $.root.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} {{end}} <div class="content comment-container"> <div class="ui top attached header comment-header gt-df gt-ac gt-sb"> diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl index 6a3f86f9fc..5833687753 100644 --- a/templates/repo/editor/commit_form.tmpl +++ b/templates/repo/editor/commit_form.tmpl @@ -1,5 +1,5 @@ <div class="commit-form-wrapper"> - {{avatar $.Context .SignedUser 48 "commit-avatar"}} + {{ctx.AvatarUtils.Avatar .SignedUser 48 "commit-avatar"}} <div class="commit-form"> <h3>{{- if .CanCommitToBranch.WillSign}} <span title="{{.locale.Tr "repo.signing.will_sign" .CanCommitToBranch.SigningKey}}">{{svg "octicon-lock" 24}}</span> diff --git a/templates/repo/forks.tmpl b/templates/repo/forks.tmpl index 13810b44da..481c0e67e0 100644 --- a/templates/repo/forks.tmpl +++ b/templates/repo/forks.tmpl @@ -7,7 +7,7 @@ </h2> {{range .Forks}} <div class="gt-df gt-ac gt-py-3"> - <span class="gt-mr-2">{{avatar $.Context .Owner}}</span> + <span class="gt-mr-2">{{ctx.AvatarUtils.Avatar .Owner}}</span> <a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="{{.Link}}">{{.Name}}</a> </div> {{end}} diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl index 8652a72052..0a21aec9c0 100644 --- a/templates/repo/graph/commits.tmpl +++ b/templates/repo/graph/commits.tmpl @@ -64,10 +64,10 @@ {{if $commit.User.FullName}} {{$userName = $commit.User.FullName}} {{end}} - <span class="gt-mr-2">{{avatar $.Context $commit.User}}</span> + <span class="gt-mr-2">{{ctx.AvatarUtils.Avatar $commit.User}}</span> <a href="{{$commit.User.HomeLink}}">{{$userName}}</a> {{else}} - <span class="gt-mr-2">{{avatarByEmail $.Context $commit.Commit.Author.Email $userName}}</span> + <span class="gt-mr-2">{{ctx.AvatarUtils.AvatarByEmail $commit.Commit.Author.Email $userName}}</span> {{$userName}} {{end}} </span> diff --git a/templates/repo/issue/filters.tmpl b/templates/repo/issue/filters.tmpl index b75d98ed6f..799509328f 100644 --- a/templates/repo/issue/filters.tmpl +++ b/templates/repo/issue/filters.tmpl @@ -146,7 +146,7 @@ <div class="divider"></div> {{range .Assignees}} <a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item gt-df" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{.ID}}&poster={{$.PosterID}}"> - {{avatar $.Context . 20}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 20}}{{template "repo/search_name" .}} </a> {{end}} </div> diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 8eb85a3298..7ae65efedc 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -56,7 +56,7 @@ {{end}} <div class="right floated"> {{range .Assignees}} - <a href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{avatar $.Context . 28 "mini gt-mr-3"}}</a> + <a href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{ctx.AvatarUtils.Avatar . 28 "mini gt-mr-3"}}</a> {{end}} </div> </div> @@ -208,7 +208,7 @@ </div> {{range .Assignees}} <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee"> - {{avatar $.Context . 20}} {{.GetDisplayName}} + {{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}} </div> {{end}} </div> diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl index aa68021748..272693e63e 100644 --- a/templates/repo/issue/new_form.tmpl +++ b/templates/repo/issue/new_form.tmpl @@ -8,7 +8,7 @@ <div class="issue-content-left"> <div class="ui comments"> <div class="comment"> - {{avatar $.Context .SignedUser 40}} + {{ctx.AvatarUtils.Avatar .SignedUser 40}} <div class="ui segment content gt-my-0"> <div class="field"> <input name="title" id="issue_title" placeholder="{{.locale.Tr "repo.milestones.title"}}" value="{{if .TitleQuery}}{{.TitleQuery}}{{else if .IssueTemplateTitle}}{{.IssueTemplateTitle}}{{else}}{{.title}}{{end}}" tabindex="3" autofocus required maxlength="255" autocomplete="off"> @@ -160,7 +160,7 @@ <a class="item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}"> <span class="octicon-check invisible">{{svg "octicon-check"}}</span> <span class="text"> - {{avatar $.Context . 28 "gt-mr-3"}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 28 "gt-mr-3"}}{{template "repo/search_name" .}} </span> </a> {{end}} @@ -173,7 +173,7 @@ <div class="selected"> {{range .Assignees}} <a class="item gt-p-2 muted gt-hidden" id="assignee_{{.ID}}" href="{{$.RepoLink}}/issues?assignee={{.ID}}"> - {{avatar $.Context . 28 "gt-mr-3 gt-vm"}}{{.GetDisplayName}} + {{ctx.AvatarUtils.Avatar . 28 "gt-mr-3 gt-vm"}}{{.GetDisplayName}} </a> {{end}} </div> diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index ab8da434ee..f6572d4965 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -16,7 +16,7 @@ </span> {{else}} <a class="timeline-avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}> - {{avatar $.Context .Issue.Poster 40}} + {{ctx.AvatarUtils.Avatar .Issue.Poster 40}} </a> {{end}} <div class="content comment-container"> @@ -35,7 +35,7 @@ </span> {{else}} <a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}"> - {{avatar $.Context .Issue.Poster 24}} + {{ctx.AvatarUtils.Avatar .Issue.Poster 24}} </a> <span class="text grey muted-links"> {{template "shared/user/authorlink" .Issue.Poster}} @@ -93,7 +93,7 @@ {{if and (or .IsRepoAdmin .HasIssuesOrPullsWritePermission (not .Issue.IsLocked)) (not .Repository.IsArchived)}} <div class="timeline-item comment form"> <a class="timeline-avatar" href="{{.SignedUser.HomeLink}}"> - {{avatar $.Context .SignedUser 40}} + {{ctx.AvatarUtils.Avatar .SignedUser 40}} </a> <div class="content"> <form class="ui segment form form-fetch-action" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post"> diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 5dbd530fa5..57756e36b9 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -20,7 +20,7 @@ </span> {{else}} <a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}> - {{avatar $.Context .Poster 40}} + {{ctx.AvatarUtils.Avatar .Poster 40}} </a> {{end}} <div class="content comment-container"> @@ -40,7 +40,7 @@ {{else}} {{if gt .Poster.ID 0}} <a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}"> - {{avatar $.Context .Poster 24}} + {{ctx.AvatarUtils.Avatar .Poster 24}} </a> {{end}} <span class="text grey muted-links"> @@ -94,7 +94,7 @@ {{else if eq .Type 1}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge gt-bg-green gt-text-white">{{svg "octicon-dot-fill"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if .Issue.IsPull}} @@ -107,7 +107,7 @@ {{else if eq .Type 2}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge gt-bg-red gt-text-white">{{svg "octicon-circle-slash"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if .Issue.IsPull}} @@ -120,7 +120,7 @@ {{else if eq .Type 28}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge gt-bg-purple gt-text-white">{{svg "octicon-git-merge"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}} @@ -147,7 +147,7 @@ {{$createdStr:= TimeSinceUnix .CreatedUnix $.locale}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-bookmark"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} {{if eq .RefAction 3}}<del>{{end}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} @@ -162,7 +162,7 @@ {{else if eq .Type 4}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-bookmark"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}} @@ -176,7 +176,7 @@ {{if or .AddedLabels .RemovedLabels}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-tag"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if and .AddedLabels (not .RemovedLabels)}} @@ -192,7 +192,7 @@ {{else if eq .Type 8}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-milestone"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.locale.Tr "repo.issues.change_milestone_at" (.OldMilestone.Name|Escape) (.Milestone.Name|Escape) $createdStr | Safe}}{{else}}{{$.locale.Tr "repo.issues.remove_milestone_at" (.OldMilestone.Name|Escape) $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.locale.Tr "repo.issues.add_milestone_at" (.Milestone.Name|Escape) $createdStr | Safe}}{{end}} @@ -203,7 +203,7 @@ <span class="badge">{{svg "octicon-person"}}</span> {{if gt .AssigneeID 0}} {{if .RemovedAssignee}} - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Assignee}} + {{template "shared/user/avatarlink" dict "user" .Assignee}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Assignee}} {{if eq .Poster.ID .Assignee.ID}} @@ -213,7 +213,7 @@ {{end}} </span> {{else}} - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Assignee}} + {{template "shared/user/avatarlink" dict "user" .Assignee}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Assignee}} {{if eq .Poster.ID .AssigneeID}} @@ -228,7 +228,7 @@ {{else if eq .Type 10}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-pencil"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.change_title_at" (.OldTitle|RenderEmoji $.Context) (.NewTitle|RenderEmoji $.Context) $createdStr | Safe}} @@ -237,7 +237,7 @@ {{else if eq .Type 11}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-git-branch"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.delete_branch_at" (.OldRef|Escape) $createdStr | Safe}} @@ -246,7 +246,7 @@ {{else if eq .Type 12}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.start_tracking_history" $createdStr | Safe}} @@ -255,7 +255,7 @@ {{else if eq .Type 13}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}} @@ -274,7 +274,7 @@ {{else if eq .Type 14}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}} @@ -293,7 +293,7 @@ {{else if eq .Type 15}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}} @@ -302,7 +302,7 @@ {{else if eq .Type 16}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.due_date_added" (DateTime "long" .Content) $createdStr | Safe}} @@ -311,7 +311,7 @@ {{else if eq .Type 17}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$parsedDeadline := StringUtils.Split .Content "|"}} @@ -325,7 +325,7 @@ {{else if eq .Type 18}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.due_date_remove" (DateTime "long" .Content) $createdStr | Safe}} @@ -334,7 +334,7 @@ {{else if eq .Type 19}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-package-dependents"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.dependency.added_dependency" $createdStr | Safe}} @@ -357,7 +357,7 @@ {{else if eq .Type 20}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-package-dependents"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.dependency.removed_dependency" $createdStr | Safe}} @@ -386,7 +386,7 @@ bubble. The condition depends on review type and for positive reviews whether there is a comment element or not */}} <a class="timeline-avatar{{if or (and (eq .Review.Type 1) (or .Content .Attachments)) (and (eq .Review.Type 2) (or .Content .Attachments)) (eq .Review.Type 3)}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}> - {{avatar $.Context .Poster 40}} + {{ctx.AvatarUtils.Avatar .Poster 40}} </a> {{end}} <span class="badge{{if eq .Review.Type 1}} gt-bg-green gt-text-white{{else if eq .Review.Type 3}} gt-bg-red gt-text-white{{end}}">{{svg (printf "octicon-%s" .Review.Type.Icon)}}</span> @@ -423,7 +423,7 @@ <div class="comment-header-left gt-df gt-ac"> {{if gt .Poster.ID 0}} <a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}"> - {{avatar $.Context .Poster 24}} + {{ctx.AvatarUtils.Avatar .Poster 24}} </a> {{end}} <span class="text grey muted-links"> @@ -549,7 +549,7 @@ <div class="comment-header-left gt-df gt-ac"> {{if not .OriginalAuthor}} <a class="avatar"> - {{avatar $.Context .Poster 20}} + {{ctx.AvatarUtils.Avatar .Poster 20}} </a> {{end}} <span class="text grey muted-links"> @@ -644,7 +644,7 @@ {{else if eq .Type 23}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-lock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} {{if .Content}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} @@ -660,7 +660,7 @@ {{else if eq .Type 24}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-key"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$.locale.Tr "repo.issues.unlock_comment" $createdStr | Safe}} @@ -669,7 +669,7 @@ {{else if eq .Type 25}} <div class="timeline-item event"> <span class="badge">{{svg "octicon-git-branch"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> <a{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.locale.Tr "repo.pulls.change_target_branch_at" (.OldRef|Escape) (.NewRef|Escape) $createdStr | Safe}} @@ -678,7 +678,7 @@ {{else if eq .Type 26}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-clock"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} @@ -697,7 +697,7 @@ {{else if eq .Type 27}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-eye"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if (gt .AssigneeID 0)}} @@ -752,7 +752,7 @@ {{if not $.UnitProjectsGlobalDisabled}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-project"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{$oldProjectDisplayHtml := "Unknown Project"}} @@ -799,7 +799,7 @@ <div class="ui top attached header comment-header-left gt-df gt-ac arrow-top"> {{if gt .Poster.ID 0}} <a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}"> - {{avatar $.Context .Poster 24}} + {{ctx.AvatarUtils.Avatar .Poster 24}} </a> {{end}} <span class="text grey muted-links"> @@ -822,7 +822,7 @@ {{else if eq .Type 33}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-git-branch"}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if and .OldRef .NewRef}} @@ -846,7 +846,7 @@ {{else if or (eq .Type 36) (eq .Type 37)}} <div class="timeline-item event" id="{{.HashTag}}"> <span class="badge">{{svg "octicon-pin" 16}}</span> - {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} + {{template "shared/user/avatarlink" dict "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if eq .Type 36}}{{$.locale.Tr "repo.issues.pin_comment" $createdStr | Safe}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 15845665bb..70aa8e53c0 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -22,7 +22,7 @@ <a class="{{if not .CanChange}}ui{{end}} item {{if .Checked}}checked{{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_{{.ItemID}}" {{if not .CanChange}} data-tooltip-content="{{$.locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}> <span class="octicon-check {{if not .Checked}}invisible{{end}}">{{svg "octicon-check"}}</span> <span class="text"> - {{avatar $.Context .User 28 "gt-mr-3"}}{{template "repo/search_name" .User}} + {{ctx.AvatarUtils.Avatar .User 28 "gt-mr-3"}}{{template "repo/search_name" .User}} </span> </a> {{end}} @@ -51,7 +51,7 @@ <div class="item gt-df gt-ac gt-py-3"> <div class="gt-df gt-ac gt-f1"> {{if .User}} - <a class="muted sidebar-item-link" href="{{.User.HomeLink}}">{{avatar $.Context .User 20 "gt-mr-3"}}{{.User.GetDisplayName}}</a> + <a class="muted sidebar-item-link" href="{{.User.HomeLink}}">{{ctx.AvatarUtils.Avatar .User 20 "gt-mr-3"}}{{.User.GetDisplayName}}</a> {{else if .Team}} <span class="text">{{svg "octicon-people" 20 "gt-mr-3"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}}</span> {{end}} @@ -231,7 +231,7 @@ {{end}} <span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span> <span class="text"> - {{avatar $.Context . 20 "gt-mr-3"}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 20 "gt-mr-3"}}{{template "repo/search_name" .}} </span> </a> {{end}} @@ -243,7 +243,7 @@ {{range .Issue.Assignees}} <div class="item"> <a class="muted sidebar-item-link" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?assignee={{.ID}}"> - {{avatar $.Context . 28 "gt-mr-3"}} + {{ctx.AvatarUtils.Avatar . 28 "gt-mr-3"}} {{.GetDisplayName}} </a> </div> @@ -258,7 +258,7 @@ <div class="ui list gt-df gt-fw"> {{range .Participants}} <a {{if gt .ID 0}}href="{{.HomeLink}}"{{end}} data-tooltip-content="{{.GetDisplayName}}"> - {{avatar $.Context . 28 "gt-my-1 gt-mr-2"}} + {{ctx.AvatarUtils.Avatar . 28 "gt-my-1 gt-mr-2"}} </a> {{end}} </div> @@ -347,7 +347,7 @@ {{range $user, $trackedtime := .WorkingUsers}} <div class="comment gt-mt-3"> <a class="avatar"> - {{avatar $.Context $user}} + {{ctx.AvatarUtils.Avatar $user}} </a> <div class="content"> {{template "shared/user/authorlink" $user}} diff --git a/templates/repo/migrate/codebase.tmpl b/templates/repo/migrate/codebase.tmpl index 3d46b14ccc..db607eebb4 100644 --- a/templates/repo/migrate/codebase.tmpl +++ b/templates/repo/migrate/codebase.tmpl @@ -62,18 +62,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl index df2f10e487..42ae642d26 100644 --- a/templates/repo/migrate/git.tmpl +++ b/templates/repo/migrate/git.tmpl @@ -36,18 +36,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser}} + {{ctx.AvatarUtils.Avatar .ContextUser}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser}} + {{ctx.AvatarUtils.Avatar .SignedUser}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/gitbucket.tmpl b/templates/repo/migrate/gitbucket.tmpl index 2ac9159d2e..372df0c2db 100644 --- a/templates/repo/migrate/gitbucket.tmpl +++ b/templates/repo/migrate/gitbucket.tmpl @@ -78,18 +78,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/gitea.tmpl b/templates/repo/migrate/gitea.tmpl index 49015e69eb..dcceb1e3af 100644 --- a/templates/repo/migrate/gitea.tmpl +++ b/templates/repo/migrate/gitea.tmpl @@ -74,18 +74,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser}} + {{ctx.AvatarUtils.Avatar .ContextUser}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser}} + {{ctx.AvatarUtils.Avatar .SignedUser}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/github.tmpl b/templates/repo/migrate/github.tmpl index 164e62d299..0ccad3a3ea 100644 --- a/templates/repo/migrate/github.tmpl +++ b/templates/repo/migrate/github.tmpl @@ -76,18 +76,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/gitlab.tmpl b/templates/repo/migrate/gitlab.tmpl index 7c226f8097..af20fa38e2 100644 --- a/templates/repo/migrate/gitlab.tmpl +++ b/templates/repo/migrate/gitlab.tmpl @@ -73,18 +73,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/gogs.tmpl b/templates/repo/migrate/gogs.tmpl index 6390d8917e..dd62e80479 100644 --- a/templates/repo/migrate/gogs.tmpl +++ b/templates/repo/migrate/gogs.tmpl @@ -76,18 +76,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser}} + {{ctx.AvatarUtils.Avatar .ContextUser}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser}} + {{ctx.AvatarUtils.Avatar .SignedUser}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/migrate/onedev.tmpl b/templates/repo/migrate/onedev.tmpl index 2a1ae110d6..f5ba11ab06 100644 --- a/templates/repo/migrate/onedev.tmpl +++ b/templates/repo/migrate/onedev.tmpl @@ -62,18 +62,18 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu" title="{{.SignedUser.Name}}"> <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index 9df55ff317..2dbb381960 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -243,7 +243,7 @@ {{end}} <div class="right floated"> {{range .Assignees}} - <a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{avatar $.Context . 28 "mini gt-mr-3"}}</a> + <a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{ctx.AvatarUtils.Avatar . 28 "mini gt-mr-3"}}</a> {{end}} </div> </div> diff --git a/templates/repo/pulls/fork.tmpl b/templates/repo/pulls/fork.tmpl index 525858c6aa..15635074ac 100644 --- a/templates/repo/pulls/fork.tmpl +++ b/templates/repo/pulls/fork.tmpl @@ -14,20 +14,20 @@ <div class="ui selection owner dropdown"> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{avatar $.Context .ContextUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> </span> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> {{if .CanForkToUser}} <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}"> - {{avatar $.Context .SignedUser 28 "mini"}} + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> </div> {{end}} {{range .Orgs}} <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} <span class="truncated-item-name">{{.ShortName 40}}</span> </div> {{end}} diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index fb8534f102..f326fb3272 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -38,7 +38,7 @@ <p class="text grey"> {{if gt .Publisher.ID 0}} <span class="author"> - {{avatar $.Context .Publisher 20}} + {{ctx.AvatarUtils.Avatar .Publisher 20}} <a href="{{.Publisher.HomeLink}}">{{.Publisher.Name}}</a> </span> <span class="released"> @@ -57,7 +57,7 @@ {{if .OriginalAuthor}} {{svg "octicon-mark-github" 16 "gt-mr-2"}}{{.OriginalAuthor}} {{else if .Publisher}} - {{avatar $.Context .Publisher 20}} + {{ctx.AvatarUtils.Avatar .Publisher 20}} <a href="{{.Publisher.HomeLink}}">{{.Publisher.GetDisplayName}}</a> {{else}} Ghost diff --git a/templates/repo/settings/collaboration.tmpl b/templates/repo/settings/collaboration.tmpl index 0716489291..13b2df0653 100644 --- a/templates/repo/settings/collaboration.tmpl +++ b/templates/repo/settings/collaboration.tmpl @@ -9,7 +9,7 @@ {{range .Collaborators}} <div class="flex-item flex-item-center"> <div class="flex-item-leading"> - <a href="{{.HomeLink}}">{{avatar $.Context . 32}}</a> + <a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 32}}</a> </div> <div class="flex-item-main"> <div class="flex-item-title"> diff --git a/templates/repo/settings/lfs_locks.tmpl b/templates/repo/settings/lfs_locks.tmpl index c003500bb6..4eadf9ca32 100644 --- a/templates/repo/settings/lfs_locks.tmpl +++ b/templates/repo/settings/lfs_locks.tmpl @@ -31,7 +31,7 @@ </td> <td> <a href="{{$.Owner.HomeLink}}"> - {{avatar $.Context $.Owner}} + {{ctx.AvatarUtils.Avatar $.Owner}} {{$.Owner.DisplayName}} </a> </td> diff --git a/templates/repo/settings/protected_branch.tmpl b/templates/repo/settings/protected_branch.tmpl index e76d3c76e2..eb5baff59b 100644 --- a/templates/repo/settings/protected_branch.tmpl +++ b/templates/repo/settings/protected_branch.tmpl @@ -55,7 +55,7 @@ <div class="menu"> {{range .Users}} <div class="item" data-value="{{.ID}}"> - {{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} </div> {{end}} </div> @@ -116,7 +116,7 @@ <div class="menu"> {{range .Users}} <div class="item" data-value="{{.ID}}"> - {{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} </div> {{end}} </div> @@ -206,7 +206,7 @@ <div class="menu"> {{range .Users}} <div class="item" data-value="{{.ID}}"> - {{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} </div> {{end}} </div> diff --git a/templates/repo/settings/tags.tmpl b/templates/repo/settings/tags.tmpl index b3e8cefa6c..c3d2fc38de 100644 --- a/templates/repo/settings/tags.tmpl +++ b/templates/repo/settings/tags.tmpl @@ -32,7 +32,7 @@ <div class="menu"> {{range .Users}} <div class="item" data-value="{{.ID}}"> - {{avatar $.Context . 28 "mini"}}{{template "repo/search_name" .}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} </div> {{end}} </div> @@ -89,7 +89,7 @@ {{$userIDs := .AllowlistUserIDs}} {{range $.Users}} {{if SliceUtils.Contains $userIDs .ID}} - <a class="ui basic label" href="{{.HomeLink}}">{{avatar $.Context . 26}} {{.GetDisplayName}}</a> + <a class="ui basic label" href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 26}} {{.GetDisplayName}}</a> {{end}} {{end}} {{if $.Owner.IsOrganization}} diff --git a/templates/repo/shabox_badge.tmpl b/templates/repo/shabox_badge.tmpl index 2418d95c67..20fbe553a4 100644 --- a/templates/repo/shabox_badge.tmpl +++ b/templates/repo/shabox_badge.tmpl @@ -3,10 +3,10 @@ <div title="{{if eq .verification.TrustStatus "trusted"}}{{else if eq .verification.TrustStatus "untrusted"}}{{$.root.locale.Tr "repo.commits.signed_by_untrusted_user"}}: {{else}}{{$.root.locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}: {{end}}{{.verification.Reason}}"> {{if ne .verification.SigningUser.ID 0}} {{svg "gitea-lock"}} - {{avatar $.root.Context .verification.SigningUser 28 "signature"}} + {{ctx.AvatarUtils.Avatar .verification.SigningUser 28 "signature"}} {{else}} <span title="{{$.root.locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span> - {{avatarByEmail $.root.Context .verification.SigningEmail "" 28 "signature"}} + {{ctx.AvatarUtils.AvatarByEmail .verification.SigningEmail "" 28 "signature"}} {{end}} </div> {{else}} diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl index 29864462e6..61ed11366c 100644 --- a/templates/repo/user_cards.tmpl +++ b/templates/repo/user_cards.tmpl @@ -8,7 +8,7 @@ {{range .Cards}} <li class="item ui segment"> <a href="{{.HomeLink}}"> - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}} </a> <h3 class="name"><a href="{{.HomeLink}}">{{.DisplayName}}</a></h3> diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 3eabf9f181..453c06216d 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -6,7 +6,7 @@ <div class="ui active tiny slow centered inline">…</div> {{else}} {{if .LatestCommitUser}} - {{avatar $.Context .LatestCommitUser 24}} + {{ctx.AvatarUtils.Avatar .LatestCommitUser 24}} {{if .LatestCommitUser.FullName}} <a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a> {{else}} @@ -14,7 +14,7 @@ {{end}} {{else}} {{if .LatestCommit.Author}} - {{avatarByEmail $.Context .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} + {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} <span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span> {{end}} {{end}} diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 30e19baf7c..72cf1dd6c8 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -37,7 +37,7 @@ <div class="text grey"> {{range .Assignees}} <a class="ui assignee gt-no-underline" href="{{.HomeLink}}" data-tooltip-content="{{.GetDisplayName}}"> - {{avatar $.Context . 20}} + {{ctx.AvatarUtils.Avatar . 20}} </a> {{end}} </div> diff --git a/templates/shared/user/avatarlink.tmpl b/templates/shared/user/avatarlink.tmpl index c99f0aacb7..5e3ed7a68c 100644 --- a/templates/shared/user/avatarlink.tmpl +++ b/templates/shared/user/avatarlink.tmpl @@ -1 +1 @@ -<a class="avatar"{{if gt .user.ID 0}} href="{{.user.HomeLink}}"{{end}}>{{avatar $.Context .user}}</a> +<a class="avatar"{{if gt .user.ID 0}} href="{{.user.HomeLink}}"{{end}}>{{ctx.AvatarUtils.Avatar .user}}</a> diff --git a/templates/shared/user/org_profile_avatar.tmpl b/templates/shared/user/org_profile_avatar.tmpl index a56763e288..9c94930511 100644 --- a/templates/shared/user/org_profile_avatar.tmpl +++ b/templates/shared/user/org_profile_avatar.tmpl @@ -3,7 +3,7 @@ <div class="ui vertically grid head"> <div class="column"> <div class="ui header"> - {{avatar $.Context . 100}} + {{ctx.AvatarUtils.Avatar . 100}} <span class="text thin grey"><a href="{{.HomeLink}}">{{.DisplayName}}</a></span> <span class="org-visibility"> {{if .Visibility.IsLimited}}<div class="ui medium basic horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}} diff --git a/templates/shared/user/profile_big_avatar.tmpl b/templates/shared/user/profile_big_avatar.tmpl index 97afbb6580..305a6b5a20 100644 --- a/templates/shared/user/profile_big_avatar.tmpl +++ b/templates/shared/user/profile_big_avatar.tmpl @@ -3,11 +3,11 @@ {{if eq .SignedUserID .ContextUser.ID}} <a class="image" href="{{AppSubUrl}}/user/settings" data-tooltip-content="{{.locale.Tr "user.change_avatar"}}"> {{/* the size doesn't take affect (and no need to take affect), image size(width) should be controlled by the parent container since this is not a flex layout*/}} - {{avatar $.Context .ContextUser 256}} + {{ctx.AvatarUtils.Avatar .ContextUser 256}} </a> {{else}} <span class="image"> - {{avatar $.Context .ContextUser 256}} + {{ctx.AvatarUtils.Avatar .ContextUser 256}} </span> {{end}} </div> @@ -86,7 +86,7 @@ {{if (or .Visibility.IsPublic (and ($.SignedUser) (or .Visibility.IsLimited (and (.HasMemberWithUserID $.SignedUserID) .Visibility.IsPrivate) ($.IsAdmin))))}} <li> <a href="{{.HomeLink}}" data-tooltip-content="{{.Name}}"> - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}} </a> </li> {{end}} diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 4a8d6c6914..24768439f5 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -2,7 +2,7 @@ {{range .Feeds}} <div class="flex-item"> <div class="flex-item-leading"> - {{avatarByAction $.Context .}} + {{ctx.AvatarUtils.AvatarByAction .}} </div> <div class="flex-item-main gt-gap-3"> <div> diff --git a/templates/user/dashboard/navbar.tmpl b/templates/user/dashboard/navbar.tmpl index 929e85a016..0aa6e4b162 100644 --- a/templates/user/dashboard/navbar.tmpl +++ b/templates/user/dashboard/navbar.tmpl @@ -3,7 +3,7 @@ <div class="item"> <div class="ui floating dropdown jump"> <span class="text truncated-item-container"> - {{avatar $.Context .ContextUser}} + {{ctx.AvatarUtils.Avatar .ContextUser}} <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> <span class="org-visibility"> {{if .ContextUser.Visibility.IsLimited}}<div class="ui basic tiny horizontal label">{{.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}} @@ -17,7 +17,7 @@ </div> <div class="scrolling menu items"> <a class="{{if eq .ContextUser.ID .SignedUser.ID}}active selected{{end}} item truncated-item-container" href="{{AppSubUrl}}/{{if .PageIsIssues}}issues{{else if .PageIsPulls}}pulls{{else if .PageIsMilestonesDashboard}}milestones{{end}}"> - {{avatar $.Context .SignedUser}} + {{ctx.AvatarUtils.Avatar .SignedUser}} <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> <span class="org-visibility"> {{if .SignedUser.Visibility.IsLimited}}<div class="ui basic tiny horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}} @@ -26,7 +26,7 @@ </a> {{range .Orgs}} <a class="{{if eq $.ContextUser.ID .ID}}active selected{{end}} item truncated-item-container" title="{{.Name}}" href="{{.OrganisationLink}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else if $.PageIsMilestonesDashboard}}milestones{{else}}dashboard{{end}}"> - {{avatar $.Context .}} + {{ctx.AvatarUtils.Avatar .}} <span class="truncated-item-name">{{.ShortName 40}}</span> <span class="org-visibility"> {{if .Visibility.IsLimited}}<div class="ui basic tiny horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}} diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index 7a4ea17cb2..be986cd8cf 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -14,7 +14,7 @@ {{range .Orgs}} <div class="flex-item"> <div class="flex-item-leading"> - {{avatar $.Context . 28 "mini"}} + {{ctx.AvatarUtils.Avatar . 28 "mini"}} </div> <div class="flex-item-main"> <div class="flex-item-title">{{template "shared/user/name" .}}</div> |