2018-10-08 21:44:25 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-05 00:43:11 +00:00
|
|
|
require "rails"
|
|
|
|
require "action_controller/railtie"
|
|
|
|
require "active_record/railtie"
|
|
|
|
require "active_storage/engine"
|
|
|
|
|
|
|
|
require "action_text"
|
2018-02-07 18:43:36 +00:00
|
|
|
|
2018-04-13 23:23:04 +00:00
|
|
|
module ActionText
|
2018-02-07 18:43:36 +00:00
|
|
|
class Engine < Rails::Engine
|
2018-04-13 23:23:04 +00:00
|
|
|
isolate_namespace ActionText
|
|
|
|
config.eager_load_namespaces << ActionText
|
2018-02-08 20:48:45 +00:00
|
|
|
|
2018-04-13 23:23:04 +00:00
|
|
|
initializer "action_text.attribute" do
|
2018-02-08 20:48:45 +00:00
|
|
|
ActiveSupport.on_load(:active_record) do
|
2018-04-13 23:23:04 +00:00
|
|
|
include ActionText::Attribute
|
2018-02-08 20:48:45 +00:00
|
|
|
end
|
|
|
|
end
|
2018-02-12 15:16:49 +00:00
|
|
|
|
2019-01-05 00:43:11 +00:00
|
|
|
initializer "action_text.attachable" do
|
2018-10-04 02:23:02 +00:00
|
|
|
ActiveSupport.on_load(:active_storage_blob) do
|
2018-04-13 23:23:04 +00:00
|
|
|
include ActionText::Attachable
|
2018-02-12 23:21:49 +00:00
|
|
|
|
|
|
|
def previewable_attachable?
|
|
|
|
representable?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-13 23:23:04 +00:00
|
|
|
initializer "action_text.helper" do
|
2018-02-12 15:16:49 +00:00
|
|
|
ActiveSupport.on_load(:action_controller_base) do
|
2018-10-03 18:41:47 +00:00
|
|
|
helper ActionText::Engine.helpers
|
2018-02-12 15:16:49 +00:00
|
|
|
end
|
|
|
|
end
|
2018-02-14 14:43:49 +00:00
|
|
|
|
2019-01-05 21:59:54 +00:00
|
|
|
initializer "action_text.renderer" do |app|
|
|
|
|
app.executor.to_run { ActionText::Content.renderer = ApplicationController.renderer }
|
|
|
|
app.executor.to_complete { ActionText::Content.renderer = ApplicationController.renderer }
|
|
|
|
|
2019-01-05 00:43:11 +00:00
|
|
|
ActiveSupport.on_load(:action_text_content) do
|
2019-01-05 21:59:54 +00:00
|
|
|
self.renderer = ApplicationController.renderer
|
2019-01-05 00:43:11 +00:00
|
|
|
end
|
2018-04-13 23:09:39 +00:00
|
|
|
|
2019-01-05 00:43:11 +00:00
|
|
|
ActiveSupport.on_load(:action_controller_base) do
|
2019-01-05 21:59:54 +00:00
|
|
|
before_action { ActionText::Content.renderer = ApplicationController.renderer.new(request.env) }
|
2018-02-14 14:43:49 +00:00
|
|
|
end
|
|
|
|
end
|
2019-05-13 16:44:06 +00:00
|
|
|
|
|
|
|
initializer "action_text.system_test_helper" do
|
|
|
|
ActiveSupport.on_load(:action_dispatch_system_test_case) do
|
|
|
|
require "action_text/system_test_helper"
|
|
|
|
include ActionText::SystemTestHelper
|
|
|
|
end
|
|
|
|
end
|
2018-02-07 18:43:36 +00:00
|
|
|
end
|
|
|
|
end
|