Changeset 692

Show
Ignore:
Timestamp:
01/09/08 09:34:03 (6 months ago)
Author:
jlong
Message:

rails2: ActionMailer::Base.view_paths is now set correctly for extensions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/rails2/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb

    r691 r692  
    2727      initialize_defaults(method_name) 
    2828      __send__(method_name, *parameters) 
    29  
     29       
    3030      # If an explicit, textual body has not been set, we check assumptions. 
    3131      unless String === @body 
     
    3535        # have not already been specified manually. 
    3636        if @parts.empty? 
    37           # JWL: begin modifications 
     37          # Radiant: begin modifications 
    3838          full_path = full_template_path("#{mailer_name}/#{@template}") 
    3939          templates = Dir.glob("#{full_path}.*") 
    40           # JWL: end modifications 
     40          # Radiant: end modifications 
    4141          templates.each do |path| 
    4242            basename = File.basename(path) 
     
    4545            template_name = basename 
    4646            content_type = md.captures[1].gsub('.', '/') 
    47             @parts << Part.new(:content_type => content_type, 
     47            # Radiant: begin modifications 
     48            @parts << ActionMailer::Part.new(:content_type => content_type, 
    4849              :disposition => "inline", :charset => charset, 
    4950              :body => render_message(template_name, @body)) 
     51            # Radiant: end modifications 
    5052          end 
    5153          unless @parts.empty? 
     
    5456          end 
    5557        end 
    56  
     58         
    5759        # Then, if there were such templates, we check to see if we ought to 
    5860        # also render a "normal" template (without the content type). If a 
     
    6264        template_exists ||= Dir.glob("#{template_path}/#{@template}.*").any? { |i| File.basename(i).split(".").length == 2 } 
    6365        @body = render_message(@template, @body) if template_exists 
    64  
     66         
    6567        # Finally, if there are other message parts and a textual body exists, 
    6668        # we shift it onto the front of the parts and set the body to nil (so 
    6769        # that create_mail doesn't try to render it in addition to the parts). 
    6870        if !@parts.empty? && String === @body 
    69           @parts.unshift Part.new(:charset => charset, :body => @body) 
     71          # Radiant: begin modifications 
     72          @parts.unshift ActionMailer::Part.new(:charset => charset, :body => @body) 
     73          # Radiant: end modifications 
    7074          @body = nil 
    7175        end 
    7276      end 
    73  
     77       
    7478      # If this is a multipart e-mail add the mime_version if it is not 
    7579      # already set. 
    7680      @mime_version ||= "1.0" if !@parts.empty? 
    77  
     81       
    7882      # build the mail object itself 
    7983      @mail = create_mail 
     
    8185     
    8286    def initialize_template_class_with_view_paths(assigns) 
    83       full_path = File.dirname(full_template_path("#{mailer_name}/#{@template}")) 
    84       ActionView::Base.new(full_path, assigns, self) 
     87      full_path = File.dirname(File.dirname(full_template_path("#{mailer_name}/#{@template}"))) 
     88      ActionView::Base.new([full_path], assigns, self) 
    8589    end 
    8690  end 
  • branches/rails2/lib/radiant/extension_loader.rb

    r691 r692  
    3434    def run 
    3535      DependenciesObserver.new(configuration).observe(Dependencies) 
    36        
    3736      discover_extensions 
    3837      activate_extensions 
     
    4241      load_extension_roots.each do |ext_path| 
    4342        configuration.load_paths.concat load_paths_for(ext_path)         
    44         # TODO: use Dependencies.load_paths instead of $LOAD_PATH 
    4543        $LOAD_PATH.concat load_paths_for(ext_path) 
    4644        configuration.controller_paths << "#{ext_path}/app/controllers" 
     
    106104       
    107105      def select_extension_roots 
    108         #put in the paths for extensions into the array 
     106        # put in the paths for extensions into the array 
    109107        roots = configuration.extensions.map do |ext_name| 
    110108          if :all === ext_name 
     
    118116          end 
    119117        end 
    120         #replace the :all symbol with any remaining paths 
     118        # replace the :all symbol with any remaining paths 
    121119        roots.map do |ext_path| 
    122120          :all === ext_path ? all_extension_roots : ext_path 
  • branches/rails2/lib/radiant/initializer.rb

    r691 r692  
    5757      configuration.view_paths << view_path if view_path and not configuration.view_paths.include?(view_path) 
    5858      view_paths = configuration.view_paths.reverse 
    59       ActionMailer::Base.view_paths = view_paths if configuration.frameworks.include?(:action_mailer) 
     59      ActionMailer::Base.view_paths = view_paths if (defined?(ActionMailer) and defined?(ActionMailer::Base)) or configuration.frameworks.include?(:action_mailer) 
    6060      ActionController::Base.view_paths = view_paths if configuration.frameworks.include?(:action_controller) 
    6161    end 
  • branches/rails2/test/functional/extension_initialization_test.rb

    r691 r692  
    4747    assert_admin_tabs "Basic Extension Tab" 
    4848    Radiant::ExtensionLoader.reactivate [] 
    49     assert Radiant::AdminUI.tabs.all? {|tab| tab.name != "Basic Extension Tab" } 
     49    assert Radiant::AdminUI.tabs.all? { |tab| tab.name != "Basic Extension Tab" } 
    5050  ensure 
    5151    Radiant::ExtensionLoader.reactivate Radiant::Extension.descendants