FEATURE: custom html and text can be added to summary emails

This commit is contained in:
Neil Lalonde 2016-08-23 16:06:02 -04:00
parent 4f68fd970d
commit 2f68be2c5c
4 changed files with 57 additions and 4 deletions

View File

@ -70,4 +70,16 @@ module UserNotificationsHelper
PrettyText.format_for_email(html, post).html_safe
end
def digest_custom_html(position_key)
digest_custom "user_notifications.digest.custom.html.#{position_key}"
end
def digest_custom_text(position_key)
digest_custom "user_notifications.digest.custom.text.#{position_key}"
end
def digest_custom(i18n_key)
PrettyText.format_for_email(I18n.t(i18n_key)).html_safe
end
end

View File

@ -1,5 +1,10 @@
<table style="border: 20px solid #eee;" cellspacing="0" cellpadding="0">
<tr>
<%- if I18n.t('user_notifications.digest.custom.html.header').present? %>
<td style="padding: 10px 10px;">
<%= raw(t 'user_notifications.digest.custom.html.header') %>
</td>
<%- else %>
<td style="padding: 10px 10px; background-color: #<%= @header_color %>;">
<a href="<%= Discourse.base_url %>" style='color: #<%= @anchor_color %>'>
<%- if logo_url.blank? %>
@ -9,6 +14,7 @@
<%- end %>
</a>
</td>
<%- end %>
</tr>
<tr>
<td style="background-color: #fff; padding: 10px 10px; font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
@ -32,11 +38,15 @@
</div>
<%- end %>
<%= digest_custom_html("below_post_#{i+1}") %>
<%- if i < @featured_topics.size - 1 %><% end %>
<%- end %>
<%- end %>
<%= digest_custom_html("above_popular_topics") %>
<%- if @new_topics.present? %>
<hr/>
<h3><%=t 'user_notifications.digest.other_new_topics' %></h3>
@ -53,6 +63,8 @@
<%- end -%>
<%= digest_custom_html("below_popular_topics") %>
<%- if @new_topics_since_seen > 0 %>
<%- if @new_by_category.present? %>
<p><%= t('user_notifications.digest.more_topics_category', last_seen_at: @last_seen_at, new_topics_since_seen: @new_topics_since_seen) %></p>
@ -71,8 +83,12 @@
</tr>
</table>
<%= digest_custom_html("above_footer") %>
<div class='footer'>
<%=raw(t 'user_notifications.digest.unsubscribe',
site_link: html_site_link(@anchor_color),
unsubscribe_link: link_to(t('user_notifications.digest.click_here'), email_unsubscribe_url(host: Discourse.base_url_no_prefix, key: @unsubscribe_key), {:style=>"color: ##{@anchor_color}"})) %>
</div>
<%= digest_custom_html("below_footer") %>

View File

@ -6,7 +6,7 @@
<%- if @featured_topics.present? %>
### <%=t 'user_notifications.digest.top_topics' %>
<%- @featured_topics.each do |t| %>
<%- @featured_topics.each_with_index do |t,i| %>
<%= raw(@markdown_linker.create(t.title, t.relative_url)) %>
<%- if t.best_post.present? %>
@ -14,10 +14,10 @@
--------------------------------------------------------------------------------
<%- end %>
<%= digest_custom_text("below_post_#{i+1}") %>
<%- end %>
<%- end %>
<%= digest_custom_text("above_popular_topics") %>
<%- if @new_topics.present? %>
**<%=t 'user_notifications.digest.other_new_topics' %>**
@ -27,12 +27,15 @@
<%- end -%>
<%= digest_custom_text("below_popular_topics") %>
<%= raw(@markdown_linker.references) %>
<%= digest_custom_text("above_footer") %>
<%=raw(t :'user_notifications.digest.unsubscribe',
site_link: site_link,
unsubscribe_link: raw(@markdown_linker.create(t('user_notifications.digest.click_here'), email_unsubscribe_url(key: @unsubscribe_key, only_path: true)))) %>
<%= raw(@markdown_linker.references) %>
<%= digest_custom_text("below_footer") %>

View File

@ -2412,6 +2412,28 @@ en:
read_more: "Read More"
more_topics: "There were %{new_topics_since_seen} other new topics."
more_topics_category: "More new topics:"
custom:
html:
header: ''
below_post_1: ''
below_post_2: ''
below_post_3: ''
below_post_4: ''
below_post_5: ''
above_popular_topics: ''
below_popular_topics: ''
above_footer: ''
below_footer: ''
text:
below_post_1: ''
below_post_2: ''
below_post_3: ''
below_post_4: ''
below_post_5: ''
above_popular_topics: ''
below_popular_topics: ''
above_footer: ''
below_footer: ''
mailing_list:
why: "All activity on %{site_link} for %{date}"