mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-30 19:48:18 +08:00
truncate all titles in activities
This commit is contained in:
parent
c88fc84538
commit
d88b21fb5e
1 changed files with 10 additions and 7 deletions
|
@ -1,13 +1,16 @@
|
||||||
module ActivityHelper
|
module ActivityHelper
|
||||||
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH)
|
||||||
activity_title = message.match(/<strong>(.*?)<\/strong>/)[1]
|
activity_titles = message.scan(/<strong>(.*?)<\/strong>/)
|
||||||
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
|
activity_titles.each do |activity_title|
|
||||||
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
|
activity_title = activity_title[0]
|
||||||
<span class='modal-tooltiptext'>#{activity_title}</span></div>"
|
if activity_title.length > Constants::NAME_TRUNCATION_LENGTH
|
||||||
else
|
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
|
||||||
title = 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
|
end
|
||||||
message = message.gsub(/#{activity_title}/, title )
|
|
||||||
sanitize_input(message) if message
|
sanitize_input(message) if message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue