/
engine.rb
100 lines (83 loc) · 3.25 KB
/
engine.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
module Locomotive
class Engine < ::Rails::Engine
isolate_namespace Locomotive
paths['mongodb/migrate'] = 'mongodb/migrate'
# Allow the root app to change the behavior of Locomotive controllers and
# models in a clean way.
config.to_prepare do
Dir.glob(Rails.root + 'app/decorators/**/*_decorator*.rb').each do |c|
require_dependency(c)
end
end
initializer 'locomotive.mongoid' do
# https://jira.mongodb.org/browse/MONGOID-5260?jql=text%20~%20%22pluck%20localized%22
::Mongoid.legacy_pluck_distinct = true
end
initializer 'locomotive.params.filter' do |app|
# Do not log remote_<field>_url params because they can contain huge base64 string
app.config.filter_parameters += [/\Aremote_.+_url\Z/]
end
initializer 'locomotive.action_controller' do |app|
::ActionController::Base.wrap_parameters format: [:json]
end
# initializer 'locomotive.devise' do |app|
# ::DeviseController.respond_to :html, :json
# end
initializer 'locomotive.inflectors' do |app|
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'API'
end
end
initializer 'locomotive.assets' do |app|
app.config.assets.paths << root.join('vendor', 'assets', 'components', 'locomotive')
end
initializer 'locomotive.precompile.hook', group: :all do |app|
app.config.assets.precompile += %w(
locomotive_manifest.js
locomotive/icons/flags/*.png
locomotive/*.png
locomotive/*.gif
locomotive/bootstrap-colorpicker/saturation.png
locomotive/bootstrap-colorpicker/alpha-horizontal.png
locomotive/bootstrap-colorpicker/alpha.png
locomotive/bootstrap-colorpicker/hue-horizontal.png
locomotive/bootstrap-colorpicker/hue.png
locomotive/wysihtml5_reset.css
locomotive/wysihtml5_editor.css
locomotive.js
locomotive.css
locomotive/account.js
locomotive/account.css
locomotive/editor.js
locomotive/editor.css
locomotive/live_editing_iframe.css
locomotive/live_editing_error.css
locomotive/error.css)
# Uncomment the lines below to view the names of assets as they are
# precompiled for the rails asset pipeline
# def compile_asset?(path)
# puts "Compiling: #{path}"
# true
# end
# app.config.assets.precompile = [ method(:compile_asset?).to_proc ]
end
initializer 'locomotive.middlewares' do |app|
require 'locomotive/middlewares'
# Note: "insert 4" means inserting after Rack::Lock
# specifying Rack::Lock caused an error in production.
app.middleware.insert 4, ::Locomotive::Middlewares::ImageThumbnail
app.middleware.use ::Locomotive::Middlewares::Site
end
initializer 'locomotive.i18n' do |app|
app.config.i18n.available_locales = Locomotive.config.locales
end
initializer 'locomotive.notifications' do
ActiveSupport::Notifications.subscribe('steam.serve.url_redirection') do |name, start, finish, id, payload|
Locomotive::Site.inc_url_redirection_counter(payload[:site_id], payload[:url])
end
end
initializer 'steam' do |app|
require 'locomotive/steam_adaptor'
end
end
end