From ac9713b4ce4624bd7c8749e9b3b7c75e005011f4 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 28 Mar 2018 18:14:55 -0400 Subject: [PATCH] Adjust email digest copy and subject (#160) * Adjust email copy in digest * Adjust email digest subject --- app/mailers/digest_mailer.rb | 10 ++++++++-- app/views/layouts/_mailer_content.html.erb | 22 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb index c233556d7..811f4c3af 100644 --- a/app/mailers/digest_mailer.rb +++ b/app/mailers/digest_mailer.rb @@ -7,13 +7,19 @@ class DigestMailer < ApplicationMailer end @articles = articles.first(6) @digest_email = true - mail(from: "DEV Digest ", to: @user.email, subject: "#{@articles.first.title} #{random_emoji} and #{@articles.size - 1} #{email_end_phrase}") do |format| + mail(from: "DEV Digest ", to: @user.email, subject: "#{adjusted_title(@articles.first)} + #{@articles.size - 1} #{email_end_phrase} #{random_emoji}") do |format| format.html { render "layouts/mailer" } end end + def adjusted_title(article) + title = article.title.strip + + title = "\"#{title}\"" unless title.start_with? '"' + end + def random_emoji - ["📖","🎉","🙈","🔥","💬","👋","👏","🐶","🦁","🦊","🐙","🦄","❤️"].shuffle.take(3).join + ["🤓","🎉","🙈","🔥","💬","👋","👏","🐶","🦁","🦊","🐙","🦄","❤️","😇"].shuffle.take(3).join end def email_end_phrase diff --git a/app/views/layouts/_mailer_content.html.erb b/app/views/layouts/_mailer_content.html.erb index 1b1e4d101..ecee594d7 100644 --- a/app/views/layouts/_mailer_content.html.erb +++ b/app/views/layouts/_mailer_content.html.erb @@ -182,7 +182,7 @@

DEV Digest

-

Recent posts you might find valuable based on who you follow ❤️

+

Recent posts you might find valuable based on your interests ❤️

<% @articles.each do |article| %>
  • @@ -191,5 +191,23 @@
<% end %> -
Thanks for being a valued member of the community. 👩‍💻👨‍💻
+ <% tip_rand = rand(5) %> +
+ <% if tip_rand == 0 %> + Thanks for being a valued member of the community. + <% elsif tip_rand == 1 %> + Follow the authors you want to see more of! + <% elsif tip_rand == 2 %> + And there's so much more dev goodness to discover. + <% elsif tip_rand == 3 %> + You're a better dev today than you were yesterday. + <% elsif tip_rand == 4 %> + <% if @user.articles.where(published: true).any? %> + Can't wait to see your next DEV post! + <% else %> + Can't wait to see your first DEV post! + <% end %> + <% end %> +
+ <% end %>