From 52f905715efcc60ffb6b10654d170f8d7da10496 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 1 Jun 2010 06:32:16 -0300 Subject: Unforce text-format from AM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionmailer/lib/action_mailer.rb | 6 ------ actionmailer/lib/action_mailer/mail_helper.rb | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index 70cc312634..6e2d288082 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -49,9 +49,3 @@ module ActionMailer autoload :TestCase autoload :TestHelper end - -module Text - extend ActiveSupport::Autoload - - autoload :Format, 'text/format' -end diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb index ab5c3469b2..aab6e12387 100644 --- a/actionmailer/lib/action_mailer/mail_helper.rb +++ b/actionmailer/lib/action_mailer/mail_helper.rb @@ -3,6 +3,13 @@ module ActionMailer # Uses Text::Format to take the text and format it, indented two spaces for # each line, and wrapped at 72 columns. def block_format(text) + begin + require 'text/format' + rescue LoadError => e + $stderr.puts "You don't have text-format installed in your application. Please add it to your Gemfile and run bundle install" + raise e + end unless defined?(Text::Format) + formatted = text.split(/\n\r\n/).collect { |paragraph| Text::Format.new( :columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph -- cgit v1.2.3 From 08baa343c884767e6b6536365893042ba1fc14e5 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 2 Jun 2010 16:49:02 -0500 Subject: Extract assets paths and make them available to Action Mailer as well --- actionmailer/lib/action_mailer/base.rb | 1 + actionmailer/lib/action_mailer/railtie.rb | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 3c41691af7..3a82979d35 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -311,6 +311,7 @@ module ActionMailer #:nodoc: include AbstractController::Layouts include AbstractController::Helpers include AbstractController::Translation + include AbstractController::AssetPaths helper ActionMailer::MailHelper diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 0730167a3e..43a4936013 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -13,7 +13,16 @@ module ActionMailer end initializer "action_mailer.set_configs" do |app| + paths = app.config.paths + am = app.config.action_mailer + + am.assets_dir ||= paths.public.to_a.first + am.javascripts_dir ||= paths.public.javascripts.to_a.first + am.stylesheets_dir ||= paths.public.stylesheets.to_a.first + ActiveSupport.on_load(:action_mailer) do + self.config.merge!(am) + include app.routes.url_helpers app.config.action_mailer.each do |k,v| -- cgit v1.2.3 From 311d99eef01c268cedc6e9b3bdb9abc2ba5c6bfa Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 7 Jun 2010 21:54:53 -0400 Subject: Adding inline attachment support to ActionMailer --- actionmailer/lib/action_mailer/base.rb | 6 +++++- actionmailer/lib/action_mailer/mail_helper.rb | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 3a82979d35..9fb3ba425f 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -612,7 +612,11 @@ module ActionMailer #:nodoc: when user_content_type.present? user_content_type when m.has_attachments? - ["multipart", "mixed", params] + if m.attachments.detect { |a| a.inline? } + ["multipart", "related", params] + else + ["multipart", "mixed", params] + end when m.multipart? ["multipart", "alternative", params] else diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb index aab6e12387..b708881edf 100644 --- a/actionmailer/lib/action_mailer/mail_helper.rb +++ b/actionmailer/lib/action_mailer/mail_helper.rb @@ -32,5 +32,10 @@ module ActionMailer def message @_message end + + # Access the message attachments list. + def attachments + @_message.attachments + end end end -- cgit v1.2.3 From 3762362eab9663b3c9bc6d4b831e402917f95e93 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 7 Jun 2010 23:14:54 -0400 Subject: Updating readme for ActionMailer::Base --- actionmailer/lib/action_mailer/base.rb | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 9fb3ba425f..7da033b6af 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -36,6 +36,9 @@ module ActionMailer #:nodoc: # * attachments[]= - Allows you to add attachments to your email in an intuitive # manner; attachments['filename.png'] = File.read('path/to/filename.png') # + # * attachments.inline[]= - Allows you to add an inline attachment to your email + # in the same manner as attachments[]= + # # * headers[]= - Allows you to specify any header field in your email such # as headers['X-No-Spam'] = 'True'. Note, while most fields (like To: # From: can only appear once in an email header, other fields like X-Anything @@ -173,7 +176,7 @@ module ActionMailer #:nodoc: # # class ApplicationMailer < ActionMailer::Base # def welcome(recipient) - # attachments['free_book.pdf'] = { :data => File.read('path/to/file.pdf') } + # attachments['free_book.pdf'] = File.read('path/to/file.pdf') # mail(:to => recipient, :subject => "New account information") # end # end @@ -184,6 +187,34 @@ module ActionMailer #:nodoc: # and the second being a application/pdf with a Base64 encoded copy of the file.pdf book # with the filename +free_book.pdf+. # + # = Inline Attachments + # + # You can also specify that a file should be displayed inline with other HTML. For example a + # corporate logo or a photo or the like. + # + # To do this is simple, in the Mailer: + # + # class ApplicationMailer < ActionMailer::Base + # def welcome(recipient) + # attachments.inline['photo.png'] = File.read('path/to/photo.png') + # mail(:to => recipient, :subject => "Here is what we look like") + # end + # end + # + # And then to reference the image in the view, you create a welcome.html.erb file and + # make a call to +image_tag+ passing in the attachment you want to display and then call + # +url+ on the attachment to get the relative content id path for the image source: + # + #

Please Don't Cringe

+ # + # <%= image_tag attachments['photo.png'].url -%> + # + # As we are using ActionView's +image_tag+ method, you can pass in any other options you want: + # + #

Please Don't Cringe

+ # + # <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%> + # # = Observing and Intercepting Mails # # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to -- cgit v1.2.3 From 32d4330b8185caa05af6ae69b0769b34b5e159eb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 8 Jun 2010 14:46:26 -0400 Subject: Get ready for beta 4 --- actionmailer/lib/action_mailer/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index e66172c8d3..8c19082f61 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -3,7 +3,7 @@ module ActionMailer MAJOR = 3 MINOR = 0 TINY = 0 - BUILD = "beta3" + BUILD = "beta4" STRING = [MAJOR, MINOR, TINY, BUILD].join('.') end -- cgit v1.2.3