summaryrefslogtreecommitdiffstats
path: root/templates/shared
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-08-10 11:19:39 +0800
committerGitHub <noreply@github.com>2023-08-10 11:19:39 +0800
commita370efc13f0e1ea309e324639832832bc14cb6dc (patch)
tree3c408cf225a4ffcc49f257fabf162831c92e23bf /templates/shared
parent36eb3c433ae384f21beec63eb648141fb9dba676 (diff)
downloadgitea-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.
Diffstat (limited to 'templates/shared')
-rw-r--r--templates/shared/issuelist.tmpl2
-rw-r--r--templates/shared/user/avatarlink.tmpl2
-rw-r--r--templates/shared/user/org_profile_avatar.tmpl2
-rw-r--r--templates/shared/user/profile_big_avatar.tmpl6
4 files changed, 6 insertions, 6 deletions
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}}