Skip to content

Use template context function for avatar rendering #26385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
30 changes: 19 additions & 11 deletions modules/templates/util_avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ""
}
5 changes: 3 additions & 2 deletions routers/web/repo/blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions templates/base/head_navbar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion templates/explore/users.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion templates/org/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions templates/org/home.tmpl
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion templates/org/member/members.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion templates/org/team/invite.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion templates/org/team/members.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion templates/org/team/teams.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion templates/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/actions/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/branch/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}} &nbsp;{{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}} &nbsp;{{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)}}
Expand Down Expand Up @@ -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}} &nbsp;{{template "shared/user/avatarlink" dict "Context" $.Context "user" .DBBranch.Pusher}} &nbsp;{{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}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
{{end}}
</td>
<td class="two wide ui">
Expand Down
12 changes: 6 additions & 6 deletions templates/repo/commit_page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/commits_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/commits_list_small.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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)}}
Expand Down
6 changes: 3 additions & 3 deletions templates/repo/create.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/diff/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/editor/commit_form.tmpl
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/forks.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/graph/commits.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/filters.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading