Skip to content

Commit a370efc

Browse files
authored
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.
1 parent 36eb3c4 commit a370efc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+162
-155
lines changed

modules/context/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func Contexter() func(next http.Handler) http.Handler {
141141
// TODO: "install.go" also shares the same logic, which should be refactored to a general function
142142
ctx.TemplateContext = NewTemplateContext(ctx)
143143
ctx.TemplateContext["Locale"] = ctx.Locale
144+
ctx.TemplateContext["AvatarUtils"] = templates.NewAvatarUtils(ctx)
144145

145146
ctx.Data.MergeFrom(middleware.CommonTemplateContextData())
146147
ctx.Data["Context"] = ctx // TODO: use "ctx" in template and remove this

modules/templates/helper.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,11 @@ func NewFuncMap() template.FuncMap {
5252

5353
// -----------------------------------------------------------------
5454
// svg / avatar / icon
55-
"svg": svg.RenderHTML,
56-
"avatar": Avatar,
57-
"avatarHTML": AvatarHTML,
58-
"avatarByAction": AvatarByAction,
59-
"avatarByEmail": AvatarByEmail,
60-
"EntryIcon": base.EntryIcon,
61-
"MigrationIcon": MigrationIcon,
62-
"ActionIcon": ActionIcon,
55+
"svg": svg.RenderHTML,
56+
"avatarHTML": AvatarHTML,
57+
"EntryIcon": base.EntryIcon,
58+
"MigrationIcon": MigrationIcon,
59+
"ActionIcon": ActionIcon,
6360

6461
"SortArrow": SortArrow,
6562

modules/templates/util_avatar.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import (
1818
"code.gitea.io/gitea/modules/setting"
1919
)
2020

21+
type AvatarUtils struct {
22+
ctx context.Context
23+
}
24+
25+
func NewAvatarUtils(ctx context.Context) *AvatarUtils {
26+
return &AvatarUtils{ctx: ctx}
27+
}
28+
2129
// AvatarHTML creates the HTML for an avatar
2230
func AvatarHTML(src string, size int, class, name string) template.HTML {
2331
sizeStr := fmt.Sprintf(`%d`, size)
@@ -30,44 +38,44 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
3038
}
3139

3240
// Avatar renders user avatars. args: user, size (int), class (string)
33-
func Avatar(ctx context.Context, item any, others ...any) template.HTML {
41+
func (au *AvatarUtils) Avatar(item any, others ...any) template.HTML {
3442
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
3543

3644
switch t := item.(type) {
3745
case *user_model.User:
38-
src := t.AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor)
46+
src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
3947
if src != "" {
4048
return AvatarHTML(src, size, class, t.DisplayName())
4149
}
4250
case *repo_model.Collaborator:
43-
src := t.AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor)
51+
src := t.AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
4452
if src != "" {
4553
return AvatarHTML(src, size, class, t.DisplayName())
4654
}
4755
case *organization.Organization:
48-
src := t.AsUser().AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor)
56+
src := t.AsUser().AvatarLinkWithSize(au.ctx, size*setting.Avatar.RenderedSizeFactor)
4957
if src != "" {
5058
return AvatarHTML(src, size, class, t.AsUser().DisplayName())
5159
}
5260
}
5361

54-
return template.HTML("")
62+
return ""
5563
}
5664

5765
// AvatarByAction renders user avatars from action. args: action, size (int), class (string)
58-
func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...any) template.HTML {
59-
action.LoadActUser(ctx)
60-
return Avatar(ctx, action.ActUser, others...)
66+
func (au *AvatarUtils) AvatarByAction(action *activities_model.Action, others ...any) template.HTML {
67+
action.LoadActUser(au.ctx)
68+
return au.Avatar(action.ActUser, others...)
6169
}
6270

6371
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
64-
func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML {
72+
func (au *AvatarUtils) AvatarByEmail(email, name string, others ...any) template.HTML {
6573
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
66-
src := avatars.GenerateEmailAvatarFastLink(ctx, email, size*setting.Avatar.RenderedSizeFactor)
74+
src := avatars.GenerateEmailAvatarFastLink(au.ctx, email, size*setting.Avatar.RenderedSizeFactor)
6775

6876
if src != "" {
6977
return AvatarHTML(src, size, class, name)
7078
}
7179

72-
return template.HTML("")
80+
return ""
7381
}

routers/web/repo/blame.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
235235

236236
var lexerName string
237237

238+
avatarUtils := templates.NewAvatarUtils(ctx)
238239
i := 0
239240
commitCnt := 0
240241
for _, part := range blameParts {
@@ -257,9 +258,9 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
257258

258259
var avatar string
259260
if commit.User != nil {
260-
avatar = string(templates.Avatar(ctx, commit.User, 18, "gt-mr-3"))
261+
avatar = string(avatarUtils.Avatar(commit.User, 18, "gt-mr-3"))
261262
} else {
262-
avatar = string(templates.AvatarByEmail(ctx, commit.Author.Email, commit.Author.Name, 18, "gt-mr-3"))
263+
avatar = string(avatarUtils.AvatarByEmail(commit.Author.Email, commit.Author.Name, 18, "gt-mr-3"))
263264
}
264265

265266
br.Avatar = gotemplate.HTML(avatar)

templates/base/head_navbar.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
{{if and .IsSigned .MustChangePassword}}
5858
<div class="ui dropdown jump item" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}">
5959
<span class="text gt-df gt-ac">
60-
{{avatar $.Context .SignedUser 24 "gt-mr-2"}}
60+
{{ctx.AvatarUtils.Avatar .SignedUser 24 "gt-mr-2"}}
6161
<span class="mobile-only gt-ml-3">{{.SignedUser.Name}}</span>
6262
<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
6363
</span>
@@ -143,7 +143,7 @@
143143

144144
<div class="ui dropdown jump item gt-mx-0 gt-pr-3" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}">
145145
<span class="text gt-df gt-ac">
146-
{{avatar $.Context .SignedUser 24 "gt-mr-2"}}
146+
{{ctx.AvatarUtils.Avatar .SignedUser 24 "gt-mr-2"}}
147147
<span class="mobile-only gt-ml-3">{{.SignedUser.Name}}</span>
148148
<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
149149
</span>

templates/explore/users.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{range .Users}}
99
<div class="flex-item flex-item-center">
1010
<div class="flex-item-leading">
11-
{{avatar $.Context . 48}}
11+
{{ctx.AvatarUtils.Avatar . 48}}
1212
</div>
1313
<div class="flex-item-main">
1414
<div class="flex-item-title">

templates/org/header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="ui vertically grid head">
44
<div class="column">
55
<div class="ui header">
6-
{{avatar $.Context . 100}}
6+
{{ctx.AvatarUtils.Avatar . 100}}
77
<span class="text thin grey"><a href="{{.HomeLink}}">{{.DisplayName}}</a></span>
88
<span class="org-visibility">
99
{{if .Visibility.IsLimited}}<div class="ui medium basic horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}}

templates/org/home.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{template "base/head" .}}
22
<div role="main" aria-label="{{.Title}}" class="page-content organization profile">
33
<div class="ui container gt-df">
4-
{{avatar $.Context .Org 140 "org-avatar"}}
4+
{{ctx.AvatarUtils.Avatar .Org 140 "org-avatar"}}
55
<div id="org-info">
66
<div class="ui header gt-df gt-fw">
77
{{.Org.DisplayName}}
@@ -61,7 +61,7 @@
6161
{{$isMember := .IsOrganizationMember}}
6262
{{range .Members}}
6363
{{if or $isMember (call $.IsPublicMember .ID)}}
64-
<a href="{{.HomeLink}}" title="{{.Name}}{{if .FullName}} ({{.FullName}}){{end}}">{{avatar $.Context . 48}}</a>
64+
<a href="{{.HomeLink}}" title="{{.Name}}{{if .FullName}} ({{.FullName}}){{end}}">{{ctx.AvatarUtils.Avatar . 48}}</a>
6565
{{end}}
6666
{{end}}
6767
</div>

templates/org/member/members.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{$isPublic := index $.MembersIsPublicMember .ID}}
1010
<div class="flex-item {{if $.PublicOnly}}flex-item-center{{end}}">
1111
<div class="flex-item-leading">
12-
<a href="{{.HomeLink}}">{{avatar $.Context . 48}}</a>
12+
<a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 48}}</a>
1313
</div>
1414
<div class="flex-item-main">
1515
<div class="flex-item-title">

templates/org/team/invite.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{template "base/alert" .}}
55
<div class="ui centered card">
66
<div class="image">
7-
{{avatar $.Context .Organization 140}}
7+
{{ctx.AvatarUtils.Avatar .Organization 140}}
88
</div>
99
<div class="content">
1010
<div class="header">{{.locale.Tr "org.teams.invite.title" .Team.Name .Organization.Name | Str2html}}</div>

