In email digests, try to get longer excerpts if we don't have enough
characters from the first paragraph.
This commit is contained in:
parent
0b6bd5c187
commit
d3b2f87f8e
|
@ -39,9 +39,15 @@ module UserNotificationsHelper
|
|||
|
||||
def first_paragraph_from(html)
|
||||
doc = Nokogiri::HTML(html)
|
||||
|
||||
result = ""
|
||||
doc.css('p').each do |p|
|
||||
return p if p.text.present?
|
||||
if p.text.present?
|
||||
result << p.to_s
|
||||
return result if result.size >= 100
|
||||
end
|
||||
end
|
||||
return result unless result.blank?
|
||||
|
||||
# If there is no first paragaph, return the first div (onebox)
|
||||
doc.css('div').first
|
||||
|
@ -54,7 +60,7 @@ module UserNotificationsHelper
|
|||
else
|
||||
# Otherwise, try just the first paragraph.
|
||||
para = first_paragraph_from(html)
|
||||
raw Sanitize.clean(para.to_s, UserNotificationsHelper.sanitize_options)
|
||||
raw Sanitize.clean(para, UserNotificationsHelper.sanitize_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -785,6 +785,7 @@ en:
|
|||
|
||||
allow_uploaded_avatars: "Allow users to upload their custom avatars"
|
||||
allow_animated_avatars: "Allow users to use animated gif for avatars. WARNING: it is highly recommended to run the avatars:regenerate rake task after changing that setting."
|
||||
digest_min_excerpt_length: "How many characters we're aiming for for each post in the email digest"
|
||||
default_digest_email_frequency: "How often users receive digest emails by default. They can change this setting in their preferences."
|
||||
default_external_links_in_new_tab: "Open external links in a new tab. Users can change this in their preferences."
|
||||
|
||||
|
|
|
@ -213,6 +213,7 @@ posting:
|
|||
email:
|
||||
email_time_window_mins: 10
|
||||
email_posts_context: 5
|
||||
digest_min_excerpt_length: 100
|
||||
default_digest_email_frequency:
|
||||
default: 7
|
||||
enum: 'DigestEmailSiteSetting'
|
||||
|
|
Loading…
Reference in New Issue