Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
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"
|
||||
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
|
||||
%w[
|
||||
../lib/custom_wizard/engine.rb
|
||||
|
@ -97,20 +112,6 @@ after_initialize do
|
|||
load File.expand_path(path, __FILE__)
|
||||
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)
|
||||
|
||||
add_class_method(:wizard, :user_requires_completion?) do |user|
|
||||
|
|
Laden …
In neuem Issue referenzieren