mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 01:55:46 +08:00
FEATURE: Return only the first paragraph of text in HTML digests, unless
there is only one post. In that case return everything. Remove dependency on 'html_truncator'
This commit is contained in:
@ -29,7 +29,14 @@ module UserNotificationsHelper
|
||||
"<a href='#{Discourse.base_url}'>#{@site_name}</a>"
|
||||
end
|
||||
|
||||
def email_excerpt(html)
|
||||
raw Sanitize.clean(HTML_Truncator.truncate(html, 300), Sanitize::Config::RELAXED)
|
||||
def email_excerpt(html, posts_count)
|
||||
# If there's only one post, include the whole thing.
|
||||
if posts_count == 1
|
||||
return raw Sanitize.clean(html, Sanitize::Config::RELAXED)
|
||||
else
|
||||
# Otherwise, try just the first paragraph.
|
||||
first_paragraph = Nokogiri::HTML(html).at('p')
|
||||
return raw Sanitize.clean(first_paragraph.to_s, Sanitize::Config::RELAXED)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user