mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: More granular mailing list mode (#4068)
* Rearrange frontend to account for mailing list mode * Allow update of user preference for mailing list frequency * Add mailing list frequency estimate * Simplify frequency estimate; disable activity summary for mailing list mode * Remove combined updates * Add specs for enqueue mailing list mode job * Write mailing list method for mailer * Fix linting error * Account for stale topics * Add translations for default mailing list setting * One query for mailing list topics * Fix failing spec * WIP * Flesh out html template * First pass at text-based mailing list summary * Add user avatar * Properly format posts for mailing list * Move make_all_links_absolute into Email::Styles * Apply first_seen_at to user * Send mailing list email summary hourly based on first_seen_at * Branch and test cleanup * Use existing mailing list mode estimate * Fix failing specs
This commit is contained in:
parent
4eeae880b6
commit
feffe23cc5
28 changed files with 567 additions and 79 deletions
|
@ -386,31 +386,16 @@ module PrettyText
|
|||
fragment.to_html
|
||||
end
|
||||
|
||||
# Given a Nokogiri doc, convert all links to absolute
|
||||
def self.make_all_links_absolute(doc)
|
||||
site_uri = nil
|
||||
doc.css("a").each do |link|
|
||||
href = link["href"].to_s
|
||||
begin
|
||||
uri = URI(href)
|
||||
site_uri ||= URI(Discourse.base_url)
|
||||
link["href"] = "#{site_uri}#{link['href']}" unless uri.host.present?
|
||||
rescue URI::InvalidURIError, URI::InvalidComponentError
|
||||
# leave it
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.strip_image_wrapping(doc)
|
||||
doc.css(".lightbox-wrapper .meta").remove
|
||||
end
|
||||
|
||||
def self.format_for_email(html, post = nil)
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
DiscourseEvent.trigger(:reduce_cooked, doc, post)
|
||||
make_all_links_absolute(doc)
|
||||
strip_image_wrapping(doc)
|
||||
doc.to_html
|
||||
def self.format_for_email(html, post = nil, style: nil)
|
||||
Email::Styles.new(html, style: style).tap do |doc|
|
||||
doc.make_all_links_absolute
|
||||
doc.send :"format_#{style}" if style
|
||||
DiscourseEvent.trigger(:reduce_cooked, doc, post)
|
||||
end.to_html
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue