2014-11-02 08:57:37 -08:00
|
|
|
module UserHelper
|
2014-11-10 22:09:36 -08:00
|
|
|
# Decides what user name to show.
|
|
|
|
# @return [String] The user name
|
2017-03-30 10:17:25 -07:00
|
|
|
def user_screen_name(user, anonymous: false, url: true, link_only: false)
|
2014-11-11 09:09:28 -08:00
|
|
|
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
|
2021-12-23 13:01:56 -08:00
|
|
|
name = user.profile.display_name.blank? ? user.screen_name : user.profile.display_name
|
2017-03-30 10:17:25 -07:00
|
|
|
if url
|
|
|
|
link = show_user_profile_path(user.screen_name)
|
|
|
|
return link if link_only
|
|
|
|
return link_to(name, link, class: "#{"user--banned" if user.banned?}")
|
|
|
|
end
|
2015-06-09 09:05:35 -07:00
|
|
|
name.strip
|
2014-11-10 22:09:36 -08:00
|
|
|
end
|
2014-11-02 08:57:37 -08:00
|
|
|
end
|