Changeset 691
- Timestamp:
- 01/08/08 09:49:18 (6 months ago)
- Files:
-
- branches/rails2/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb (modified) (4 diffs)
- branches/rails2/lib/radiant/extension_loader.rb (modified) (3 diffs)
- branches/rails2/lib/radiant/initializer.rb (modified) (4 diffs)
- branches/rails2/test/functional/extension_initialization_test.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/rails2/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb
r555 r691 21 21 return full_path unless Dir["#{full_path}.*"].empty? 22 22 end 23 nil 23 24 end 24 25 25 26 def create_with_view_paths!(method_name, *parameters) #:nodoc: 26 27 initialize_defaults(method_name) 27 send(method_name, *parameters)28 __send__(method_name, *parameters) 28 29 29 30 # If an explicit, textual body has not been set, we check assumptions. … … 31 32 # First, we look to see if there are any likely templates that match, 32 33 # which include the content-type in their file name (i.e., 33 # "the_template_file.text.html. rhtml", etc.). Only do this if parts34 # "the_template_file.text.html.erb", etc.). Only do this if parts 34 35 # have not already been specified manually. 35 36 if @parts.empty? … … 39 40 # JWL: end modifications 40 41 templates.each do |path| 41 # TODO: don't hardcode rhtml|rxml42 42 basename = File.basename(path) 43 next unless md = /^([^\.]+)\.([^\.]+\.[^\+]+)\.(rhtml|rxml)$/.match(basename) 43 template_regex = Regexp.new("^([^\\\.]+)\\\.([^\\\.]+\\\.[^\\\.]+)\\\.(" + template_extensions.join('|') + ")$") 44 next unless md = template_regex.match(basename) 44 45 template_name = basename 45 46 content_type = md.captures[1].gsub('.', '/') 46 @parts << ActionMailer::Part.new(:content_type => content_type,47 @parts << Part.new(:content_type => content_type, 47 48 :disposition => "inline", :charset => charset, 48 49 :body => render_message(template_name, @body)) … … 66 67 # that create_mail doesn't try to render it in addition to the parts). 67 68 if !@parts.empty? && String === @body 68 @parts.unshift ActionMailer::Part.new(:charset => charset, :body => @body)69 @parts.unshift Part.new(:charset => charset, :body => @body) 69 70 @body = nil 70 71 end branches/rails2/lib/radiant/extension_loader.rb
r682 r691 42 42 load_extension_roots.each do |ext_path| 43 43 configuration.load_paths.concat load_paths_for(ext_path) 44 # TODO: use Dependencies.load_paths instead of $LOAD_PATH 44 45 $LOAD_PATH.concat load_paths_for(ext_path) 45 46 configuration.controller_paths << "#{ext_path}/app/controllers" 46 ActionController::Base.view_paths << "#{ext_path}/app/views"47 configuration.view_paths << "#{ext_path}/app/views" 47 48 @extension_roots << ext_path 48 49 end … … 94 95 extension if enabled 95 96 end 96 97 97 98 def load_paths_for(ext_path) 98 99 load_paths = %w(lib app/models app/controllers app/helpers test/helpers).collect { |p| "#{ext_path}/#{p}" } 99 100 load_paths << ext_path 100 101 end 101 102 102 103 def load_extension_roots 103 104 @load_extension_roots ||= configuration.extensions ? select_extension_roots : all_extension_roots … … 122 123 end.flatten 123 124 end 124 125 125 126 def all_extension_roots 126 127 @all_extension_roots ||= configuration.extension_paths.map do |path| branches/rails2/lib/radiant/initializer.rb
r682 r691 7 7 attr_accessor :extension_paths 8 8 attr_accessor :extensions 9 attr_accessor :view_paths 9 10 10 11 def initialize 12 self.view_paths = [] 11 13 self.extension_paths = default_extension_paths 12 14 self.extensions = nil … … 31 33 def after_initialize 32 34 initialize_extensions 35 initialize_framework_views 33 36 super 34 37 end … … 37 40 ActiveRecord::Base.connection.execute("select count(*) from #{ExtensionMeta.table_name}") 38 41 rescue 39 $stderr.puts "Extensions cannot be used until Radiant migrations are up to date."42 $stderr.puts "Extensions cannot be used until Radiant migrations are updated." 40 43 else 41 44 require 'radiant/extension_loader' … … 50 53 end 51 54 55 def initialize_framework_views 56 view_path = configuration.view_path 57 configuration.view_paths << view_path if view_path and not configuration.view_paths.include?(view_path) 58 view_paths = configuration.view_paths.reverse 59 ActionMailer::Base.view_paths = view_paths if configuration.frameworks.include?(:action_mailer) 60 ActionController::Base.view_paths = view_paths if configuration.frameworks.include?(:action_controller) 61 end 62 52 63 def admin 53 64 configuration.admin branches/rails2/test/functional/extension_initialization_test.rb
r542 r691 38 38 Dependencies.clear 39 39 Dependencies.explicitly_unloadable_constants = old_list 40 40 41 41 assert_basic_extension_annotations 42 42 assert_view_paths 43 43 assert_admin_tabs "Basic Extension Tab" 44 45 44 end 46 45 … … 66 65 assert_basic_extension_annotations 67 66 end 68 67 69 68 def test_should_load_plugin_from_vendor_plugin 70 69 assert_nothing_raised { Radiant::Extension.const_get(:PLUGIN_PLUGIN_NORMAL) } … … 88 87 assert !Dependencies.load_once_paths.include?(OverridingExtension.root + "/vendor/plugins/multiple/lib") 89 88 end 90 89 91 90 def test_should_add_extension_load_paths_to_requirable_load_path 92 91 assert_nothing_raised { require 'new_module' } … … 97 96 98 97 def assert_admin_tabs(more_tabs = []) 99 tab names = []98 tab_names = [] 100 99 Radiant::AdminUI.tabs.each do |tab| 101 assert "Duplicate Tab", !tabnames.include?(tab.name)102 tab names << tab.name100 assert !tab_names.include?(tab.name), "duplicate tab #{tab.name.inspect}" 101 tab_names << tab.name 103 102 end 104 more_tabs.each do |tab name|105 assert Radiant::AdminUI.tabs.any? {|tab| tab.name == tab name }103 more_tabs.each do |tab_name| 104 assert Radiant::AdminUI.tabs.any? {|tab| tab.name == tab_name } 106 105 end 107 106 end … … 112 111 assert_equal "http://test.com", BasicExtension.url 113 112 end 114 115 def assert_view_paths(expected = {}, message = nil)116 expected .reverse_merge!({113 114 def assert_view_paths(expected_messages = {}, message = nil) 115 expected_messages.reverse_merge!( 117 116 :index => /Hello, Extension World/, 118 117 :override => /Hello, Overridden Extension World/, 119 :routing => /You're routing works/ ,120 })121 118 :routing => /You're routing works/ 119 ) 120 122 121 @controller = BasicExtensionController.new 123 122 @request = ActionController::TestRequest.new … … 126 125 [:index, :override, :routing].each do |action| 127 126 get action 128 assert_match expected [action], @response.body, message127 assert_match expected_messages[action], @response.body, message 129 128 end 130 129 end
