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 | |
parent | dc761e3a0a7bf9ff4feddc4785113df33a585cd2 (diff) | |
download | gitlab-ce-6558586f15f493968129b78544d76486cd2a6cd4.tar.gz |
Add link to user profile to commit avatar (!5163)
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/avatars_helper.rb | 30 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 10 |
2 files changed, 30 insertions, 10 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 diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 474041eccbb..052ce56809e 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -16,16 +16,6 @@ module CommitsHelper commit_person_link(commit, options.merge(source: :committer)) end - def commit_author_avatar(commit, options = {}) - options = options.merge(source: :author) - user = commit.send(options[:source]) - - source_email = clean(commit.send "#{options[:source]}_email".to_sym) - person_email = user.try(:email) || source_email - - image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]} hidden-xs", width: options[:size], alt: "") - end - def image_diff_class(diff) if diff.deleted_file "deleted" |