diff --git a/app/helpers/user_notifications_helper.rb b/app/helpers/user_notifications_helper.rb index a08366feb59..e36dc33c65b 100644 --- a/app/helpers/user_notifications_helper.rb +++ b/app/helpers/user_notifications_helper.rb @@ -68,4 +68,15 @@ module UserNotificationsHelper def cooked_post_for_email(post) PrettyText.format_for_email(post.cooked).html_safe 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 diff --git a/app/views/user_notifications/digest.html.erb b/app/views/user_notifications/digest.html.erb index 0323f69e2e9..ba8fa42fdf6 100644 --- a/app/views/user_notifications/digest.html.erb +++ b/app/views/user_notifications/digest.html.erb @@ -13,7 +13,10 @@ <h3><%=t 'user_notifications.digest.top_topics' %></h3> <%- @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? %> <div class='digest-post'> @@ -33,12 +36,8 @@ <ul> <li> <%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %> - <span class='post-count'><%= t('user_notifications.digest.posts', count: t.posts_count) %></span> - - <%- 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 %> + <%= email_category(t.category) %> </li> </ul> <%- end -%> diff --git a/lib/email/styles.rb b/lib/email/styles.rb index d1f2be693ff..88cbbeeafb4 100644 --- a/lib/email/styles.rb +++ b/lib/email/styles.rb @@ -53,7 +53,7 @@ module Email def format_html style('h3', 'margin: 15px 0 20px 0; border-bottom: 1px solid #ddd;') 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('li', 'padding-bottom: 10px') 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('code', 'background-color: #f1f1ff; padding: 2px 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 style('aside.quote', 'border-left: 5px solid #bebebe; background-color: #f1f1f1; padding: 12px;')