Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

place language/framework/gem patches in distinct folder

ulferts9a11f0c9bdf4
diff --git a/config/initializers/reform.rb b/config/initializers/10-load_patches.rb
similarity index 68%
rename from config/initializers/reform.rb
rename to config/initializers/10-load_patches.rb
index bc83a8e674a..6a7e79ecf30 100644
--- a/config/initializers/reform.rb
+++ b/config/initializers/10-load_patches.rb
@@ -28,27 +28,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require "reform/form/active_model/validations"
+# Do not place any patches within this file. Add a file to lib/open_project/patches
-Reform::Form.class_eval do
- include Reform::Form::ActiveModel::Validations
-end
-
-Reform::Contract.class_eval do
- include Reform::Form::ActiveModel::Validations
-end
-
-Reform::Form::ActiveModel::Validations::Validator.class_eval do
- ##
- # use activerecord as the base scope instead of 'activemodel' to be compatible
- # to the messages we have already stored
- def self.i18n_scope
- :activerecord
- end
-end
-
-require 'reform/contract'
-
-class Reform::Form::ActiveModel::Errors
- prepend OpenProject::Patches::Reform
+# Whatever ruby file is placed in lib/open_project/patches is required
+Dir.glob(File.expand_path("../../../lib/open_project/patches/*.rb", __FILE__)).each do |path|
+ require path
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 2dd504cdce1..3b506310481 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -24,6 +24,5 @@ OpenProject::Application.configure do
work_packages.js
vendor/ckeditor/ckeditor.*js
vendor/enjoyhint.js
- bundles/openproject-legacy-app.js
)
end
diff --git a/config/initializers/health_checks.rb b/config/initializers/health_checks.rb
index 88639771113..fc3a675c091 100644
--- a/config/initializers/health_checks.rb
+++ b/config/initializers/health_checks.rb
@@ -46,7 +46,6 @@ OkComputer::CheckCollection.new('full').tap do |collection|
OkComputer::Registry.default_collection.register 'full', collection
end
-
# Check if authentication required
authentication_password = OpenProject::Configuration.health_checks_authentication_password
if authentication_password.present?
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index ff0a0871829..3fbd59f543c 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -57,7 +57,8 @@ Redmine::MenuManager.map :top_menu do |menu|
(User.current.logged? || !Setting.login_required?) &&
User.current.allowed_to?(:view_time_entries, nil, global: true)
}
- menu.push :help, OpenProject::Static::Links.help_link,
+ menu.push :help,
+ OpenProject::Static::Links.help_link,
last: true,
caption: '',
icon: 'icon5 icon-help',
diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb
index c61389026b4..61b61201bc2 100644
--- a/config/initializers/zeitwerk.rb
+++ b/config/initializers/zeitwerk.rb
@@ -55,5 +55,6 @@ end
# Instruct zeitwerk to ignore all the engine gems' lib initialization files
Rails.autoloaders.main.ignore(Rails.root.join('modules/*/lib/openproject-*.rb'))
Rails.autoloaders.main.ignore(Rails.root.join('lib/plugins'))
+Rails.autoloaders.main.ignore(Rails.root.join('lib/open_project/patches'))
Rails.autoloaders.main.ignore(Rails.root.join('lib/generators'))
Rails.autoloaders.main.ignore(Bundler.bundle_path.join('**/*.rb'))
diff --git a/config/initializers/10-patches.rb b/lib/open_project/patches/action_view_accessible_errors.rb
similarity index 88%
rename from config/initializers/10-patches.rb
rename to lib/open_project/patches/action_view_accessible_errors.rb
index ea46d0a24ee..8b0a961e79a 100644
--- a/config/initializers/10-patches.rb
+++ b/lib/open_project/patches/action_view_accessible_errors.rb
@@ -1,5 +1,3 @@
-#-- encoding: UTF-8
-
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -28,19 +26,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require 'active_record'
-
-module ActiveRecord
- class Base
- include Redmine::I18n
-
- def self.human_attribute_name(attr, options = {})
- attr = attr.to_s.gsub(/_id\z/, '')
- super
- end
- end
-end
-
module ActionView
module Helpers
module Tags
@@ -138,8 +123,6 @@ module ActionView
end
end
-ActionView::Base.send :include, ActionView::Helpers::AccessibleErrors
-
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag.include?('<label')
html_tag.to_s
@@ -148,16 +131,4 @@ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
end
end
-# Patch acts_as_list before any class includes the module
-require 'open_project/patches/acts_as_list'
-
-# Patch String to have some helper methods
-require 'open_project/patches/string'
-
-# Patch Array to have some helper methods
-require 'open_project/patches/array'
-
-# Patch carrierwave to support custom access key validity (to be removed once carrierwave is bumped to 2)
-require 'open_project/patches/carrierwave'
-
-require 'open_project/patches/reform'
+ActionView::Base.send :include, ActionView::Helpers::AccessibleErrors
diff --git a/config/initializers/action_view_helpers_asset_tag_helper_patch.rb b/lib/open_project/patches/action_view_helpers_asset_tag_helper.rb
similarity index 89%
rename from config/initializers/action_view_helpers_asset_tag_helper_patch.rb
rename to lib/open_project/patches/action_view_helpers_asset_tag_helper.rb
index 480dc8bb4e4..a471ba8b15a 100644
--- a/config/initializers/action_view_helpers_asset_tag_helper_patch.rb
+++ b/lib/open_project/patches/action_view_helpers_asset_tag_helper.rb
@@ -28,7 +28,7 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-module OpenProject::ActionViewHelpersAssetTagHelperPatch
+module OpenProject::Patches::ActionViewHelpersAssetTagHelperPatch
def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
return if (type == :atom) && Setting.table_exists? && !Setting.feeds_enabled?
@@ -36,4 +36,4 @@ module OpenProject::ActionViewHelpersAssetTagHelperPatch
end
end
-ActionView::Helpers::AssetTagHelper.prepend(OpenProject::ActionViewHelpersAssetTagHelperPatch)
+ActionView::Helpers::AssetTagHelper.prepend(OpenProject::Patches::ActionViewHelpersAssetTagHelperPatch)
diff --git a/config/initializers/active_model_errors_patch.rb b/lib/open_project/patches/active_model_errors.rb
similarity index 100%
rename from config/initializers/active_model_errors_patch.rb
rename to lib/open_project/patches/active_model_errors.rb
diff --git a/lib/open_project/patches/active_record_i18n.rb b/lib/open_project/patches/active_record_i18n.rb
new file mode 100644
index 00000000000..3de5db49e00
--- /dev/null
+++ b/lib/open_project/patches/active_record_i18n.rb
@@ -0,0 +1,38 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+module ActiveRecord
+ class Base
+ include Redmine::I18n
+
+ def self.human_attribute_name(attr, options = {})
+ attr = attr.to_s.gsub(/_id\z/, '')
+ super
+ end
+ end
+end
diff --git a/lib/open_project/patches/array.rb b/lib/open_project/patches/array.rb
index 86b13c6f2e4..660810c6243 100644
--- a/lib/open_project/patches/array.rb
+++ b/lib/open_project/patches/array.rb
@@ -1,8 +1 @@
-module OpenProject
- module Patches
- module Array
- end
- end
-end
-
Array.send(:include, Redmine::Diff::Diffable)
diff --git a/config/initializers/eager_load_with_hours.rb b/lib/open_project/patches/eager_load_with_hours.rb
similarity index 100%
rename from config/initializers/eager_load_with_hours.rb
rename to lib/open_project/patches/eager_load_with_hours.rb
diff --git a/config/initializers/i18n_patch.rb b/lib/open_project/patches/i18n_patch.rb
similarity index 100%
rename from config/initializers/i18n_patch.rb
rename to lib/open_project/patches/i18n_patch.rb
diff --git a/lib/open_project/patches/reform.rb b/lib/open_project/patches/reform.rb
index c61835c6e4d..0a1e459263c 100644
--- a/lib/open_project/patches/reform.rb
+++ b/lib/open_project/patches/reform.rb
@@ -52,3 +52,28 @@ module OpenProject
end
end
end
+
+require "reform/form/active_model/validations"
+
+Reform::Form.class_eval do
+ include Reform::Form::ActiveModel::Validations
+end
+
+Reform::Contract.class_eval do
+ include Reform::Form::ActiveModel::Validations
+end
+
+Reform::Form::ActiveModel::Validations::Validator.class_eval do
+ ##
+ # use activerecord as the base scope instead of 'activemodel' to be compatible
+ # to the messages we have already stored
+ def self.i18n_scope
+ :activerecord
+ end
+end
+
+require 'reform/contract'
+
+class Reform::Form::ActiveModel::Errors
+ prepend OpenProject::Patches::Reform
+end
diff --git a/config/initializers/representable_patch.rb b/lib/open_project/patches/representable.rb
similarity index 92%
rename from config/initializers/representable_patch.rb
rename to lib/open_project/patches/representable.rb
index fba29872cb8..5488ee47ee2 100644
--- a/config/initializers/representable_patch.rb
+++ b/lib/open_project/patches/representable.rb
@@ -28,7 +28,7 @@
require 'representable'
-module OpenProject::RepresentablePatch
+module OpenProject::Patches::Representable
def self.included(base)
base.class_eval do
def self.as_strategy=(strategy)
@@ -50,6 +50,6 @@ module OpenProject::RepresentablePatch
end
end
-unless Representable::Decorator.included_modules.include?(OpenProject::RepresentablePatch)
- Representable::Decorator.send(:include, OpenProject::RepresentablePatch)
+unless Representable::Decorator.included_modules.include?(OpenProject::Patches::Representable)
+ Representable::Decorator.send(:include, OpenProject::Patches::Representable)
end