Commit a6b6251b authored by Benjamin Neff's avatar Benjamin Neff

Fix PeopleHelper#person_link and #person_image_link with frozen strings

parent e8269096
......@@ -26,11 +26,9 @@ module PeopleHelper
end
def person_link(person, opts={})
opts[:class] ||= ""
opts[:class] << " self" if defined?(user_signed_in?) && user_signed_in? && current_user.person == person
opts[:class] << " hovercardable" if defined?(user_signed_in?) && user_signed_in? && current_user.person != person
css_class = person_link_class(person, opts[:class])
remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe
"<a data-hovercard='#{remote_or_hovercard_link}' href='#{remote_or_hovercard_link}' class='#{opts[:class]}'>"\
"<a data-hovercard='#{remote_or_hovercard_link}' href='#{remote_or_hovercard_link}' class='#{css_class}'>"\
"#{html_escape_once(opts[:display_name] || person.name)}</a>"\
.html_safe
end
......@@ -46,11 +44,9 @@ module PeopleHelper
if opts[:to] == :photos
link_to person_image_tag(person, opts[:size]), person_photos_path(person)
else
opts[:class] ||= ""
opts[:class] << " self" if defined?(user_signed_in?) && user_signed_in? && current_user.person == person
opts[:class] << " hovercardable" if defined?(user_signed_in?) && user_signed_in? && current_user.person != person
css_class = person_link_class(person, opts[:class])
remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe
"<a href='#{remote_or_hovercard_link}' class='#{opts[:class]}' #{ ("target=" + opts[:target]) if opts[:target]}>
"<a href='#{remote_or_hovercard_link}' class='#{css_class}' #{('target=' + opts[:target]) if opts[:target]}>
#{person_image_tag(person, opts[:size])}
</a>".html_safe
end
......@@ -79,4 +75,14 @@ module PeopleHelper
return Rails.application.routes.url_helpers.person_path(person, opts)
end
end
private
def person_link_class(person, css_class)
return css_class unless defined?(user_signed_in?) && user_signed_in?
return "#{css_class} self" if current_user.person == person
"#{css_class} hovercardable"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment