Show post count in digest emails. Sort by score

This commit is contained in:
Robin Ward 2013-11-29 13:00:10 -05:00
parent 78b2c5acff
commit 781a8876d3
5 changed files with 18 additions and 3 deletions

View File

@ -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,

View File

@ -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 -%>

View File

@ -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 -%>

View File

@ -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: |

View File

@ -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')