Changed engine to use plugin base functionality

pull/6827/head
Sebastian Schuster 11 years ago
parent 4c82c8eee4
commit 762a249a61
  1. 66
      lib/open_project/my_project_page/engine.rb

@ -24,24 +24,13 @@ module OpenProject::MyProjectPage
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
engine_name :openproject_my_project_page engine_name :openproject_my_project_page
include OpenProject::Plugins::ActsAsOpEngine
config.autoload_paths += Dir["#{config.root}/lib/"] register 'openproject-my_project_page',
:author_url => 'http://finn.de',
spec = Bundler.environment.specs['openproject-my_project_page'][0] :requires_openproject => '>= 3.0.0' do
initializer 'my_project_page.register_plugin' do
Redmine::Plugin.register :openproject_my_project_page do
name 'OpenProject MyProjectPage'
author ((spec.authors.kind_of? Array) ? spec.authors[0] : spec.authors)
author_url spec.homepage
description spec.description
version spec.version
url 'https://www.openproject.org/projects/my-project-page'
requires_openproject ">= 3.0.0pre42"
project_module :my_project_page do project_module :my_project_page do
Redmine::AccessControl.permission(:view_project).actions << "my_projects_overviews/index" << Redmine::AccessControl.permission(:view_project).actions << "my_projects_overviews/index" <<
"my_projects_overviews/show_all_members" "my_projects_overviews/show_all_members"
Redmine::AccessControl.permission(:edit_project).actions << "my_projects_overviews/page_layout" << Redmine::AccessControl.permission(:edit_project).actions << "my_projects_overviews/page_layout" <<
@ -51,53 +40,8 @@ module OpenProject::MyProjectPage
"my_projects_overviews/order_blocks" << "my_projects_overviews/order_blocks" <<
"my_projects_overviews/destroy_attachment" "my_projects_overviews/destroy_attachment"
end end
end
end end
initializer 'my_project_page.precompile_assets' do |app| assets %w(my_projects_overview.css, my_project_page.js)
app.config.assets.precompile += ["my_projects_overview.css"]
end
initializer 'my_project_page.register_path_to_rspec' do |app|
require File.join(File.dirname(__FILE__), "disabled_specs")
app.config.plugins_to_test_paths << self.root
end
config.before_configuration do |app|
# This is required for the routes to be loaded first
# as the routes should be prepended so they take precedence over the core.
app.config.paths['config/routes'].unshift File.join(File.dirname(__FILE__), "..", "..", "..", "config", "routes.rb")
end
initializer "remove_duplicate_meeting_routes", :after => "add_routing_paths" do |app|
# removes duplicate entry from app.routes_reloader
# As we prepend the plugin's routes to the load_path up front and rails
# adds all engines' config/routes.rb later, we have double loaded the routes
# This is not harmful as such but leads to duplicate routes which decreases performance
app.routes_reloader.paths.uniq!
end
# adds our factories to factory girl's load path
initializer "my_project_page.register_factories", :after => "factory_girl.set_factory_paths" do |app|
FactoryGirl.definition_file_paths << File.expand_path(self.root.to_s + '/spec/factories') if defined?(FactoryGirl)
end
initializer 'my_project_page.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
end
config.to_prepare do
# load classes so that all User.before_destroy filters are loaded
#require_dependency 'my_project_page'
end
end end
end end

Loading…
Cancel
Save