Skip to content
Browse files

fix view_path order and streamline a bit

  • Loading branch information...
1 parent 0e4fd7d commit 42a76b2062b5ccfc56a91f609ca33449d28b7563 @will-r will-r committed Sep 23, 2011
Showing with 15 additions and 18 deletions.
  1. +0 −1 config/boot.rb
  2. +1 −1 config/preinitializer.rb
  3. +4 −2 lib/radiant/extension_loader.rb
  4. +10 −14 lib/radiant/initializer.rb
View
1 config/boot.rb
@@ -2,7 +2,6 @@
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
-RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
module Rails
class << self
View
2 config/preinitializer.rb
@@ -13,7 +13,7 @@
begin
# Set up load paths for all bundled gems
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
- Bundler.setup(:default, RAILS_ENV)
+ Bundler.setup
rescue Bundler::GemNotFound => e
raise RuntimeError, "Bundler couldn't find some gems: #{e}. Did you run `bundle install`?"
end
View
6 lib/radiant/extension_loader.rb
@@ -48,7 +48,7 @@ def enabled_extension_paths
# extension_loader.paths(:controller) #=> ['extension/app/controllers', 'extension/app/controllers']
# extension_loader.paths(:eager_load) #=> ['extension/app/controllers', 'extension/app/models', 'extension/app/helpers']
#
- # For compatibility with the old loader, there are also corresponding +type_paths+
+ # For compatibility with the old loader, there are corresponding +type_paths+ methods.
# There are also (deprecated) +add_type_paths+ methods.
#
def paths(type)
@@ -57,7 +57,7 @@ def paths(type)
# Loads but does not activate all the extensions that have been enabled, in the configured order
# (which defaults to alphabetically). If an extension fails to load an error will be logged
- # but application startup will not halt. If an extension doesn't exist, a LoadError will be raised
+ # but application startup will continue. If an extension doesn't exist, a LoadError will be raised
# and startup will halt.
#
def load_extensions
@@ -114,6 +114,8 @@ def record_path(path, name=nil)
ExtensionPath.from_path(path, name)
end
+ # For compatibility with old calls probably still to be found in some extensions.
+ #
%w{controller model view metal plugin load locale}.each do |type|
define_method("#{type}_paths".to_sym) do
paths(type)
View
24 lib/radiant/initializer.rb
@@ -49,10 +49,9 @@ class Configuration < Rails::Configuration
# * to notice that some gems and plugins are in fact radiant extensions
# * to notice that some radiant extensions add load paths (for plugins, controllers, metal, etc)
- attr_accessor :extension_paths, :ignored_extensions, :view_paths
+ attr_accessor :extension_paths, :ignored_extensions
def initialize #:nodoc:
- self.view_paths = []
self.extension_paths = default_extension_paths
self.ignored_extensions = []
super
@@ -382,22 +381,19 @@ def initialize_default_admin_tabs
admin.initialize_nav
end
- # Adds extension view paths and then hooks them into ActionMailer and ActionController
+ # This adds extension view paths to the standard Rails::Initializer method.
+ # In environments that don't cache templates it reloads the path set on each request,
+ # so that new extension paths are noticed without a restart.
#
def initialize_framework_views
- view_paths = [].tap do |arr|
- arr << configuration.view_path unless configuration.view_paths.include?(configuration.view_path)
- arr.concat(configuration.view_paths)
- arr.concat(extension_loader.paths(:view))
- arr.reverse!
+ view_paths = extension_loader.paths(:view).push(configuration.view_path)
+ if ActionController::Base.view_paths.blank? || !ActionView::Base.cache_template_loading?
+ ActionController::Base.view_paths = ActionView::Base.process_view_paths(view_paths)
end
- if configuration.frameworks.include?(:action_mailer) || defined?(ActionMailer::Base)
- ActionMailer::Base.view_paths = ActionView::Base.process_view_paths(view_paths)
+ if configuration.frameworks.include?(:action_mailer) && ActionMailer::Base.view_paths.blank? || !ActionView::Base.cache_template_loading?
+ ActionMailer::Base.view_paths = ActionView::Base.process_view_paths(view_paths) if configuration.frameworks.include?(:action_mailer)
end
- view_paths.each do |vp|
- ActionController::Base.prepend_view_path(vp) unless ActionController::Base.view_paths.include?(vp)
- end
- end
+ end
# Extends the Rails initializer to make sure that extension controller paths are available when routes
# are initialized.

0 comments on commit 42a76b2

Please sign in to comment.
Something went wrong with that request. Please try again.