diff options
author | winniehell <git@winniehell.de> | 2016-07-09 02:47:05 +0200 |
---|---|---|
committer | winniehell <git@winniehell.de> | 2016-07-20 17:44:28 +0200 |
commit | 6558586f15f493968129b78544d76486cd2a6cd4 (patch) | |
tree | 21eb690f24c215413882f1e037779671198b08f8 /app/helpers/avatars_helper.rb | |
parent | dc761e3a0a7bf9ff4feddc4785113df33a585cd2 (diff) | |
download | gitlab-ce-6558586f15f493968129b78544d76486cd2a6cd4.tar.gz |
Add link to user profile to commit avatar (!5163)
Diffstat (limited to 'app/helpers/avatars_helper.rb')
-rw-r--r-- | app/helpers/avatars_helper.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb new file mode 100644 index 00000000000..6ff40c6b461 --- /dev/null +++ b/app/helpers/avatars_helper.rb @@ -0,0 +1,30 @@ +module AvatarsHelper + + def author_avatar(commit_or_event, options = {}) + user_avatar(options.merge({ + user: commit_or_event.author, + user_name: commit_or_event.author_name, + user_email: commit_or_event.author_email, + })) + end + + private + + def user_avatar(options = {}) + avatar_size = options[:size] || 16 + user_name = options[:user].try(:name) || options[:user_name] + avatar = image_tag( + avatar_icon(options[:user] || options[:user_email], avatar_size), + class: "avatar has-tooltip hidden-xs s#{avatar_size}", + alt: "#{user_name}'s avatar", + title: user_name + ) + + if options[:user] + link_to(avatar, user_path(options[:user])) + elsif options[:user_email] + mail_to(options[:user_email], avatar) + end + end + +end |