summaryrefslogtreecommitdiffstats
path: root/modules/templates
diff options
context:
space:
mode:
Diffstat (limited to 'modules/templates')
-rw-r--r--modules/templates/helper.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 7afc3aa59b..8f8f565c1f 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -25,7 +25,6 @@ import (
activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/models/avatars"
- "code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
@@ -90,8 +89,8 @@ func NewFuncMap() []template.FuncMap {
"AssetVersion": func() string {
return setting.AssetVersion
},
- "DisableGravatar": func() bool {
- return system_model.GetSettingBool(system_model.KeyPictureDisableGravatar)
+ "DisableGravatar": func(ctx context.Context) bool {
+ return system_model.GetSettingBool(ctx, system_model.KeyPictureDisableGravatar)
},
"DefaultShowFullName": func() bool {
return setting.UI.DefaultShowFullName
@@ -613,22 +612,22 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
}
// Avatar renders user avatars. args: user, size (int), class (string)
-func Avatar(item interface{}, others ...interface{}) template.HTML {
+func Avatar(ctx context.Context, item interface{}, others ...interface{}) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
switch t := item.(type) {
case *user_model.User:
- src := t.AvatarLinkWithSize(size * setting.Avatar.RenderedSizeFactor)
+ src := t.AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor)
if src != "" {
return AvatarHTML(src, size, class, t.DisplayName())
}
case *repo_model.Collaborator:
- src := t.AvatarLinkWithSize(size * setting.Avatar.RenderedSizeFactor)
+ src := t.AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor)
if src != "" {
return AvatarHTML(src, size, class, t.DisplayName())
}
case *organization.Organization:
- src := t.AsUser().AvatarLinkWithSize(size * setting.Avatar.RenderedSizeFactor)
+ src := t.AsUser().AvatarLinkWithSize(ctx, size*setting.Avatar.RenderedSizeFactor)
if src != "" {
return AvatarHTML(src, size, class, t.AsUser().DisplayName())
}
@@ -638,9 +637,9 @@ func Avatar(item interface{}, others ...interface{}) template.HTML {
}
// AvatarByAction renders user avatars from action. args: action, size (int), class (string)
-func AvatarByAction(action *activities_model.Action, others ...interface{}) template.HTML {
- action.LoadActUser(db.DefaultContext)
- return Avatar(action.ActUser, others...)
+func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...interface{}) template.HTML {
+ action.LoadActUser(ctx)
+ return Avatar(ctx, action.ActUser, others...)
}
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
@@ -655,9 +654,9 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
}
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
-func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
+func AvatarByEmail(ctx context.Context, email, name string, others ...interface{}) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
- src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
+ src := avatars.GenerateEmailAvatarFastLink(ctx, email, size*setting.Avatar.RenderedSizeFactor)
if src != "" {
return AvatarHTML(src, size, class, name)