2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-07-30 15:05:08 -04:00
|
|
|
require 'erb'
|
|
|
|
|
2017-04-24 15:26:06 -04:00
|
|
|
module EmailHelper
|
|
|
|
|
|
|
|
def mailing_list_topic(topic, post_count)
|
|
|
|
render(
|
|
|
|
partial: partial_for("mailing_list_post"),
|
|
|
|
locals: { topic: topic, post_count: post_count }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def mailing_list_topic_text(topic)
|
|
|
|
url, title = extract_details(topic)
|
|
|
|
raw(@markdown_linker.create(title, url))
|
|
|
|
end
|
|
|
|
|
|
|
|
def private_topic_title(topic)
|
2017-04-27 11:45:49 -04:00
|
|
|
I18n.t("system_messages.private_topic_title", id: topic.id)
|
2017-04-24 15:26:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def email_topic_link(topic)
|
|
|
|
url, title = extract_details(topic)
|
|
|
|
raw "<a href='#{Discourse.base_url}#{url}' style='color: ##{@anchor_color}'>#{title}</a>"
|
|
|
|
end
|
|
|
|
|
2020-05-23 00:56:13 -04:00
|
|
|
def email_html_template
|
2020-07-13 10:39:40 -04:00
|
|
|
EmailStyle.new.html
|
2021-07-05 16:40:52 -04:00
|
|
|
.sub('%{email_content}') { capture { yield } }
|
2020-07-13 10:39:40 -04:00
|
|
|
.gsub('%{html_lang}', html_lang)
|
|
|
|
.html_safe
|
2019-07-30 15:05:08 -04:00
|
|
|
end
|
|
|
|
|
2017-04-24 15:26:06 -04:00
|
|
|
protected
|
|
|
|
|
|
|
|
def extract_details(topic)
|
|
|
|
if SiteSetting.private_email?
|
|
|
|
[topic.slugless_url, private_topic_title(topic)]
|
|
|
|
else
|
|
|
|
[topic.relative_url, format_topic_title(topic.title)]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def partial_for(name)
|
|
|
|
SiteSetting.private_email? ? "email/secure_#{name}" : "email/#{name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|