Class: Radiant::Initializer

Inherits:
Rails::Initializer
  • Object
show all
Defined in:
lib/radiant/initializer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(command = :process, configuration = Configuration.new) ⇒ Object



146
147
148
149
# File 'lib/radiant/initializer.rb', line 146

def self.run(command = :process, configuration = Configuration.new)
  Rails.configuration = configuration
  super
end

Instance Method Details

#add_plugin_load_pathsObject



168
169
170
171
172
# File 'lib/radiant/initializer.rb', line 168

def add_plugin_load_paths
  # checks for plugins within extensions:
  extension_loader.add_plugin_paths
  super
end

#adminObject



235
236
237
# File 'lib/radiant/initializer.rb', line 235

def admin
  configuration.admin
end

#after_initializeObject



182
183
184
185
186
# File 'lib/radiant/initializer.rb', line 182

def after_initialize
  super
  extension_loader.activate_extensions
  configuration.check_extension_dependencies
end

#all_available_extensionsObject



229
230
231
232
233
# File 'lib/radiant/initializer.rb', line 229

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

#extension_loaderObject



239
240
241
# File 'lib/radiant/initializer.rb', line 239

def extension_loader
  ExtensionLoader.instance {|l| l.initializer = self }
end

#extensionsObject



225
226
227
# File 'lib/radiant/initializer.rb', line 225

def extensions
  @extensions ||= all_available_extensions
end

#initialize_default_admin_tabsObject



188
189
190
191
# File 'lib/radiant/initializer.rb', line 188

def initialize_default_admin_tabs
  admin.nav.clear
  admin.load_default_nav
end

#initialize_framework_viewsObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/radiant/initializer.rb', line 193

def initialize_framework_views
  view_paths = returning [] do |arr|
    # Add the singular view path if it's not in the list
    arr << configuration.view_path if !configuration.view_paths.include?(configuration.view_path)
    # Add the default view paths
    arr.concat configuration.view_paths
    # Add the extension view paths
    arr.concat extension_loader.view_paths
    # Reverse the list so extensions come first
    arr.reverse!
  end
  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 = 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
      end
    end
  end
end

#initialize_metalObject

override Rails initializer to insert extension metals



157
158
159
160
161
162
163
164
165
166
# File 'lib/radiant/initializer.rb', line 157

def initialize_metal
  Rails::Rack::Metal.requested_metals = configuration.metals
  Rails::Rack::Metal.metal_paths = ["#{RADIANT_ROOT}/app/metal"] # reset Rails default to RADIANT_ROOT
  Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
  Rails::Rack::Metal.metal_paths += extension_loader.metal_paths

  configuration.middleware.insert_before(
    :"ActionController::ParamsParser",
    Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
end

#initialize_routingObject



220
221
222
223
# File 'lib/radiant/initializer.rb', line 220

def initialize_routing
  extension_loader.add_controller_paths
  super
end

#load_pluginsObject



174
175
176
177
178
179
180
# File 'lib/radiant/initializer.rb', line 174

def load_plugins
  super
  extension_loader.load_extensions
  add_gem_load_paths
  load_gems
  check_gem_dependencies
end

#set_autoload_pathsObject



151
152
153
154
# File 'lib/radiant/initializer.rb', line 151

def set_autoload_paths
  extension_loader.add_extension_paths
  super
end