2016-07-21 19:11:15 +08:00
|
|
|
module ActivityHelper
|
2016-10-05 23:45:20 +08:00
|
|
|
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
2017-06-01 21:09:01 +08:00
|
|
|
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
|
2017-06-05 22:07:21 +08:00
|
|
|
title = "<div class='modal-tooltip'>
|
|
|
|
#{truncate(activity_title, length: len)}
|
|
|
|
<span class='modal-tooltiptext'>
|
|
|
|
#{activity_title}
|
|
|
|
</span>
|
|
|
|
</div>"
|
2017-06-01 21:09:01 +08:00
|
|
|
else
|
|
|
|
title = truncate(activity_title, length: len)
|
|
|
|
end
|
2017-06-05 22:07:21 +08:00
|
|
|
message = message.gsub(/#{Regexp.escape(activity_title)}/, title)
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|
2017-01-04 00:27:22 +08:00
|
|
|
sanitize_input(message) if message
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|
2017-01-12 21:47:15 +08:00
|
|
|
|
|
|
|
def days_since_1970(dt)
|
|
|
|
dt.to_i / 86400
|
|
|
|
end
|
2016-07-21 19:11:15 +08:00
|
|
|
end
|