debian-mirror-gitlab/app/helpers/avatars_helper.rb

31 lines
886 B
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05: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,
2016-11-03 12:29:30 +05:30
css_class: 'hidden-xs'
2016-08-24 12:49:21 +05:30
}))
end
def user_avatar(options = {})
avatar_size = options[:size] || 16
user_name = options[:user].try(:name) || options[:user_name]
2016-11-03 12:29:30 +05:30
css_class = options[:css_class] || ''
2016-08-24 12:49:21 +05:30
avatar = image_tag(
avatar_icon(options[:user] || options[:user_email], avatar_size),
2016-11-03 12:29:30 +05:30
class: "avatar has-tooltip s#{avatar_size} #{css_class}",
2016-08-24 12:49:21 +05:30
alt: "#{user_name}'s avatar",
2016-09-29 09:46:39 +05:30
title: user_name,
data: { container: 'body' }
2016-08-24 12:49:21 +05:30
)
if options[:user]
link_to(avatar, user_path(options[:user]))
elsif options[:user_email]
mail_to(options[:user_email], avatar)
end
end
end