lib/radiant/initializer.rb in radiant-0.7.2 vs lib/radiant/initializer.rb in radiant-0.8.0
- old
+ new
@@ -2,23 +2,22 @@
$LOAD_PATH.unshift "#{RADIANT_ROOT}/vendor/rails/railties/lib"
require 'initializer'
require 'radiant/admin_ui'
require 'radiant/extension_loader'
-require 'radiant/compat'
module Radiant
-
+ autoload :Cache, 'radiant/cache'
+
class Configuration < Rails::Configuration
attr_accessor :extension_paths
- attr_accessor :extensions
+ attr_writer :extensions
attr_accessor :view_paths
def initialize
self.view_paths = []
self.extension_paths = default_extension_paths
- self.extensions = [ :all ]
super
end
def default_extension_paths
env = ENV["RAILS_ENV"] || RAILS_ENV
@@ -26,27 +25,43 @@
# There's no other way it will work, config/environments/test.rb loads too late
# TODO: Should figure out how to include this extension path only for the tests that need it
paths.unshift(RADIANT_ROOT + "/test/fixtures/extensions") if env == "test"
paths
end
-
+
+ def extensions
+ @extensions ||= all_available_extensions
+ end
+
+ def all_available_extensions
+ extension_paths.map do |path|
+ Dir["#{path}/*"].select {|f| File.directory?(f) }
+ end.flatten.map {|f| File.basename(f).sub(/^\d+_/, '') }.sort.map(&:to_sym)
+ end
+
def admin
AdminUI.instance
end
private
def library_directories
libs = %W{
#{RADIANT_ROOT}/vendor/radius/lib
#{RADIANT_ROOT}/vendor/highline/lib
+ #{RADIANT_ROOT}/vendor/rack-cache/lib
}
begin
+ Object.send :gem, 'RedCloth', ">=4.0.0"
require 'redcloth'
- rescue LoadError
+ rescue LoadError, Gem::LoadError
# If the gem is not available, use the packaged version
libs << "#{RADIANT_ROOT}/vendor/redcloth/lib"
+ after_initialize do
+ warn "RedCloth > 4.0 not found. Falling back to RedCloth 3.0.4 (2005-09-15). You should run `gem install RedCloth`."
+ require 'redcloth'
+ end
end
libs
end
def framework_root_path
@@ -143,11 +158,11 @@
if configuration.frameworks.include?(:action_mailer) || defined?(ActionMailer::Base)
# This happens before the plugins are loaded so we must load it manually
unless ActionMailer::Base.respond_to? :view_paths
require "#{RADIANT_ROOT}/lib/plugins/extension_patches/lib/mailer_view_paths_extension"
end
- ActionMailer::Base.view_paths = view_paths
+ ActionMailer::Base.view_paths = ActionView::Base.process_view_paths(view_paths)
end
if configuration.frameworks.include?(:action_controller) || defined?(ActionController::Base)
view_paths.each do |vp|
unless ActionController::Base.view_paths.include?(vp)
ActionController::Base.prepend_view_path vp
@@ -158,10 +173,20 @@
def initialize_routing
extension_loader.add_controller_paths
super
end
-
+
+ def extensions
+ @extensions ||= all_available_extensions
+ end
+
+ def all_available_extensions
+ extension_paths.map do |path|
+ Dir["#{path}/*"].select {|f| File.directory?(f) }
+ end.flatten.map {|f| File.basename(f).sub(/^\d+_/, '') }.sort.map(&:to_sym)
+ end
+
def admin
configuration.admin
end
def extension_loader