-
Notifications
You must be signed in to change notification settings - Fork 256
/
engine.rb
64 lines (51 loc) · 2.1 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
# frozen_string_literal: true
require 'view_component'
module Blacklight
class Engine < Rails::Engine
engine_name "blacklight"
# BlacklightHelper is needed by all helpers, so we inject it
# into action view base here.
initializer 'blacklight.helpers' do
config.after_initialize do
ActionView::Base.include BlacklightHelper
end
end
# This makes our rake tasks visible.
rake_tasks do
Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) do
Dir.glob(File.join('railties', '*.rake')).each do |railtie|
load railtie
end
end
end
initializer "blacklight.assets.precompile" do
# rubocop:disable Lint/ConstantDefinitionInBlock
PRECOMPILE_ASSETS = %w(favicon.ico blacklight/blacklight.js blacklight/blacklight.js.map).freeze
# rubocop:enable Lint/ConstantDefinitionInBlock
# When Rails has been generated in API mode, it does not have sprockets available
if Rails.application.config.respond_to?(:assets)
Rails.application.config.assets.precompile += PRECOMPILE_ASSETS
end
end
bl_global_config = OpenStructWithHashAccess.new
bl_global_config.sms_mappings = {
'Virgin' => 'vmobl.com',
'AT&T' => 'txt.att.net',
'Verizon' => 'vtext.com',
'Nextel' => 'messaging.nextel.com',
'Sprint' => 'messaging.sprintpcs.com',
'T Mobile' => 'tmomail.net',
'Alltel' => 'message.alltel.com',
'Cricket' => 'mms.mycricket.com',
'Google Fi' => 'msg.fi.google.com'
}
bl_global_config.bookmarks_http_method = :post
bl_global_config.email_regexp = defined?(Devise) ? Devise.email_regexp : /\A[^@\s]+@[^@\s]+\z/
bl_global_config.facet_missing_param = '[* TO *]'
# Anything that goes into Blacklight::Engine.config is stored as a class
# variable on Railtie::Configuration. we're going to encapsulate all the
# Blacklight specific stuff in this single struct:
Blacklight::Engine.config.blacklight = bl_global_config
config.action_dispatch.rescue_responses["Blacklight::Exceptions::RecordNotFound"] = :not_found
end
end