Add categories to the first topics in the email digest
This commit is contained in:
parent
b2cb4b27a1
commit
2341118570
|
@ -68,4 +68,15 @@ module UserNotificationsHelper
|
||||||
def cooked_post_for_email(post)
|
def cooked_post_for_email(post)
|
||||||
PrettyText.format_for_email(post.cooked).html_safe
|
PrettyText.format_for_email(post.cooked).html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def email_category(category)
|
||||||
|
return "" if category.blank? || category.uncategorized?
|
||||||
|
result = ""
|
||||||
|
if category.parent_category.present?
|
||||||
|
result << "<span style='background-color: ##{category.parent_category.color}; font-size: 12px; padding: 4px 2px; font-weight: bold; margin: 0; width: 2px;'> </span>"
|
||||||
|
end
|
||||||
|
result << "<span style='background-color: ##{category.color}; color: ##{category.text_color}; font-size: 12px; padding: 4px 6px; font-weight: bold; margin: 0;'>#{category.name}</span>"
|
||||||
|
result.html_safe
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
<h3><%=t 'user_notifications.digest.top_topics' %></h3>
|
<h3><%=t 'user_notifications.digest.top_topics' %></h3>
|
||||||
|
|
||||||
<%- @featured_topics.each_with_index do |t, i| %>
|
<%- @featured_topics.each_with_index do |t, i| %>
|
||||||
<%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %>
|
<div class='featured-topic'>
|
||||||
|
<%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %>
|
||||||
|
<%= email_category(t.category) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%- if t.best_post.present? %>
|
<%- if t.best_post.present? %>
|
||||||
<div class='digest-post'>
|
<div class='digest-post'>
|
||||||
|
@ -33,12 +36,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %>
|
<%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %>
|
||||||
|
|
||||||
<span class='post-count'><%= t('user_notifications.digest.posts', count: t.posts_count) %></span>
|
<span class='post-count'><%= t('user_notifications.digest.posts', count: t.posts_count) %></span>
|
||||||
|
<%= email_category(t.category) %>
|
||||||
<%- if t.category && !t.category.uncategorized? %>
|
|
||||||
<%- if t.category.parent_category %><span style='background-color: #<%= t.category.parent_category.color %>; font-size: 12px; padding: 4px 2px; font-weight: bold; margin: 0; width: 2px;'> </span><%- end %><span style='background-color: #<%= t.category.color %>; color: #<%= t.category.text_color %>; font-size: 12px; padding: 4px 6px; font-weight: bold; margin: 0;'><%= t.category.name %></span>
|
|
||||||
<%- end %>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Email
|
||||||
def format_html
|
def format_html
|
||||||
style('h3', 'margin: 15px 0 20px 0; border-bottom: 1px solid #ddd;')
|
style('h3', 'margin: 15px 0 20px 0; border-bottom: 1px solid #ddd;')
|
||||||
style('hr', 'background-color: #ddd; height: 1px; border: 1px;')
|
style('hr', 'background-color: #ddd; height: 1px; border: 1px;')
|
||||||
style('a',' text-decoration: none; font-weight: bold; color: #006699;')
|
style('a', 'text-decoration: none; font-weight: bold; color: #006699;')
|
||||||
style('ul', 'margin: 0 0 0 10px; padding: 0 0 0 20px;')
|
style('ul', 'margin: 0 0 0 10px; padding: 0 0 0 20px;')
|
||||||
style('li', 'padding-bottom: 10px')
|
style('li', 'padding-bottom: 10px')
|
||||||
style('div.digest-post', 'margin-left: 15px; margin-top: 20px; max-width: 694px;')
|
style('div.digest-post', 'margin-left: 15px; margin-top: 20px; max-width: 694px;')
|
||||||
|
@ -63,6 +63,7 @@ module Email
|
||||||
style('pre', 'word-wrap: break-word; max-width: 694px;')
|
style('pre', 'word-wrap: break-word; max-width: 694px;')
|
||||||
style('code', 'background-color: #f1f1ff; padding: 2px 5px;')
|
style('code', 'background-color: #f1f1ff; padding: 2px 5px;')
|
||||||
style('pre code', 'display: block; background-color: #f1f1ff; padding: 5px;')
|
style('pre code', 'display: block; background-color: #f1f1ff; padding: 5px;')
|
||||||
|
style('.featured-topic a', 'text-decoration: none; font-weight: bold; color: #006699; margin-right: 5px')
|
||||||
|
|
||||||
# Links to other topics
|
# Links to other topics
|
||||||
style('aside.quote', 'border-left: 5px solid #bebebe; background-color: #f1f1f1; padding: 12px;')
|
style('aside.quote', 'border-left: 5px solid #bebebe; background-color: #f1f1f1; padding: 12px;')
|
||||||
|
|
Loading…
Reference in New Issue