blacklight 7.41.0 → 7.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/matrix.json +9 -0
- data/.github/workflows/test.yml +1 -2
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +2 -2
- data/.solr_wrapper.yml +3 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +596 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
- data/app/assets/javascripts/blacklight/blacklight.js +5 -10
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
- data/app/controllers/concerns/blacklight/search_fields.rb +1 -1
- data/blacklight.gemspec +2 -1
- data/config/importmap.rb +3 -0
- data/lib/blacklight/abstract_repository.rb +2 -0
- data/lib/blacklight/configuration/field.rb +6 -6
- data/lib/blacklight/configuration/sort_field.rb +2 -2
- data/lib/blacklight/controller_runtime.rb +42 -0
- data/lib/blacklight/engine.rb +18 -4
- data/lib/blacklight/log_subscriber.rb +25 -0
- data/lib/blacklight/runtime_registry.rb +24 -0
- data/lib/blacklight/solr/repository.rb +15 -10
- data/lib/generators/blacklight/assets/importmap_generator.rb +56 -0
- data/lib/generators/blacklight/assets/propshaft_generator.rb +34 -0
- data/lib/generators/blacklight/assets/sprockets_generator.rb +100 -0
- data/lib/generators/blacklight/assets_generator.rb +9 -86
- data/lib/generators/blacklight/install_generator.rb +2 -2
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +3 -7
- data/package.json +1 -1
- data/spec/controllers/application_controller_spec.rb +23 -0
- data/spec/controllers/blacklight/base_spec.rb +1 -1
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +1 -2
- data/spec/lib/blacklight/runtime_registry_spec.rb +46 -0
- data/spec/models/blacklight/document/dublin_core_spec.rb +2 -2
- data/spec/models/blacklight/solr/repository_spec.rb +69 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/tasks/blacklight.rake +1 -1
- metadata +30 -8
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Assets
|
|
5
|
+
class SprocketsGenerator < Rails::Generators::Base
|
|
6
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 4.0'), desc: "Set the generated app's bootstrap version"
|
|
7
|
+
|
|
8
|
+
def replace_propshaft_with_sprockets
|
|
9
|
+
return if defined?(Sprockets)
|
|
10
|
+
|
|
11
|
+
# Rails 8+ defaults to Propshaft, but Blacklight 7.x JS requires Sprockets
|
|
12
|
+
gsub_file 'Gemfile', /^gem ['"]propshaft['"].*$/, '# \0'
|
|
13
|
+
gem 'sprockets-rails'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_javascript_dependencies
|
|
17
|
+
gem 'bootstrap', options[:'bootstrap-version'].presence
|
|
18
|
+
gem 'jquery-rails'
|
|
19
|
+
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add_sass_support
|
|
23
|
+
gem "sassc-rails", "~> 2.1" if Rails.version > '7'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def setup_sprockets_manifest
|
|
27
|
+
if !defined?(Sprockets)
|
|
28
|
+
# Rails 8+ with Propshaft replaced: create Sprockets config from scratch
|
|
29
|
+
directory = File.expand_path('app/assets/config', destination_root)
|
|
30
|
+
FileUtils.mkdir_p(directory)
|
|
31
|
+
create_file 'app/assets/config/manifest.js' do
|
|
32
|
+
<<~CONTENT
|
|
33
|
+
//= link_tree ../images
|
|
34
|
+
//= link_directory ../stylesheets .css
|
|
35
|
+
//= link application.js
|
|
36
|
+
CONTENT
|
|
37
|
+
end
|
|
38
|
+
empty_directory 'app/assets/images'
|
|
39
|
+
elsif defined?(Sprockets::VERSION) && Sprockets::VERSION >= '4'
|
|
40
|
+
append_to_file 'app/assets/config/manifest.js', "\n//= link application.js"
|
|
41
|
+
empty_directory 'app/assets/images'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def assets # rubocop:disable Metrics/MethodLength
|
|
46
|
+
create_file 'app/assets/stylesheets/blacklight.scss' do
|
|
47
|
+
<<~CONTENT
|
|
48
|
+
@import 'bootstrap';
|
|
49
|
+
@import 'blacklight/blacklight';
|
|
50
|
+
CONTENT
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Ensure application.css is a proper Sprockets manifest that loads blacklight styles
|
|
54
|
+
application_css = File.expand_path('app/assets/stylesheets/application.css', destination_root)
|
|
55
|
+
if File.exist?(application_css)
|
|
56
|
+
content = File.read(application_css)
|
|
57
|
+
unless content.include?('require blacklight')
|
|
58
|
+
create_file 'app/assets/stylesheets/application.css', force: true do
|
|
59
|
+
<<~CONTENT
|
|
60
|
+
/*
|
|
61
|
+
*= require blacklight
|
|
62
|
+
*= require_self
|
|
63
|
+
*/
|
|
64
|
+
CONTENT
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Ensure this method is idempotent
|
|
70
|
+
return if has_blacklight_assets?
|
|
71
|
+
|
|
72
|
+
create_file 'app/assets/javascripts/application.js' do
|
|
73
|
+
<<~CONTENT
|
|
74
|
+
//= require jquery3
|
|
75
|
+
//= require rails-ujs
|
|
76
|
+
|
|
77
|
+
// Required by Blacklight
|
|
78
|
+
//= require popper
|
|
79
|
+
// Twitter Typeahead for autocomplete
|
|
80
|
+
//= require twitter/typeahead
|
|
81
|
+
//= require bootstrap
|
|
82
|
+
//= require blacklight/blacklight
|
|
83
|
+
CONTENT
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def has_blacklight_assets?
|
|
90
|
+
application_js.include?('blacklight/blacklight')
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def application_js
|
|
94
|
+
path = File.expand_path("app/assets/javascripts/application.js", destination_root)
|
|
95
|
+
|
|
96
|
+
File.exist?(path) ? File.read(path) : ''
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -1,94 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
module Blacklight
|
|
3
|
-
class Assets < Rails::Generators::Base
|
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
-
|
|
6
|
-
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 4.0'), desc: "Set the generated app's bootstrap version"
|
|
7
|
-
|
|
8
|
-
# This could be skipped if you want to use webpacker
|
|
9
|
-
def add_javascript_dependencies
|
|
10
|
-
gem 'bootstrap', options[:'bootstrap-version']
|
|
11
|
-
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def appease_rails7
|
|
15
|
-
return unless Rails.version > '7'
|
|
16
|
-
|
|
17
|
-
gem "sassc-rails", "~> 2.1"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Add sprockets javascript if needed
|
|
21
|
-
def create_sprockets_javascript
|
|
22
|
-
create_file 'app/assets/javascripts/application.js' do
|
|
23
|
-
<<~CONTENT
|
|
24
|
-
//= require jquery3
|
|
25
|
-
//= require rails-ujs
|
|
26
|
-
#{'//= require turbolinks' if Rails.version < '7'}
|
|
27
|
-
CONTENT
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
##
|
|
32
|
-
# Remove the empty generated app/assets/images directory. Without doing this,
|
|
33
|
-
# the default Sprockets 4 manifest will raise an exception.
|
|
34
|
-
def appease_sprockets4
|
|
35
|
-
return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4' || using_importmap?
|
|
36
|
-
|
|
37
|
-
append_to_file 'app/assets/config/manifest.js', "\n//= link application.js\n"
|
|
38
|
-
empty_directory 'app/assets/images'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def assets
|
|
42
|
-
copy_file "blacklight.scss", "app/assets/stylesheets/blacklight.scss"
|
|
43
|
-
|
|
44
|
-
# Ensure this method is idempotent
|
|
45
|
-
return if has_blacklight_assets?
|
|
46
2
|
|
|
47
|
-
|
|
48
|
-
contents = "\n//\n// Required by Blacklight\n"
|
|
49
|
-
contents += "//= require popper\n"
|
|
50
|
-
contents += "// Twitter Typeahead for autocomplete\n"
|
|
51
|
-
contents += "//= require twitter/typeahead\n"
|
|
52
|
-
contents += "//= require bootstrap\n"
|
|
53
|
-
contents += "//= require blacklight/blacklight\n"
|
|
3
|
+
require 'shellwords'
|
|
54
4
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'//= require rails-ujs'
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
insert_into_file "app/assets/javascripts/application.js", after: marker do
|
|
62
|
-
contents
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
insert_into_file "app/assets/javascripts/application.js", before: '//= require rails-ujs' do
|
|
66
|
-
"//= require jquery3\n"
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
private
|
|
71
|
-
|
|
72
|
-
def root
|
|
73
|
-
@root ||= Pathname(destination_root)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def using_importmap?
|
|
77
|
-
@using_importmap ||= root.join('config/importmap.rb').exist?
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def turbolinks?
|
|
81
|
-
@turbolinks ||= application_js.include?('turbolinks')
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def has_blacklight_assets?
|
|
85
|
-
application_js.include?('blacklight/blacklight')
|
|
86
|
-
end
|
|
5
|
+
module Blacklight
|
|
6
|
+
class AssetsGenerator < Rails::Generators::Base
|
|
7
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 4.0'), desc: "Set the generated app's bootstrap version"
|
|
87
8
|
|
|
88
|
-
def
|
|
89
|
-
|
|
9
|
+
def run_asset_pipeline_specific_generator
|
|
10
|
+
generated_options = "--bootstrap-version='#{Shellwords.escape(options[:'bootstrap-version'])}'" if options[:'bootstrap-version']
|
|
90
11
|
|
|
91
|
-
|
|
12
|
+
# Blacklight 7.x JS is distributed via Sprockets (//= require directives, jQuery, etc.)
|
|
13
|
+
# so we always use the sprockets generator regardless of what Rails defaulted to.
|
|
14
|
+
generate 'blacklight:assets:sprockets', generated_options
|
|
92
15
|
end
|
|
93
16
|
end
|
|
94
17
|
end
|
|
@@ -11,7 +11,7 @@ module Blacklight
|
|
|
11
11
|
class_option :devise, type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic."
|
|
12
12
|
class_option :marc, type: :boolean, default: false, aliases: "-m", desc: "Generate MARC-based demo."
|
|
13
13
|
class_option :'bootstrap-version', type: :string, default: nil, desc: "Set the generated app's bootstrap version"
|
|
14
|
-
class_option :'skip-assets', type: :boolean, default:
|
|
14
|
+
class_option :'skip-assets', type: :boolean, default: false, desc: "Skip generating javascript and css assets into the application"
|
|
15
15
|
class_option :'skip-solr', type: :boolean, default: false, desc: "Skip generating solr configurations."
|
|
16
16
|
|
|
17
17
|
desc <<-EOS
|
|
@@ -41,7 +41,7 @@ module Blacklight
|
|
|
41
41
|
|
|
42
42
|
def bundle_install
|
|
43
43
|
inside destination_root do
|
|
44
|
-
Bundler.
|
|
44
|
+
Bundler.with_unbundled_env do
|
|
45
45
|
run "bundle install"
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<dataDir>${solr.data.dir:}</dataDir>
|
|
25
25
|
|
|
26
|
-
<requestHandler name="
|
|
26
|
+
<requestHandler name="/select" class="solr.SearchHandler" default="true">
|
|
27
27
|
<!-- default values for query parameters can be specified, these
|
|
28
28
|
will be overridden by parameters in the request
|
|
29
29
|
-->
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
full_title_tsim
|
|
48
48
|
short_title_tsim
|
|
49
49
|
alternative_title_tsim
|
|
50
|
-
active_fedora_model_ssi
|
|
51
50
|
title_tsim
|
|
52
51
|
author_tsim
|
|
53
52
|
subject_tsim
|
|
@@ -84,7 +83,6 @@
|
|
|
84
83
|
<str name="facet">true</str>
|
|
85
84
|
<str name="facet.mincount">1</str>
|
|
86
85
|
<str name="facet.limit">10</str>
|
|
87
|
-
<str name="facet.field">active_fedora_model_ssi</str>
|
|
88
86
|
<str name="facet.field">subject_ssim</str>
|
|
89
87
|
|
|
90
88
|
<str name="spellcheck">true</str>
|
|
@@ -116,7 +114,6 @@
|
|
|
116
114
|
full_title_tsim
|
|
117
115
|
short_title_tsim
|
|
118
116
|
alternative_title_tsim
|
|
119
|
-
active_fedora_model_ssi
|
|
120
117
|
title_tsim
|
|
121
118
|
author_tsim
|
|
122
119
|
subject_tsim
|
|
@@ -153,7 +150,6 @@
|
|
|
153
150
|
<str name="facet">true</str>
|
|
154
151
|
<str name="facet.mincount">1</str>
|
|
155
152
|
<str name="facet.limit">10</str>
|
|
156
|
-
<str name="facet.field">active_fedora_model_ssi</str>
|
|
157
153
|
<str name="facet.field">subject_ssim</str>
|
|
158
154
|
|
|
159
155
|
<str name="spellcheck">true</str>
|
|
@@ -257,8 +253,8 @@
|
|
|
257
253
|
|
|
258
254
|
<requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />
|
|
259
255
|
|
|
260
|
-
<requestDispatcher
|
|
261
|
-
<requestParsers
|
|
256
|
+
<requestDispatcher>
|
|
257
|
+
<requestParsers multipartUploadLimitInKB="2048" />
|
|
262
258
|
</requestDispatcher>
|
|
263
259
|
|
|
264
260
|
<requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
|
data/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe ApplicationController do
|
|
4
|
+
describe ".log_process_action" do
|
|
5
|
+
it "appends Solr runtime to the messages ActiveRecord/ActionController already log" do
|
|
6
|
+
messages = described_class.log_process_action(solr_runtime: 45.3, solr_query_count: 2)
|
|
7
|
+
expect(messages).to include("Solr: 45.3ms (2 queries)")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "uses singular 'query' for a single Solr request" do
|
|
11
|
+
messages = described_class.log_process_action(solr_runtime: 12.0, solr_query_count: 1)
|
|
12
|
+
expect(messages).to include("Solr: 12.0ms (1 query)")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "does not add a message when no Solr request was made" do
|
|
16
|
+
messages = described_class.log_process_action({})
|
|
17
|
+
expect(messages.grep(/Solr/)).to be_empty
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "does not add a message when the payload reports zero Solr queries" do
|
|
21
|
+
# Stats#solr_runtime defaults to 0.0 (truthy, never nil) - query count is the real "did Solr get queried" signal.
|
|
22
|
+
messages = described_class.log_process_action(solr_runtime: 0.0, solr_query_count: 0)
|
|
23
|
+
expect(messages.grep(/Solr/)).to be_empty
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
4
27
|
describe "#blacklight_config" do
|
|
5
28
|
it "provides a default blacklight_config everywhere" do
|
|
6
29
|
expect(controller.blacklight_config).to eq CatalogController.blacklight_config
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec.describe Blacklight::Base do
|
|
4
4
|
subject { controller }
|
|
5
5
|
|
|
6
|
-
let(:controller) { Deprecation.silence(described_class) {
|
|
6
|
+
let(:controller) { Deprecation.silence(described_class) { Class.new(ApplicationController) { include Blacklight::Base }.new } }
|
|
7
7
|
|
|
8
8
|
describe "#search_state" do
|
|
9
9
|
subject { controller.send(:search_state) }
|
|
@@ -231,8 +231,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
|
231
231
|
context "when one of the facet items is rendered as nil" do
|
|
232
232
|
# An app may override render_facet_item to filter out some undesired facet items by returning nil.
|
|
233
233
|
before do
|
|
234
|
-
|
|
235
|
-
# allow_any_instance_of(Blacklight::FacetItemComponent).to receive(:overridden_helper_methods?).and_return(true)
|
|
234
|
+
allow_any_instance_of Blacklight::FacetItemComponent.to receive(:overridden_helper_methods?).and_return(true) # rubocop:disable RSpec/AnyInstance
|
|
236
235
|
allow(helper).to receive(:render_facet_item).and_return('<a class="facet-select">Book</a>'.html_safe, nil)
|
|
237
236
|
end
|
|
238
237
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Blacklight::RuntimeRegistry do
|
|
4
|
+
before { described_class.stats.reset }
|
|
5
|
+
|
|
6
|
+
describe ".call" do
|
|
7
|
+
it "accumulates the event's duration into stats.solr_runtime" do
|
|
8
|
+
described_class.call("solr_request.blacklight", 0.0, 0.0125, nil, {})
|
|
9
|
+
|
|
10
|
+
expect(described_class.stats.solr_runtime).to eq 12.5
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "increments stats.solr_query_count" do
|
|
14
|
+
described_class.call("solr_request.blacklight", 0.0, 0.0125, nil, {})
|
|
15
|
+
described_class.call("solr_request.blacklight", 0.0, 0.0125, nil, {})
|
|
16
|
+
|
|
17
|
+
expect(described_class.stats.solr_query_count).to eq 2
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe ".stats" do
|
|
22
|
+
it "is thread-local" do
|
|
23
|
+
described_class.call("solr_request.blacklight", 0.0, 0.0125, nil, {})
|
|
24
|
+
|
|
25
|
+
Thread.new { expect(described_class.stats.solr_runtime).to eq 0.0 }.join
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "Stats#reset" do
|
|
30
|
+
it "clears the accumulated runtime and query count" do
|
|
31
|
+
stats = described_class.stats
|
|
32
|
+
described_class.call("solr_request.blacklight", 0.0, 0.0125, nil, {})
|
|
33
|
+
|
|
34
|
+
stats.reset
|
|
35
|
+
|
|
36
|
+
expect(stats.solr_runtime).to eq 0.0
|
|
37
|
+
expect(stats.solr_query_count).to eq 0
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "subscribed to solr_request.blacklight notifications" do
|
|
42
|
+
it "fires without raising (Blacklight::Engine subscribes this at boot)" do
|
|
43
|
+
expect { ActiveSupport::Notifications.instrument("solr_request.blacklight") }.not_to raise_error
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -25,8 +25,8 @@ RSpec.describe "Blacklight::Document::DublinCore" do
|
|
|
25
25
|
it "includes 'dc:'-prefixed semantic fields" do
|
|
26
26
|
data = { 'id' => '123456', 'title_tsim' => ['654321'] }
|
|
27
27
|
document = @mock_class.new(data)
|
|
28
|
-
expect(document.export_as_oai_dc_xml).to match
|
|
29
|
-
expect(document.export_as_oai_dc_xml).to match
|
|
28
|
+
expect(document.export_as_oai_dc_xml).to match 'xmlns:dc="http://purl.org/dc/elements/1.1/"'
|
|
29
|
+
expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "works with multi-value fields" do
|
|
@@ -135,6 +135,31 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
|
135
135
|
end.and_return('response' => { 'docs' => [] })
|
|
136
136
|
subject.search(input_params)
|
|
137
137
|
end
|
|
138
|
+
|
|
139
|
+
it "instruments the request with ActiveSupport::Notifications" do
|
|
140
|
+
allow(subject.connection).to receive(:send_and_receive).and_return(mock_response)
|
|
141
|
+
|
|
142
|
+
payload = nil
|
|
143
|
+
callback = ->(event) { payload = event.payload }
|
|
144
|
+
ActiveSupport::Notifications.subscribed(callback, "solr_request.blacklight") do
|
|
145
|
+
subject.search(params: {})
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
expect(payload).to include(path: 'select', method: :get)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "instruments a json query dsl request as post, regardless of http_method configuration" do
|
|
152
|
+
blacklight_config.http_method = :get
|
|
153
|
+
allow(subject.connection).to receive(:send_and_receive).and_return(mock_response)
|
|
154
|
+
|
|
155
|
+
payload = nil
|
|
156
|
+
callback = ->(event) { payload = event.payload }
|
|
157
|
+
ActiveSupport::Notifications.subscribed(callback, "solr_request.blacklight") do
|
|
158
|
+
subject.search(params: { json: { query: 'foo' } })
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
expect(payload).to include(method: :post)
|
|
162
|
+
end
|
|
138
163
|
end
|
|
139
164
|
|
|
140
165
|
describe "#build_solr_request" do
|
|
@@ -214,5 +239,49 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
|
214
239
|
subject { repository.ping }
|
|
215
240
|
|
|
216
241
|
it { is_expected.to be true }
|
|
242
|
+
|
|
243
|
+
it "instruments the request with ActiveSupport::Notifications" do
|
|
244
|
+
payload = nil
|
|
245
|
+
callback = ->(event) { payload = event.payload }
|
|
246
|
+
ActiveSupport::Notifications.subscribed(callback, "solr_request.blacklight") do
|
|
247
|
+
repository.ping
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
expect(payload).to include(path: 'admin/ping', method: :get)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
describe "debug logging" do
|
|
255
|
+
let(:io) { StringIO.new }
|
|
256
|
+
let(:test_logger) { Logger.new(io, level: Logger::DEBUG) }
|
|
257
|
+
|
|
258
|
+
before do
|
|
259
|
+
allow(Blacklight).to receive(:logger).and_return(test_logger)
|
|
260
|
+
allow(subject.connection).to receive(:send_and_receive).and_return(mock_response)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it "logs the solr query at debug, never at info" do
|
|
264
|
+
subject.search(params: { q: 'test' })
|
|
265
|
+
|
|
266
|
+
expect(io.string).to include("test")
|
|
267
|
+
expect(io.string).not_to include("INFO")
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it "does not log the full response by default" do
|
|
271
|
+
subject.search(params: { q: 'test' })
|
|
272
|
+
|
|
273
|
+
expect(io.string).not_to include("Solr response")
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
context "when BLACKLIGHT_VERBOSE_LOGGING is set" do
|
|
277
|
+
before { stub_const('BLACKLIGHT_VERBOSE_LOGGING', true) }
|
|
278
|
+
|
|
279
|
+
it "logs the full response at debug, never at info" do
|
|
280
|
+
subject.search(params: { q: 'test' })
|
|
281
|
+
|
|
282
|
+
expect(io.string).to include("Solr response")
|
|
283
|
+
expect(io.string).not_to include("INFO")
|
|
284
|
+
end
|
|
285
|
+
end
|
|
217
286
|
end
|
|
218
287
|
end
|
data/tasks/blacklight.rake
CHANGED
|
@@ -24,7 +24,7 @@ def with_solr
|
|
|
24
24
|
# We're being invoked by the app entrypoint script and solr is already up via docker compose
|
|
25
25
|
if ENV['SOLR_ENV'] == 'docker-compose'
|
|
26
26
|
yield
|
|
27
|
-
elsif system('docker compose
|
|
27
|
+
elsif system('docker compose version')
|
|
28
28
|
# We're not running `docker compose up' but still want to use a docker instance of solr.
|
|
29
29
|
begin
|
|
30
30
|
puts "Starting Solr"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blacklight
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.43.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Rochkind
|
|
@@ -14,10 +14,9 @@ authors:
|
|
|
14
14
|
- Dan Funk
|
|
15
15
|
- Naomi Dushay
|
|
16
16
|
- Justin Coyne
|
|
17
|
-
autorequire:
|
|
18
17
|
bindir: exe
|
|
19
18
|
cert_chain: []
|
|
20
|
-
date:
|
|
19
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
21
20
|
dependencies:
|
|
22
21
|
- !ruby/object:Gem::Dependency
|
|
23
22
|
name: rails
|
|
@@ -28,7 +27,7 @@ dependencies:
|
|
|
28
27
|
version: '6.1'
|
|
29
28
|
- - "<"
|
|
30
29
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: '
|
|
30
|
+
version: '9'
|
|
32
31
|
type: :runtime
|
|
33
32
|
prerelease: false
|
|
34
33
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -38,7 +37,7 @@ dependencies:
|
|
|
38
37
|
version: '6.1'
|
|
39
38
|
- - "<"
|
|
40
39
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
40
|
+
version: '9'
|
|
42
41
|
- !ruby/object:Gem::Dependency
|
|
43
42
|
name: globalid
|
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,6 +66,20 @@ dependencies:
|
|
|
67
66
|
- - "~>"
|
|
68
67
|
- !ruby/object:Gem::Version
|
|
69
68
|
version: '2.7'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: json
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "<"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "<"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.0'
|
|
70
83
|
- !ruby/object:Gem::Dependency
|
|
71
84
|
name: kaminari
|
|
72
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -440,7 +453,10 @@ files:
|
|
|
440
453
|
- app/assets/images/blacklight/logo.png
|
|
441
454
|
- app/assets/images/blacklight/search.svg
|
|
442
455
|
- app/assets/images/favicon.ico
|
|
456
|
+
- app/assets/javascripts/blacklight/blacklight.esm.js
|
|
457
|
+
- app/assets/javascripts/blacklight/blacklight.esm.js.map
|
|
443
458
|
- app/assets/javascripts/blacklight/blacklight.js
|
|
459
|
+
- app/assets/javascripts/blacklight/blacklight.js.map
|
|
444
460
|
- app/assets/stylesheets/blacklight/_balanced_list.scss
|
|
445
461
|
- app/assets/stylesheets/blacklight/_blacklight_base.scss
|
|
446
462
|
- app/assets/stylesheets/blacklight/_bookmark.scss
|
|
@@ -729,6 +745,7 @@ files:
|
|
|
729
745
|
- app/views/shared/_user_util_links.html.erb
|
|
730
746
|
- blacklight.gemspec
|
|
731
747
|
- config/i18n-tasks.yml
|
|
748
|
+
- config/importmap.rb
|
|
732
749
|
- config/locales/blacklight.ar.yml
|
|
733
750
|
- config/locales/blacklight.ca.yml
|
|
734
751
|
- config/locales/blacklight.de.yml
|
|
@@ -762,10 +779,12 @@ files:
|
|
|
762
779
|
- lib/blacklight/configuration/sort_field.rb
|
|
763
780
|
- lib/blacklight/configuration/tool_config.rb
|
|
764
781
|
- lib/blacklight/configuration/view_config.rb
|
|
782
|
+
- lib/blacklight/controller_runtime.rb
|
|
765
783
|
- lib/blacklight/deprecations/engine_configuration.rb
|
|
766
784
|
- lib/blacklight/deprecations/search_state_normalization.rb
|
|
767
785
|
- lib/blacklight/engine.rb
|
|
768
786
|
- lib/blacklight/exceptions.rb
|
|
787
|
+
- lib/blacklight/log_subscriber.rb
|
|
769
788
|
- lib/blacklight/nested_open_struct_with_hash_access.rb
|
|
770
789
|
- lib/blacklight/open_struct_with_hash_access.rb
|
|
771
790
|
- lib/blacklight/parameters.rb
|
|
@@ -792,6 +811,9 @@ files:
|
|
|
792
811
|
- lib/blacklight/solr/response/spelling.rb
|
|
793
812
|
- lib/blacklight/solr/search_builder_behavior.rb
|
|
794
813
|
- lib/blacklight/version.rb
|
|
814
|
+
- lib/generators/blacklight/assets/importmap_generator.rb
|
|
815
|
+
- lib/generators/blacklight/assets/propshaft_generator.rb
|
|
816
|
+
- lib/generators/blacklight/assets/sprockets_generator.rb
|
|
795
817
|
- lib/generators/blacklight/assets_generator.rb
|
|
796
818
|
- lib/generators/blacklight/controller_generator.rb
|
|
797
819
|
- lib/generators/blacklight/document_generator.rb
|
|
@@ -904,6 +926,7 @@ files:
|
|
|
904
926
|
- spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb
|
|
905
927
|
- spec/lib/blacklight/open_struct_with_hash_access_spec.rb
|
|
906
928
|
- spec/lib/blacklight/parameters_spec.rb
|
|
929
|
+
- spec/lib/blacklight/runtime_registry_spec.rb
|
|
907
930
|
- spec/lib/blacklight/search_state/filter_field_spec.rb
|
|
908
931
|
- spec/lib/blacklight/search_state_spec.rb
|
|
909
932
|
- spec/lib/blacklight_spec.rb
|
|
@@ -997,7 +1020,6 @@ homepage: http://projectblacklight.org/
|
|
|
997
1020
|
licenses:
|
|
998
1021
|
- Apache 2.0
|
|
999
1022
|
metadata: {}
|
|
1000
|
-
post_install_message:
|
|
1001
1023
|
rdoc_options: []
|
|
1002
1024
|
require_paths:
|
|
1003
1025
|
- lib
|
|
@@ -1012,8 +1034,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1012
1034
|
- !ruby/object:Gem::Version
|
|
1013
1035
|
version: '0'
|
|
1014
1036
|
requirements: []
|
|
1015
|
-
rubygems_version:
|
|
1016
|
-
signing_key:
|
|
1037
|
+
rubygems_version: 4.0.18
|
|
1017
1038
|
specification_version: 4
|
|
1018
1039
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
|
1019
1040
|
index.
|
|
@@ -1094,6 +1115,7 @@ test_files:
|
|
|
1094
1115
|
- spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb
|
|
1095
1116
|
- spec/lib/blacklight/open_struct_with_hash_access_spec.rb
|
|
1096
1117
|
- spec/lib/blacklight/parameters_spec.rb
|
|
1118
|
+
- spec/lib/blacklight/runtime_registry_spec.rb
|
|
1097
1119
|
- spec/lib/blacklight/search_state/filter_field_spec.rb
|
|
1098
1120
|
- spec/lib/blacklight/search_state_spec.rb
|
|
1099
1121
|
- spec/lib/blacklight_spec.rb
|