aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-01-21 20:45:04 +0000
committerMichael Koziarski <michael@koziarski.com>2008-01-21 20:45:04 +0000
commit61c90a4ad6eab3623002353ed5867e2f05cb6809 (patch)
tree12855a156606c9af87c3f24d46d52dc859a55496 /actionpack/lib/action_controller
parent32b36b8936b043d54daad072054f95429e462ff8 (diff)
downloadrails-61c90a4ad6eab3623002353ed5867e2f05cb6809.tar.gz
rails-61c90a4ad6eab3623002353ed5867e2f05cb6809.tar.bz2
rails-61c90a4ad6eab3623002353ed5867e2f05cb6809.zip
Reapply the TemplateFinder first applied in [8669] then reverted in [8676]. Closes #10800 [lifofifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8683 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-xactionpack/lib/action_controller/base.rb16
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb1
-rw-r--r--actionpack/lib/action_controller/layout.rb13
3 files changed, 12 insertions, 18 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 5d4afc31fe..1321b002eb 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -5,6 +5,7 @@ require 'action_controller/routing'
require 'action_controller/resources'
require 'action_controller/url_rewriter'
require 'action_controller/status_codes'
+require 'action_view/template_finder'
require 'drb'
require 'set'
@@ -428,6 +429,7 @@ module ActionController #:nodoc:
def view_paths=(value)
@view_paths = value
+ ActionView::TemplateFinder.process_view_paths(value)
end
# Adds a view_path to the front of the view_paths array.
@@ -440,6 +442,7 @@ module ActionController #:nodoc:
def prepend_view_path(path)
@view_paths = superclass.view_paths.dup if @view_paths.nil?
view_paths.unshift(*path)
+ ActionView::TemplateFinder.process_view_paths(path)
end
# Adds a view_path to the end of the view_paths array.
@@ -452,6 +455,7 @@ module ActionController #:nodoc:
def append_view_path(path)
@view_paths = superclass.view_paths.dup if @view_paths.nil?
view_paths.push(*path)
+ ActionView::TemplateFinder.process_view_paths(path)
end
# Replace sensitive parameter data from the request log.
@@ -642,11 +646,11 @@ module ActionController #:nodoc:
# View load paths for controller.
def view_paths
- @template.view_paths
+ @template.finder.view_paths
end
def view_paths=(value)
- @template.view_paths = value
+ @template.finder.view_paths = value # Mutex needed
end
# Adds a view_path to the front of the view_paths array.
@@ -656,7 +660,7 @@ module ActionController #:nodoc:
# self.prepend_view_path(["views/default", "views/custom"])
#
def prepend_view_path(path)
- @template.prepend_view_path(path)
+ @template.finder.prepend_view_path(path) # Mutex needed
end
# Adds a view_path to the end of the view_paths array.
@@ -666,7 +670,7 @@ module ActionController #:nodoc:
# self.append_view_path(["views/default", "views/custom"])
#
def append_view_path(path)
- @template.append_view_path(path)
+ @template.finder.append_view_path(path) # Mutex needed
end
protected
@@ -1249,7 +1253,7 @@ module ActionController #:nodoc:
end
def template_exists?(template_name = default_template_name)
- @template.file_exists?(template_name)
+ @template.finder.file_exists?(template_name)
end
def template_public?(template_name = default_template_name)
@@ -1257,7 +1261,7 @@ module ActionController #:nodoc:
end
def template_exempt_from_layout?(template_name = default_template_name)
- extension = @template && @template.pick_template_extension(template_name)
+ extension = @template && @template.finder.pick_template_extension(template_name)
name_with_extension = !template_name.include?('.') && extension ? "#{template_name}.#{extension}" : template_name
@@exempt_from_layout.any? { |ext| name_with_extension =~ ext }
end
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index 6a02f602e4..f892058f20 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -139,6 +139,7 @@ module ActionController
if unprepared || force
run_callbacks :prepare_dispatch
+ ActionView::TemplateFinder.reload! unless ActionView::Base.cache_template_loading
self.unprepared = false
end
end
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index a81efc2693..0fbbfa8b05 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -208,12 +208,6 @@ module ActionController #:nodoc:
conditions.inject({}) {|hash, (key, value)| hash.merge(key => [value].flatten.map {|action| action.to_s})}
end
- def layout_directory_exists_cache
- @@layout_directory_exists_cache ||= Hash.new do |h, dirname|
- h[dirname] = File.directory? dirname
- end
- end
-
def default_layout_with_format(format, layout)
list = layout_list
if list.grep(%r{layouts/#{layout}\.#{format}(\.[a-z][0-9a-z]*)+$}).empty?
@@ -313,13 +307,8 @@ module ActionController #:nodoc:
end
end
- # Does a layout directory for this class exist?
- # we cache this info in a class level hash
def layout_directory?(layout_name)
- view_paths.find do |path|
- next unless template_path = Dir[File.join(path, 'layouts', layout_name) + ".*"].first
- self.class.send!(:layout_directory_exists_cache)[File.dirname(template_path)]
- end
+ @template.finder.find_template_extension_from_handler(File.join('layouts', layout_name))
end
end
end