require 'active_support/dependencies' require_relative 'query_output' module RedmineExtensions class Engine < ::Rails::Engine config.autoload_paths << config.root.join('lib') config.eager_load_paths << config.root.join('app', 'models', 'easy_queries') initializer 'redmine_extensions.assets' do if config.respond_to?(:assets) config.assets.precompile << 'redmine_extensions/applications.js' config.assets.precompile << 'redmine_extensions/blocking.js' end end # config.to_prepare goes after Reloader.to_prepare ActiveSupport::Reloader.to_prepare do RedmineExtensions::QueryOutput.register_output RedmineExtensions::QueryOutputs::ListOutput RedmineExtensions::QueryOutput.register_output RedmineExtensions::QueryOutputs::TilesOutput ApplicationController.include RedmineExtensions::RenderingHelper end initializer 'redmine_extensions.append_migrations' do |app| unless app.root.to_s.match root.to_s config.paths['db/migrate'].expanded.each do |expanded_path| app.config.paths['db/migrate'] << expanded_path end end js_dir = app.root.join('public', 'javascripts', 'redmine_extensions') FileUtils.mkdir_p(js_dir) Dir.glob(root.join('app', 'assets', 'javascripts', 'redmine_extensions', '*.js')) do |js_file| FileUtils.cp(js_file, app.root.join('public', 'javascripts', 'redmine_extensions')) rescue StandardError # ignore end end # include helpers initializer 'redmine_extensions.rails_patching', before: :load_config_initializers do |_app| ActiveSupport.on_load(:action_controller_base) do helper RedmineExtensions::ApplicationHelper # helper RedmineExtensions::EasyQueryHelper end ActiveSupport.on_load(:active_record) do include RedmineExtensions::RailsPatches::ActiveRecord end ActiveSupport.on_load(:action_view) do default_form_builder.include RedmineExtensions::RailsPatches::FormBuilderPatch end end ActiveSupport::Reloader.to_prepare do require_relative 'hooks' require_relative 'easy_entity_formatters/easy_entity_formatter' end end end