0
@@ -6,21 +6,21 @@ module Merb
0
# * Create a MailController subclass with actions and templates.
0
# * Call the MailController from another Controller via the send_mail method.
0
- # First, create a file in app/mailers that subclasses Merb::MailController.
0
+ # First, create a file in app/mailers that subclasses Merb::MailController.
0
# The actions in this controller will do nothing but render mail.
0
# # app/mailers/article_mailer.rb
0
# class ArticleMailer < Merb::MailController
0
# @user = params[:user]
0
- # You also can access the params hash for values passed with the
0
- # Controller.send_mail method. See also the documentation for
0
+ # You also can access the params hash for values passed with the
0
+ # Controller.send_mail method. See also the documentation for
0
# render_mail to see all the ways it can be called.
0
# Create a template in a subdirectory of app/mailers/views that corresponds
0
@@ -28,10 +28,10 @@ module Merb
0
# # app/mailers/views/article_mailer/notify.text.erb
0
# Hey, <%= @user.name %>,
0
# We're running a sale on dog bones!
0
- # Finally, call the Controller.send_mail method from a standard
0
+ # Finally, call the Controller.send_mail method from a standard
0
# class Articles < Application
0
@@ -47,13 +47,13 @@ module Merb
0
# Note: If you don't pass a fourth argument to Controller.send_mail,
0
# the controller's params will be sent to the MailController subclass
0
- # as params. However, you can explicitly send a hash of objects that
0
- # will populate the params hash instead. In either case, you must
0
- # set instance variables in the MailController's actions if you
0
+ # as params. However, you can explicitly send a hash of objects that
0
+ # will populate the params hash instead. In either case, you must
0
+ # set instance variables in the MailController's actions if you
0
# want to use them in the MailController's views.
0
# The MailController class is very powerful. You can:
0
@@ -91,15 +91,15 @@ module Merb
0
def _template_location(action, type = nil, controller = controller_name)
0
"#{controller}/#{action}.#{type}"
0
- # The location to look for a template and mime-type. This is overridden
0
- # from AbstractController, which defines a version of this that does not
0
+ # The location to look for a template and mime-type. This is overridden
0
+ # from AbstractController, which defines a version of this that does not
0
# The absolute path to a template - without mime and template extension.
0
- # The mime-type extension is optional - it will be appended from the
0
+ # The mime-type extension is optional - it will be appended from the
0
# current content type if it hasn't been added already.
0
# The mime-type of the template that will be rendered. Defaults to nil.
0
@@ -126,7 +126,7 @@ module Merb
0
- # The Merb::MailController inheriting from the base class.
0
+ # The Merb::MailController inheriting from the base class.
0
def self.inherited(klass)
0
klass._template_root = Merb.dir_for(:mailer) / "views" unless self._template_root
0
@@ -172,7 +172,7 @@ module Merb
0
# "foo", this is identical to render_mail :foo.
0
# checks for foo.html.ext and foo.text.ext and applies them as appropriate.
0
# render_mail :action => {:html => :foo, :text => :bar}
0
@@ -213,13 +213,13 @@ module Merb
0
@_missing_templates = false # used to make sure that at least one template was found
0
# If the options are not a hash, normalize to an action hash
0
options = {:action => {:html => options, :text => options}} if !options.is_a?(Hash)
0
# Take care of the options
0
actions = opts.delete(:action) if opts[:action].is_a?(Hash)
0
templates = opts.delete(:template) if opts[:template].is_a?(Hash)
0
# Prepare the options hash for each format
0
# We need to delete anything relating to the other format here
0
# before we try to render the template.
0
@@ -228,7 +228,7 @@ module Merb
0
opts_hash[fmt] ||= actions[fmt] if actions && actions[fmt]
0
opts_hash[:template] = templates[fmt] if templates && templates[fmt]
0
# Send the result to the mailer
0
{ :html => "rawhtml=", :text => "text="}.each do |fmt,meth|
0
@@ -252,14 +252,21 @@ module Merb
0
# Mimic the behavior of absolute_url in AbstractController
0
# but use @base_controller.request
0
- def absolute_url(name, rparams={})
0
- req = @base_controller.request
0
- uri = req.protocol + req.host + url(name, rparams)
0
+ self.base_controller.request.generate_url(name, *args)
0
+ alias_method :relative_url, :url
0
+ # Mimic the behavior of absolute_url in AbstractController
0
+ # but use @base_controller.request
0
+ def absolute_url(name, *args)
0
+ self.base_controller.request.generate_absolute_url(name, *args)
0
# Attaches a file or multiple files to an email. You call this from a
0
# method in your MailController (including a before filter).
0
# file_or_files<File, Array[File]>:: File(s) to attach.
0
@@ -271,17 +278,17 @@ module Merb
0
# attach File.open("foo")
0
# attach [File.open("foo"), File.open("bar")]
0
# If you are passing an array of files, you should use an array of the
0
# attach [[File.open("foo"), "bar", "text/html"], [File.open("baz"),
0
# which would attach two files ("foo" and "baz" in the filesystem) as
0
# "bar" and "bat" respectively. It would also set the mime-type as
0
# "text/html" and "text/css" respectively.
0
- def attach( file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,
0
+ def attach( file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,
0
type = nil, headers = nil)
0
@mailer.attach(file_or_files, filename, type, headers)
0
@@ -305,7 +312,7 @@ module Merb
0
@mailer = self.class._mailer_klass.new(mail_params)
0
# dispatch and render use params[:action], so set it
0
self.action_name = method