move sprockets logic outside after_initialize
Dieser Commit ist enthalten in:
Ursprung
a4adeecf5f
Commit
eb5e2fe604
1 geänderte Dateien mit 15 neuen und 14 gelöschten Zeilen
29
plugin.rb
29
plugin.rb
|
@ -35,6 +35,21 @@ if respond_to?(:register_svg_icon)
|
||||||
register_svg_icon "save"
|
register_svg_icon "save"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
add_to_class(::Sprockets::DirectiveProcessor, :process_require_tree_discourse_directive) do |path = "."|
|
||||||
|
raise CustomWizard::SprocketsEmptyPath, "path cannot be empty" if path == "."
|
||||||
|
|
||||||
|
discourse_asset_path = "#{Rails.root}/app/assets/javascripts/"
|
||||||
|
path = File.expand_path(path, discourse_asset_path)
|
||||||
|
stat = @environment.stat(path)
|
||||||
|
|
||||||
|
if stat && stat.directory?
|
||||||
|
require_paths(*@environment.stat_sorted_tree_with_dependencies(path))
|
||||||
|
else
|
||||||
|
raise CustomWizard::SprocketsFileNotFound, "#{path} not found in discourse core"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
%w[
|
%w[
|
||||||
../lib/custom_wizard/engine.rb
|
../lib/custom_wizard/engine.rb
|
||||||
|
@ -97,20 +112,6 @@ after_initialize do
|
||||||
load File.expand_path(path, __FILE__)
|
load File.expand_path(path, __FILE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_to_class(::Sprockets::DirectiveProcessor, :process_require_tree_discourse_directive) do |path = "."|
|
|
||||||
raise CustomWizard::SprocketsEmptyPath, "path cannot be empty" if path == "."
|
|
||||||
|
|
||||||
discourse_asset_path = "#{Rails.root}/app/assets/javascripts/"
|
|
||||||
path = File.expand_path(path, discourse_asset_path)
|
|
||||||
stat = @environment.stat(path)
|
|
||||||
|
|
||||||
if stat && stat.directory?
|
|
||||||
require_paths(*@environment.stat_sorted_tree_with_dependencies(path))
|
|
||||||
else
|
|
||||||
raise CustomWizard::SprocketsFileNotFound, "#{path} not found in discourse core"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
|
||||||
|
|
||||||
add_class_method(:wizard, :user_requires_completion?) do |user|
|
add_class_method(:wizard, :user_requires_completion?) do |user|
|
||||||
|
|
Laden …
In neuem Issue referenzieren