templates/org/team/members.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{{range .Team.Members}}
2727
<div class="flex-item flex-item-center">
2828
<div class="flex-item-leading">
29-
<a href="{{.HomeLink}}">{{avatar $.Context . 32}}</a>
29+
<a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 32}}</a>
3030
</div>
3131
<div class="flex-item-main">
3232
<div class="flex-item-title">

templates/org/team/teams.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</div>
3333
<div class="ui attached segment members">
3434
{{range .Members}}
35-
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .}}
35+
{{template "shared/user/avatarlink" dict "user" .}}
3636
{{end}}
3737
</div>
3838
<div class="ui bottom attached header">

templates/projects/view.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
{{end}}
235235
<div class="right floated">
236236
{{range .Assignees}}
237-
<a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{avatar $.Context . 28 "mini gt-mr-3"}}</a>
237+
<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>
238238
{{end}}
239239
</div>
240240
</div>

templates/repo/actions/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</a>
3434
{{range .Actors}}
3535
<a class="item{{if eq .ID $.CurActor}} active{{end}}" href="{{$.Link}}?workflow={{$.CurWorkflow}}&actor={{.ID}}&status={{$.CurStatus}}">
36-
{{avatar $.Context . 20}} {{.GetDisplayName}}
36+
{{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}}
3737
</a>
3838
{{end}}
3939
</div>

templates/repo/branch/list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
2828
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
2929
</div>
30-
<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}} &nbsp;{{template "shared/user/avatarlink" dict "Context" $.Context "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
30+
<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}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
3131
</td>
3232
<td class="right aligned middle aligned overflow-visible">
3333
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
@@ -94,7 +94,7 @@
9494
<button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
9595
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
9696
</div>
97-
<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}} &nbsp;{{template "shared/user/avatarlink" dict "Context" $.Context "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
97+
<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}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
9898
{{end}}
9999
</td>
100100
<td class="two wide ui">

templates/repo/commit_page.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,24 +142,24 @@
142142
<div class="ui attached segment gt-df gt-ac gt-sb gt-py-2 commit-header-row gt-fw {{$class}}">
143143
<div class="gt-df gt-ac author">
144144
{{if .Author}}
145-
{{avatar $.Context .Author 28 "gt-mr-3"}}
145+
{{ctx.AvatarUtils.Avatar .Author 28 "gt-mr-3"}}
146146
{{if .Author.FullName}}
147147
<a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a>
148148
{{else}}
149149
<a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a>
150150
{{end}}
151151
{{else}}
152-
{{avatarByEmail $.Context .Commit.Author.Email .Commit.Author.Email 28 "gt-mr-3"}}
152+
{{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "gt-mr-3"}}
153153
<strong>{{.Commit.Author.Name}}</strong>
154154
{{end}}
155155
<span class="text grey gt-ml-3" id="authored-time">{{TimeSince .Commit.Author.When $.locale}}</span>
156156
{{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}}
157157
<span class="text grey gt-mx-3">{{.locale.Tr "repo.diff.committed_by"}}</span>
158158
{{if ne .Verification.CommittingUser.ID 0}}
159-
{{avatar $.Context .Verification.CommittingUser 28 "gt-mx-3"}}
159+
{{ctx.AvatarUtils.Avatar .Verification.CommittingUser 28 "gt-mx-3"}}
160160
<a href="{{.Verification.CommittingUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a>
161161
{{else}}
162-
{{avatarByEmail $.Context .Commit.Committer.Email .Commit.Committer.Name 28 "gt-mr-3"}}
162+
{{ctx.AvatarUtils.AvatarByEmail .Commit.Committer.Email .Commit.Committer.Name 28 "gt-mr-3"}}
163163
<strong>{{.Commit.Committer.Name}}</strong>
164164
{{end}}
165165
{{end}}
@@ -196,12 +196,12 @@
196196
{{else}}
197197
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
198198
{{end}}
199-
{{avatar $.Context .Verification.SigningUser 28 "gt-mr-3"}}
199+
{{ctx.AvatarUtils.Avatar .Verification.SigningUser 28 "gt-mr-3"}}
200200
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a>
201201
{{else}}
202202
<span title="{{.locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog" 16 "gt-mr-3"}}</span>
203203
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.signed_by"}}:</span>
204-
{{avatarByEmail $.Context .Verification.SigningEmail "" 28}}
204+
{{ctx.AvatarUtils.AvatarByEmail .Verification.SigningEmail "" 28}}
205205
<strong>{{.Verification.SigningUser.GetDisplayName}}</strong>
206206
{{end}}
207207
{{else}}

