1
1
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:
wxiaoguang
2023-08-10 11:19:39 +08:00
committed by GitHub
parent 36eb3c433a
commit a370efc13f
54 changed files with 162 additions and 155 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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}}

View File

@@ -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}}