diff --git a/app/controllers/admin/e_paper_criterias_controller.rb b/app/controllers/admin/e_paper_criterias_controller.rb index bd2a150..4b19b47 100644 --- a/app/controllers/admin/e_paper_criterias_controller.rb +++ b/app/controllers/admin/e_paper_criterias_controller.rb @@ -48,7 +48,7 @@ def initialize def send_test_email paper_criteria = PaperCriteria.find(params[:id]) page = Page.where(:module => "e_paper").first.url rescue "" - email = Email.new(:mail_subject => paper_criteria.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper_criteria, "page" => "http://" + request.host_with_port + page}, :mail_to => params[:email]) + email = Email.new(:mail_subject => paper_criteria.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper_criteria, "page" => "http://" + request.host_with_port + page, "siteurl" => "http://" + request.host_with_port }, :mail_to => params[:email]) email.deliver render :json => {"success" => true}.to_json end diff --git a/app/views/admin/e_paper_criterias/emailer.html.erb b/app/views/admin/e_paper_criterias/emailer.html.erb index 6c45408..2700a09 100644 --- a/app/views/admin/e_paper_criterias/emailer.html.erb +++ b/app/views/admin/e_paper_criterias/emailer.html.erb @@ -1,5 +1,6 @@ <% paper = @data["paper"] %> <% page = @data["page"] %> +<% siteurl = @data["siteurl"] %> @@ -159,8 +160,9 @@ <% paper.epaper_topics.desc(:created_at).each do |topic| %>
" target="_blank"><%= topic.title %> + "> <% t = strip_tags(topic.content) %> -

<%= t[0..100] %>

+ <%= topic.description %> " target="_blank">more
<% end %> diff --git a/lib/tasks/e_paper_tasks.rake b/lib/tasks/e_paper_tasks.rake index d36fcf2..d0811fc 100644 --- a/lib/tasks/e_paper_tasks.rake +++ b/lib/tasks/e_paper_tasks.rake @@ -14,7 +14,7 @@ namespace :epaper do subscriber.save if emails.count == mail_limit puts "Sending #{mail_limit} mails" - email = Email.new(:mail_subject => paper.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page}, :mail_to => emails) + email = Email.new(:mail_subject => paper.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page, "siteurl" => "http://" + domain }, :mail_to => emails) email.deliver emails = [] sleep 0.5 @@ -26,7 +26,7 @@ namespace :epaper do emails << email if emails.count == mail_limit puts "Sending #{mail_limit} mails" - email = Email.new(:mail_subject => paper.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page}, :mail_to => emails) + email = Email.new(:mail_subject => paper.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page, "siteurl" => "http://" + domain }, :mail_to => emails) email.deliver emails = [] sleep 0.5 @@ -35,7 +35,7 @@ namespace :epaper do end if !emails.empty? puts "Sending last emails" - email = Email.new(:mail_subject => paper.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page}, :mail_to => emails) + email = Email.new(:mail_subject => paper.sending_title, :mail_lang => :zh_tw, :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page, "siteurl" => "http://" + domain }, :mail_to => emails) email.deliver end paper.save