mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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.
This commit is contained in:
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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}}
|
||||
|
@@ -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}}
|
||||
|
Reference in New Issue
Block a user