truncate all titles in activities

This commit is contained in:
Mojca Lorber 2017-06-01 15:09:01 +02:00
parent c88fc84538
commit d88b21fb5e

View file

@ -1,13 +1,16 @@
module ActivityHelper
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
activity_title = message.match(/<strong>(.*?)<\/strong>/)[1]
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
<span class='modal-tooltiptext'>#{activity_title}</span></div>"
else
title = truncate(activity_title, length: len)
activity_titles = message.scan(/<strong>(.*?)<\/strong>/)
activity_titles.each do |activity_title|
activity_title = activity_title[0]
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
<span class='modal-tooltiptext'>#{activity_title}</span></div>"
else
title = truncate(activity_title, length: len)
end
message = message.gsub(/#{activity_title}/, title )
end
message = message.gsub(/#{activity_title}/, title )
sanitize_input(message) if message
end