Commit c6f5b48462925a16493db0d865bef4def009e29b
Exists in
master
and in
29 other branches
Merge branch 'plugins-fix-extensions-filters-reload' into 'master'
Plugins: fix extensions and filters reload See commit description. This is needed for the responsive plugin. See merge request !457
Showing
2 changed files
with
13 additions
and
7 deletions
Show diff stats
lib/noosfero/plugin.rb
| ... | ... | @@ -24,11 +24,17 @@ class Noosfero::Plugin |
| 24 | 24 | |
| 25 | 25 | def initialize! |
| 26 | 26 | return if !should_load |
| 27 | - available_plugins.each do |plugin_dir| | |
| 27 | + | |
| 28 | + klasses = available_plugins.map do |plugin_dir| | |
| 28 | 29 | plugin_name = File.basename(plugin_dir) |
| 29 | - plugin = load_plugin(plugin_name) | |
| 30 | - load_plugin_extensions(plugin_dir) | |
| 31 | - load_plugin_filters(plugin) | |
| 30 | + load_plugin plugin_name | |
| 31 | + end | |
| 32 | + available_plugins.each do |plugin_dir| | |
| 33 | + load_plugin_extensions plugin_dir | |
| 34 | + end | |
| 35 | + # filters must be loaded after all extensions | |
| 36 | + klasses.each do |plugin| | |
| 37 | + load_plugin_filters plugin | |
| 32 | 38 | end |
| 33 | 39 | end |
| 34 | 40 | |
| ... | ... | @@ -88,7 +94,7 @@ class Noosfero::Plugin |
| 88 | 94 | # This is a generic method that initialize any possible filter defined by a |
| 89 | 95 | # plugin to a specific controller |
| 90 | 96 | def load_plugin_filters(plugin) |
| 91 | - Rails.configuration.to_prepare do | |
| 97 | + ActionDispatch::Reloader.to_prepare do | |
| 92 | 98 | filters = plugin.new.send 'application_controller_filters' rescue [] |
| 93 | 99 | Noosfero::Plugin.add_controller_filters ApplicationController, plugin, filters |
| 94 | 100 | |
| ... | ... | @@ -116,7 +122,7 @@ class Noosfero::Plugin |
| 116 | 122 | end |
| 117 | 123 | |
| 118 | 124 | def load_plugin_extensions(dir) |
| 119 | - Rails.configuration.to_prepare do | |
| 125 | + ActionDispatch::Reloader.to_prepare do | |
| 120 | 126 | Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } |
| 121 | 127 | end |
| 122 | 128 | end | ... | ... |
lib/noosfero/plugin/spammable.rb