aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/action.go7
-rw-r--r--modules/templates/helper.go17
-rw-r--r--templates/user/dashboard/feeds.tmpl2
3 files changed, 17 insertions, 9 deletions
diff --git a/models/action.go b/models/action.go
index ca186033a6..67c60d84f3 100644
--- a/models/action.go
+++ b/models/action.go
@@ -77,7 +77,8 @@ func (a *Action) GetOpType() ActionType {
return a.OpType
}
-func (a *Action) loadActUser() {
+// LoadActUser loads a.ActUser
+func (a *Action) LoadActUser() {
if a.ActUser != nil {
return
}
@@ -105,13 +106,13 @@ func (a *Action) loadRepo() {
// GetActFullName gets the action's user full name.
func (a *Action) GetActFullName() string {
- a.loadActUser()
+ a.LoadActUser()
return a.ActUser.FullName
}
// GetActUserName gets the action's user name.
func (a *Action) GetActUserName() string {
- a.loadActUser()
+ a.LoadActUser()
return a.ActUser.Name
}
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index f7c10c3698..a7063d7b8d 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -338,11 +338,12 @@ func NewFuncMap() []template.FuncMap {
}
return false
},
- "svg": SVG,
- "avatar": Avatar,
- "avatarHTML": AvatarHTML,
- "avatarByEmail": AvatarByEmail,
- "repoAvatar": RepoAvatar,
+ "svg": SVG,
+ "avatar": Avatar,
+ "avatarHTML": AvatarHTML,
+ "avatarByAction": AvatarByAction,
+ "avatarByEmail": AvatarByEmail,
+ "repoAvatar": RepoAvatar,
"SortArrow": func(normSort, revSort, urlSort string, isDefault bool) template.HTML {
// if needed
if len(normSort) == 0 || len(urlSort) == 0 {
@@ -559,6 +560,12 @@ func Avatar(user *models.User, others ...interface{}) template.HTML {
return template.HTML("")
}
+// AvatarByAction renders user avatars from action. args: action, size (int), class (string)
+func AvatarByAction(action *models.Action, others ...interface{}) template.HTML {
+ action.LoadActUser()
+ return Avatar(action.ActUser, others...)
+}
+
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
func RepoAvatar(repo *models.Repository, others ...interface{}) template.HTML {
size, class := parseOthers(models.DefaultAvatarPixelSize, "ui avatar image", others...)
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 0d9f7de5a7..b28c7c9a0b 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -1,7 +1,7 @@
{{range .Feeds}}
<div class="news">
<div class="ui left">
- {{avatar .ActUser}}
+ {{avatarByAction .}}
</div>
<div class="ui grid">
<div class="ui fourteen wide column">