Fix PeopleHelper#person_link and #person_image_link with frozen strings
This commit is contained in:
parent
e82690963d
commit
a6b6251b53
1 changed files with 14 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue