diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index e627ccbde..101cb4fb5 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -44,6 +44,10 @@ class UserNotifications < ActionMailer::Base # Don't send email unless there is content in it if @featured_topics.present? @featured_topics, @new_topics = @featured_topics[0..4], @featured_topics[5..-1] + + # Sort the new topics by score + @new_topics.sort! {|a, b| b.score - a.score } if @new_topics.present? + @markdown_linker = MarkdownLinker.new(Discourse.base_url) build_email user.email, diff --git a/app/views/user_notifications/digest.html.erb b/app/views/user_notifications/digest.html.erb index 193789732..d53cf14ba 100644 --- a/app/views/user_notifications/digest.html.erb +++ b/app/views/user_notifications/digest.html.erb @@ -31,7 +31,13 @@ <%- @new_topics.each do |t| %> <ul> - <li><%= link_to t.title, t.relative_url %> <%- if t.category %>[<%= t.category.name %>]<%- end %></li> + <li> + <%= link_to t.title, t.relative_url %> + + <span class='post-count'><%= t('user_notifications.digest.posts', count: t.posts_count) %></span> + + <%- if t.category %><span style='background-color: #<%= t.category.color %>; color: #<%= t.category.text_color %>; font-size: 12px; padding: 4px 6px; font-weight: bold'><%= t.category.name %></span><%- end %> + </li> </ul> <%- end -%> diff --git a/app/views/user_notifications/digest.text.erb b/app/views/user_notifications/digest.text.erb index edf9622dd..f05ed22ff 100644 --- a/app/views/user_notifications/digest.text.erb +++ b/app/views/user_notifications/digest.text.erb @@ -25,7 +25,7 @@ **<%=t 'user_notifications.digest.other_new_topics' %>** <%- @new_topics.each do |t| %> -* <%= raw(@markdown_linker.create(t.title, t.relative_url)) %> <%- if t.category %>[<%= t.category.name %>]<%- end %> +* <%= raw(@markdown_linker.create(t.title, t.relative_url)) %> - <%= t('user_notifications.digest.posts', count: t.posts_count) %> - <%- if t.category %>[<%= t.category.name %>]<%- end %> <%- end -%> <%- end -%> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 876834c04..2fa9124ea 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -79,7 +79,7 @@ en: education: until_posts: - one: "post" + one: "1 post" other: "%{count} posts" 'new-topic': | @@ -1117,6 +1117,10 @@ en: from: "%{site_name} digest" read_more: "Read More" + posts: + one: "1 post" + other: "%{count} posts" + forgot_password: subject_template: "[%{site_name}] Password reset" text_body_template: | diff --git a/lib/email/styles.rb b/lib/email/styles.rb index 041ac01e2..7a13181fa 100644 --- a/lib/email/styles.rb +++ b/lib/email/styles.rb @@ -60,6 +60,7 @@ module Email style('div.digest-post h1', 'font-size: 20px;') style('span.footer-notice', 'color:#666; font-size:80%') + style('span.post-count', 'margin: 0 5px; color: #777;') style('pre', 'white-space: pre-wrap') style('code', 'background-color: f1f1ff; padding: 2px 5px;') style('pre code', 'display: block; background-color: f1f1ff; padding: 5px')