forked from gsamokovarov/web-console
-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathrailtie.rb
71 lines (56 loc) · 2.26 KB
/
railtie.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
# frozen_string_literal: true
require "rails/railtie"
module WebConsole
class Railtie < ::Rails::Railtie
config.web_console = ActiveSupport::OrderedOptions.new
config.web_console.permissions = %w( 127.0.0.1 ::1 )
initializer "web_console.initialize" do
require "bindex"
require "web_console/extensions"
ActionDispatch::DebugExceptions.register_interceptor(Interceptor)
end
initializer "web_console.development_only" do
unless (config.web_console.development_only == false) || Rails.env.development?
abort <<-END.strip_heredoc
Web Console is activated in the #{Rails.env} environment. This is
usually a mistake. To ensure it's only activated in development
mode, move it to the development group of your Gemfile:
gem 'web-console', group: :development
If you still want to run it in the #{Rails.env} environment (and know
what you are doing), put this in your Rails application
configuration:
config.web_console.development_only = false
END
end
end
initializer "web_console.insert_middleware" do |app|
app.middleware.insert_before ActionDispatch::DebugExceptions, Middleware
end
initializer "web_console.mount_point" do
if mount_point = config.web_console.mount_point
Middleware.mount_point = mount_point.chomp("/")
end
if root = Rails.application.config.relative_url_root
Middleware.mount_point = File.join(root, Middleware.mount_point)
end
end
initializer "web_console.template_paths" do
if template_paths = config.web_console.template_paths
Template.template_paths.unshift(*Array(template_paths))
end
end
initializer "web_console.permissions" do
if permissions = config.web_console.permissions || config.web_console.whitelisted_ips
Request.permissions = Permissions.new(permissions)
end
end
initializer "web_console.whiny_requests" do
if config.web_console.key?(:whiny_requests)
Middleware.whiny_requests = config.web_console.whiny_requests
end
end
initializer "i18n.load_path" do
config.i18n.load_path.concat(Dir[File.expand_path("../locales/*.yml", __FILE__)])
end
end
end