templates/repo/commits_list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
{{if .User.FullName}}
1919
{{$userName = .User.FullName}}
2020
{{end}}
21-
{{avatar $.Context .User 28 "gt-mr-2"}}<a href="{{.User.HomeLink}}">{{$userName}}</a>
21+
{{ctx.AvatarUtils.Avatar .User 28 "gt-mr-2"}}<a href="{{.User.HomeLink}}">{{$userName}}</a>
2222
{{else}}
23-
{{avatarByEmail $.Context .Author.Email .Author.Name 28 "gt-mr-2"}}
23+
{{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "gt-mr-2"}}
2424
{{$userName}}
2525
{{end}}
2626
</td>

templates/repo/commits_list_small.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<div class="singular-commit" id="{{$tag}}">
77
<span class="badge badge-commit">{{svg "octicon-git-commit"}}</span>
88
{{if .User}}
9-
<a class="avatar" href="{{.User.HomeLink}}">{{avatar $.root.Context .User}}</a>
9+
<a class="avatar" href="{{.User.HomeLink}}">{{ctx.AvatarUtils.Avatar .User}}</a>
1010
{{else}}
11-
{{avatarByEmail $.root.Context .Author.Email .Author.Name}}
11+
{{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name}}
1212
{{end}}
1313

1414
{{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}}

templates/repo/create.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
<div class="ui selection owner dropdown">
2222
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
2323
<span class="text truncated-item-container" title="{{.ContextUser.Name}}">
24-
{{avatar $.Context .ContextUser 28 "mini"}}
24+
{{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}}
2525
<span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span>
2626
</span>
2727
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
2828
<div class="menu">
2929
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}">
30-
{{avatar $.Context .SignedUser 28 "mini"}}
30+
{{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}}
3131
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
3232
</div>
3333
{{range .Orgs}}
3434
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
35-
{{avatar $.Context . 28 "mini"}}
35+
{{ctx.AvatarUtils.Avatar . 28 "mini"}}
3636
<span class="truncated-item-name">{{.ShortName 40}}</span>
3737
</div>
3838
{{end}}

templates/repo/diff/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{if .OriginalAuthor}}
66
<span class="avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span>
77
{{else}}
8-
{{template "shared/user/avatarlink" dict "Context" $.root.Context "user" .Poster}}
8+
{{template "shared/user/avatarlink" dict "user" .Poster}}
99
{{end}}
1010
<div class="content comment-container">
1111
<div class="ui top attached header comment-header gt-df gt-ac gt-sb">

templates/repo/editor/commit_form.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="commit-form-wrapper">
2-
{{avatar $.Context .SignedUser 48 "commit-avatar"}}
2+
{{ctx.AvatarUtils.Avatar .SignedUser 48 "commit-avatar"}}
33
<div class="commit-form">
44
<h3>{{- if .CanCommitToBranch.WillSign}}
55
<span title="{{.locale.Tr "repo.signing.will_sign" .CanCommitToBranch.SigningKey}}">{{svg "octicon-lock" 24}}</span>

templates/repo/forks.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</h2>
88
{{range .Forks}}
99
<div class="gt-df gt-ac gt-py-3">
10-
<span class="gt-mr-2">{{avatar $.Context .Owner}}</span>
10+
<span class="gt-mr-2">{{ctx.AvatarUtils.Avatar .Owner}}</span>
1111
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="{{.Link}}">{{.Name}}</a>
1212
</div>
1313
{{end}}

templates/repo/graph/commits.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464
{{if $commit.User.FullName}}
6565
{{$userName = $commit.User.FullName}}
6666
{{end}}
67-
<span class="gt-mr-2">{{avatar $.Context $commit.User}}</span>
67+
<span class="gt-mr-2">{{ctx.AvatarUtils.Avatar $commit.User}}</span>
6868
<a href="{{$commit.User.HomeLink}}">{{$userName}}</a>
6969
{{else}}
70-
<span class="gt-mr-2">{{avatarByEmail $.Context $commit.Commit.Author.Email $userName}}</span>
70+
<span class="gt-mr-2">{{ctx.AvatarUtils.AvatarByEmail $commit.Commit.Author.Email $userName}}</span>
7171
{{$userName}}
7272
{{end}}
7373
</span>

templates/repo/issue/filters.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
<div class="divider"></div>
147147
{{range .Assignees}}
148148
<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}}">
149-
{{avatar $.Context . 20}}{{template "repo/search_name" .}}
149+
{{ctx.AvatarUtils.Avatar . 20}}{{template "repo/search_name" .}}
150150
</a>
151151
{{end}}
152152
</div>

0 commit comments

Comments
 (0)