blacklight 9.2.1 → 9.3.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 +4 -4
- data/.github/workflows/build.yml +3 -0
- data/.github/workflows/lint.yml +17 -2
- data/.github/workflows/main.yml +3 -0
- data/.github/workflows/release_7_x_scheduled.yml +3 -0
- data/.github/workflows/release_8_x_scheduled.yml +3 -0
- data/.github/workflows/test.yml +3 -2
- data/.gitignore +0 -1
- data/.prettierignore +5 -0
- data/.prettierrc.json +4 -0
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +0 -143
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +39 -9
- data/app/assets/javascripts/blacklight/blacklight.esm.js +207 -125
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +207 -125
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_search_results.scss +24 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +18 -3
- data/app/components/blacklight/constraints_component.rb +2 -1
- data/app/components/blacklight/facet_field_component.rb +1 -1
- data/app/components/blacklight/open_graph_metadata_component.rb +33 -0
- data/app/components/blacklight/search/sidebar_component.html.erb +2 -2
- data/app/components/blacklight/search/sidebar_component.rb +3 -2
- data/app/controllers/concerns/blacklight/catalog.rb +3 -5
- data/app/controllers/concerns/blacklight/controller.rb +2 -6
- data/app/controllers/concerns/blacklight/search_context.rb +2 -7
- data/app/controllers/concerns/blacklight/token_based_user.rb +2 -6
- data/app/helpers/blacklight/catalog_helper_behavior.rb +9 -9
- data/app/helpers/blacklight/url_helper_behavior.rb +2 -7
- data/app/javascript/blacklight-frontend/bookmark_toggle.js +10 -8
- data/app/javascript/blacklight-frontend/checkbox_submit.js +42 -33
- data/app/javascript/blacklight-frontend/color_theme_switcher.js +47 -16
- data/app/javascript/blacklight-frontend/core.js +18 -19
- data/app/javascript/blacklight-frontend/debounce.js +7 -5
- data/app/javascript/blacklight-frontend/facet_suggest.js +27 -25
- data/app/javascript/blacklight-frontend/index.js +1 -1
- data/app/javascript/blacklight-frontend/modal.js +69 -52
- data/app/javascript/blacklight-frontend/search_context.js +36 -17
- data/app/models/blacklight/facet_paginator.rb +1 -3
- data/app/presenters/blacklight/document_presenter.rb +10 -1
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -3
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +0 -8
- data/app/presenters/blacklight/json_presenter.rb +1 -3
- data/app/presenters/blacklight/open_graph_presenter.rb +34 -0
- data/app/presenters/blacklight/thumbnail_presenter.rb +24 -1
- data/app/services/blacklight/field_retriever.rb +1 -3
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/catalog/_document.atom.builder +3 -5
- data/app/views/catalog/_show_main_content.html.erb +1 -0
- data/app/views/catalog/index.atom.builder +8 -4
- data/app/views/layouts/blacklight/base.html.erb +7 -1
- data/config/i18n-tasks.yml +1 -1
- data/config/locales/blacklight.ja.yml +256 -0
- data/lib/blacklight/configuration/context.rb +1 -1
- data/lib/blacklight/configuration/fields.rb +3 -9
- data/lib/blacklight/configuration/view_config.rb +16 -0
- data/lib/blacklight/configuration.rb +6 -2
- data/lib/blacklight/engine.rb +2 -4
- data/lib/blacklight/search_builder.rb +4 -4
- data/lib/blacklight/search_state/filter_field.rb +0 -1
- data/lib/blacklight/search_state.rb +2 -6
- data/lib/blacklight/solr/facet_paginator.rb +1 -1
- data/lib/blacklight/solr/repository.rb +1 -3
- data/lib/blacklight/solr/response/facets.rb +11 -9
- data/lib/blacklight/solr/response/spelling.rb +51 -47
- data/lib/blacklight/solr/search_builder_behavior.rb +14 -15
- data/lib/blacklight.rb +3 -9
- data/lib/generators/blacklight/assets/importmap_generator.rb +3 -3
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/railties/blacklight.rake +3 -5
- data/package-lock.json +1054 -0
- data/package.json +7 -4
- data/rollup.config.js +5 -7
- data/spec/components/blacklight/constraints_component_spec.rb +23 -1
- data/spec/components/blacklight/document/page_header_component_spec.rb +4 -4
- data/spec/components/blacklight/document_component_spec.rb +16 -3
- data/spec/components/blacklight/metadata_field_component_spec.rb +2 -2
- data/spec/components/blacklight/response/spellcheck_component_spec.rb +2 -2
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +1 -1
- data/spec/components/blacklight/system/dropdown_component_spec.rb +1 -2
- data/spec/controllers/bookmarks_controller_spec.rb +3 -9
- data/spec/controllers/catalog_controller_spec.rb +56 -26
- data/spec/features/dark_mode_spec.rb +30 -0
- data/spec/features/did_you_mean_spec.rb +1 -1
- data/spec/features/facet_missing_spec.rb +3 -3
- data/spec/features/modal_spec.rb +2 -2
- data/spec/features/open_graph_spec.rb +43 -0
- data/spec/features/search_context_spec.rb +1 -1
- data/spec/fixtures/sample_solr_documents.yml +6 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +11 -8
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +5 -5
- data/spec/helpers/blacklight_helper_spec.rb +6 -4
- data/spec/helpers/catalog_helper_spec.rb +34 -8
- data/spec/lib/blacklight/configuration/session_tracking_config_spec.rb +2 -2
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +2 -2
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +1 -1
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +1 -1
- data/spec/lib/blacklight/search_state_spec.rb +14 -19
- data/spec/lib/blacklight_spec.rb +5 -5
- data/spec/models/blacklight/configuration_spec.rb +1 -1
- data/spec/models/blacklight/document/cache_key_spec.rb +32 -12
- data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
- data/spec/models/blacklight/icon_spec.rb +3 -3
- data/spec/models/blacklight/search_builder_spec.rb +21 -16
- data/spec/models/blacklight/solr/default_filter_query_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/document_spec.rb +8 -8
- data/spec/models/blacklight/solr/response/facets_spec.rb +5 -5
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -1
- data/spec/models/blacklight/solr/response_spec.rb +18 -3
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +46 -7
- data/spec/models/blacklight/suggest_search_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +2 -2
- data/spec/models/search_spec.rb +7 -7
- data/spec/presenters/blacklight/document_presenter_spec.rb +19 -6
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +4 -4
- data/spec/presenters/blacklight/field_presenter_spec.rb +12 -9
- data/spec/presenters/blacklight/open_graph_presenter_spec.rb +56 -0
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +3 -3
- data/spec/presenters/blacklight/thumbnail_presenter_spec.rb +129 -13
- data/spec/routing/catalog_routing_spec.rb +1 -1
- data/spec/services/blacklight/field_retriever_spec.rb +1 -1
- data/spec/services/blacklight/search_service_spec.rb +8 -8
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -3
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +16 -20
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +1 -1
- metadata +12 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Blacklight::OpenGraphPresenter, type: :presenter do
|
|
4
|
+
subject(:open_graph) { described_class.new(document_presenter) }
|
|
5
|
+
|
|
6
|
+
let(:view_context) { controller.view_context }
|
|
7
|
+
let(:document) { SolrDocument.new(id: 'xyz') }
|
|
8
|
+
let(:thumbnail_url) { 'http://example.com/image.jpg' }
|
|
9
|
+
let(:thumbnail) { instance_double(Blacklight::ThumbnailPresenter, url: thumbnail_url) }
|
|
10
|
+
let(:document_presenter) do
|
|
11
|
+
instance_double(Blacklight::ShowPresenter, document: document, view_context: view_context, configuration: Blacklight::Configuration.new,
|
|
12
|
+
html_title: 'A title', thumbnail: thumbnail)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#properties' do
|
|
16
|
+
it 'derives properties from the document presenter' do
|
|
17
|
+
expect(open_graph.properties).to eq(
|
|
18
|
+
'og:type' => 'website',
|
|
19
|
+
'og:title' => 'A title',
|
|
20
|
+
'og:image' => 'http://example.com/image.jpg'
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'when the document has no thumbnail url' do
|
|
25
|
+
let(:thumbnail_url) { nil }
|
|
26
|
+
|
|
27
|
+
it 'leaves out og:image' do
|
|
28
|
+
expect(open_graph.properties).not_to have_key 'og:image'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'with a subclass that provides a description' do
|
|
33
|
+
subject(:open_graph) { custom_presenter_class.new(document_presenter) }
|
|
34
|
+
|
|
35
|
+
let(:custom_presenter_class) do
|
|
36
|
+
Class.new(described_class) do
|
|
37
|
+
def description = 'A description'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'includes og:description' do
|
|
42
|
+
expect(open_graph.properties).to include 'og:description' => 'A description'
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '#image' do
|
|
48
|
+
context 'with a path' do
|
|
49
|
+
let(:thumbnail_url) { '/images/thumbnail.jpg' }
|
|
50
|
+
|
|
51
|
+
it 'returns an absolute url' do
|
|
52
|
+
expect(open_graph.image).to eq 'http://test.host/images/thumbnail.jpg'
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -32,7 +32,7 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
|
32
32
|
.with(values, field_config, document, context, described_class.operations, options)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
context 'outside of an HTML context' do
|
|
35
|
+
context 'when outside of an HTML context' do
|
|
36
36
|
context 'when options determines format' do
|
|
37
37
|
let(:options) { { format: 'text' } }
|
|
38
38
|
|
|
@@ -74,7 +74,7 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
|
74
74
|
expect(rendered).to eq ["<a href=/catalog?f[format][]=book>book</a>", "<a href=/catalog?f[format][]=manuscript>manuscript</a>"]
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
context 'outside html context' do
|
|
77
|
+
context 'when outside html context' do
|
|
78
78
|
let(:values) { %w[book manuscript] }
|
|
79
79
|
let(:field_config) { Blacklight::Configuration::Field.new(field: 'format', link_to_facet: true) }
|
|
80
80
|
let(:search_state) { Blacklight::SearchState.new({ format: 'json' }, CatalogController.blacklight_config, CatalogController.new) }
|
|
@@ -145,7 +145,7 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
context 'outside the html context' do
|
|
148
|
+
context 'when outside the html context' do
|
|
149
149
|
let(:values) { %w[a b <c] }
|
|
150
150
|
let(:field_config) { Blacklight::Configuration::Field.new(join: true) }
|
|
151
151
|
let(:options) { { format: 'json' } }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
RSpec.describe Blacklight::ThumbnailPresenter do
|
|
3
|
+
RSpec.describe Blacklight::ThumbnailPresenter, type: :presenter do
|
|
4
4
|
include Capybara::RSpecMatchers
|
|
5
5
|
|
|
6
|
-
let(:view_context) {
|
|
6
|
+
let(:view_context) { controller.view_context }
|
|
7
7
|
let(:config) { Blacklight::Configuration.new.view_config(:index) }
|
|
8
8
|
let(:presenter) { described_class.new(document, view_context, config) }
|
|
9
9
|
let(:document) { SolrDocument.new }
|
|
@@ -24,13 +24,13 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
24
24
|
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: :xyz)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
context "
|
|
27
|
+
context "when the field exists in the document" do
|
|
28
28
|
let(:document) { SolrDocument.new('xyz' => 'image.png') }
|
|
29
29
|
|
|
30
30
|
it { is_expected.to be true }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
context "
|
|
33
|
+
context "when the field is missing from the document" do
|
|
34
34
|
it { is_expected.to be false }
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -40,7 +40,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
40
40
|
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: [:rst, :uvw, :xyz])
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
context "
|
|
43
|
+
context "when the field exists in the document" do
|
|
44
44
|
let(:document) { SolrDocument.new('xyz' => 'image.png') }
|
|
45
45
|
|
|
46
46
|
it { is_expected.to be true }
|
|
@@ -52,7 +52,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
52
52
|
Blacklight::OpenStructWithHashAccess.new(default_thumbnail: 'image.png')
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
context "
|
|
55
|
+
context "when the field exists in the document" do
|
|
56
56
|
it { is_expected.to be true }
|
|
57
57
|
end
|
|
58
58
|
end
|
|
@@ -62,6 +62,72 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
describe "#url" do
|
|
66
|
+
subject { presenter.url }
|
|
67
|
+
|
|
68
|
+
context "when thumbnail_field is configured" do
|
|
69
|
+
let(:config) do
|
|
70
|
+
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: :xyz)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context "when the field exists in the document" do
|
|
74
|
+
let(:document) { SolrDocument.new('xyz' => 'http://example.com/some.jpg') }
|
|
75
|
+
|
|
76
|
+
it { is_expected.to eq 'http://example.com/some.jpg' }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "when the field is missing from the document" do
|
|
80
|
+
it { is_expected.to be_nil }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context "when thumbnail_field is configured as an array of fields" do
|
|
85
|
+
let(:config) do
|
|
86
|
+
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: [:rst, :uvw, :xyz])
|
|
87
|
+
end
|
|
88
|
+
let(:document) { SolrDocument.new('xyz' => 'http://example.com/some.jpg') }
|
|
89
|
+
|
|
90
|
+
it { is_expected.to eq 'http://example.com/some.jpg' }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "when thumbnail_field is configured with an accessor" do
|
|
94
|
+
let(:config) do
|
|
95
|
+
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: Blacklight::Configuration::Field.new(field: :computed_thumbnail, accessor: true))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
before do
|
|
99
|
+
document.define_singleton_method(:computed_thumbnail) { 'http://example.com/computed.jpg' }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it { is_expected.to eq 'http://example.com/computed.jpg' }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
context "when both thumbnail_method and thumbnail_field are configured" do
|
|
106
|
+
let(:config) do
|
|
107
|
+
Blacklight::OpenStructWithHashAccess.new(thumbnail_method: :xyz, thumbnail_field: :xyz)
|
|
108
|
+
end
|
|
109
|
+
let(:document) { SolrDocument.new('xyz' => 'http://example.com/some.jpg') }
|
|
110
|
+
|
|
111
|
+
it { is_expected.to eq 'http://example.com/some.jpg' }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
context "when only thumbnail_method is configured" do
|
|
115
|
+
let(:config) do
|
|
116
|
+
Blacklight::OpenStructWithHashAccess.new(thumbnail_method: :xyz)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it { is_expected.to be_nil }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
context "when only default_thumbnail is configured" do
|
|
123
|
+
let(:config) do
|
|
124
|
+
Blacklight::OpenStructWithHashAccess.new(default_thumbnail: 'image.png')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it { is_expected.to be_nil }
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
65
131
|
describe "#thumbnail_tag" do
|
|
66
132
|
subject { presenter.thumbnail_tag }
|
|
67
133
|
|
|
@@ -70,7 +136,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
70
136
|
Blacklight::OpenStructWithHashAccess.new(thumbnail_method: :xyz)
|
|
71
137
|
end
|
|
72
138
|
|
|
73
|
-
context "
|
|
139
|
+
context "when the method returns a value" do
|
|
74
140
|
before do
|
|
75
141
|
allow(view_context).to receive_messages(xyz: "some-thumbnail")
|
|
76
142
|
end
|
|
@@ -82,7 +148,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
82
148
|
expect(view_context).to have_received(:xyz)
|
|
83
149
|
end
|
|
84
150
|
|
|
85
|
-
context "
|
|
151
|
+
context "when url options have :suppress_link" do
|
|
86
152
|
subject { presenter.thumbnail_tag({}, suppress_link: true) }
|
|
87
153
|
|
|
88
154
|
it "does not link to the document" do
|
|
@@ -91,7 +157,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
91
157
|
end
|
|
92
158
|
end
|
|
93
159
|
|
|
94
|
-
context "
|
|
160
|
+
context "when no value is returned from the thumbnail method" do
|
|
95
161
|
before do
|
|
96
162
|
allow(view_context).to receive_messages(xyz: nil)
|
|
97
163
|
end
|
|
@@ -123,7 +189,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
123
189
|
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: [:rst, :uvw, :xyz])
|
|
124
190
|
end
|
|
125
191
|
|
|
126
|
-
context "
|
|
192
|
+
context "when the field exists in the document" do
|
|
127
193
|
let(:document) { SolrDocument.new(xyz: 'http://example.com/some.jpg') }
|
|
128
194
|
|
|
129
195
|
it "creates an image tag from the given field" do
|
|
@@ -136,7 +202,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
136
202
|
end
|
|
137
203
|
|
|
138
204
|
context "when default_thumbnail is configured" do
|
|
139
|
-
context "
|
|
205
|
+
context "when it is a string" do
|
|
140
206
|
let(:config) do
|
|
141
207
|
Blacklight::OpenStructWithHashAccess.new(default_thumbnail: 'image.png')
|
|
142
208
|
end
|
|
@@ -147,7 +213,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
147
213
|
end
|
|
148
214
|
end
|
|
149
215
|
|
|
150
|
-
context "
|
|
216
|
+
context "when it is a symbol" do
|
|
151
217
|
let(:config) do
|
|
152
218
|
Blacklight::OpenStructWithHashAccess.new(default_thumbnail: :get_a_default_thumbnail)
|
|
153
219
|
end
|
|
@@ -158,7 +224,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
158
224
|
end
|
|
159
225
|
end
|
|
160
226
|
|
|
161
|
-
context "
|
|
227
|
+
context "when it is a proc" do
|
|
162
228
|
let(:config) do
|
|
163
229
|
Blacklight::OpenStructWithHashAccess.new(default_thumbnail: ->(_, _) { '<img src="image.jpg">' })
|
|
164
230
|
end
|
|
@@ -169,6 +235,56 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
|
169
235
|
end
|
|
170
236
|
end
|
|
171
237
|
|
|
238
|
+
context "when a thumbnail and a default_thumbnail are both configured" do
|
|
239
|
+
subject { presenter.thumbnail_tag(image_options, suppress_link: true) }
|
|
240
|
+
|
|
241
|
+
let(:view_context) { ActionView::Base.empty }
|
|
242
|
+
let(:image_options) { { alt: '' } }
|
|
243
|
+
let(:document) { SolrDocument.new(xyz: 'http://example.com/some.jpg') }
|
|
244
|
+
let(:config) do
|
|
245
|
+
Blacklight::OpenStructWithHashAccess.new(thumbnail_field: :xyz, default_thumbnail: 'http://example.com/default.png')
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it "renders the default thumbnail and the thumbnail together, so the default can show until the thumbnail loads" do
|
|
249
|
+
expect(subject).to have_css '.thumbnail-stack .thumbnail-fallback img[src="http://example.com/default.png"]'
|
|
250
|
+
expect(subject).to have_css '.thumbnail-stack > img[src="http://example.com/some.jpg"]'
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it "puts the thumbnail last, so it paints over the default thumbnail" do
|
|
254
|
+
expect(subject).to have_css '.thumbnail-stack > .thumbnail-fallback:first-child + img:last-child'
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "leaves the default thumbnail out of the accessibility tree" do
|
|
258
|
+
expect(subject).to have_css '.thumbnail-fallback[aria-hidden="true"]'
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
context "with an id in the image options" do
|
|
262
|
+
let(:image_options) { { alt: '', id: 'thumb' } }
|
|
263
|
+
|
|
264
|
+
it "keeps the id on the thumbnail alone" do
|
|
265
|
+
expect(subject).to have_css 'img#thumb[src="http://example.com/some.jpg"]'
|
|
266
|
+
expect(subject).to have_css '[id="thumb"]', count: 1
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
context "when the document has no thumbnail" do
|
|
271
|
+
let(:document) { SolrDocument.new }
|
|
272
|
+
|
|
273
|
+
it "renders the default thumbnail alone" do
|
|
274
|
+
expect(subject).to have_css 'img[src="http://example.com/default.png"]'
|
|
275
|
+
expect(subject).to have_no_css '.thumbnail-stack'
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
context "with an id in the image options" do
|
|
279
|
+
let(:image_options) { { alt: '', id: 'thumb' } }
|
|
280
|
+
|
|
281
|
+
it "keeps the id on the default thumbnail" do
|
|
282
|
+
expect(subject).to have_css 'img#thumb[src="http://example.com/default.png"]'
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
172
288
|
context "when no thumbnail is configured" do
|
|
173
289
|
it { is_expected.to be_nil }
|
|
174
290
|
end
|
|
@@ -35,7 +35,7 @@ RSpec.describe "Routing" do
|
|
|
35
35
|
expect(get: solr_document_path(SolrDocument.new(id: 'asdf'))).to route_to(controller: 'catalog', action: 'show', id: 'asdf')
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
describe "escaping solr document ids" do
|
|
39
39
|
it "pass-throughs url-valid ids" do
|
|
40
40
|
expect(get: solr_document_path(SolrDocument.new(id: 'qwerty'))).to route_to(controller: 'catalog', action: 'show', id: 'qwerty')
|
|
41
41
|
end
|
|
@@ -7,7 +7,7 @@ RSpec.describe Blacklight::FieldRetriever, :api do
|
|
|
7
7
|
let(:document) { SolrDocument.new({ 'id' => 'doc1', 'title_field' => 'doc1 title', 'author_field' => 'author_someone' }, 'highlighting' => { 'doc1' => { 'title_tsimext' => ['doc <em>1</em>'] } }) }
|
|
8
8
|
let(:view_context) { {} }
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
describe "highlighting" do
|
|
11
11
|
describe '#fetch' do
|
|
12
12
|
it "retrieves an author even if it's not highlighted" do
|
|
13
13
|
expect(service.fetch).to eq(['author_someone'])
|
|
@@ -35,7 +35,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
context 'when the search_builder_class is passed in' do
|
|
38
|
-
let(:klass) {
|
|
38
|
+
let(:klass) { Class.new(SearchBuilder) }
|
|
39
39
|
let(:context) { { search_builder_class: klass } }
|
|
40
40
|
|
|
41
41
|
it 'uses the passed value' do
|
|
@@ -79,7 +79,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
79
79
|
let(:user_params) { { q: all_docs_query } }
|
|
80
80
|
|
|
81
81
|
before do
|
|
82
|
-
|
|
82
|
+
blacklight_config.index.group = 'title_si'
|
|
83
83
|
blacklight_config.default_solr_params[:group] = true
|
|
84
84
|
blacklight_config.default_solr_params[:'group.field'] = %w[pub_date_si title_si]
|
|
85
85
|
end
|
|
@@ -231,7 +231,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
231
231
|
end
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
-
context "with page
|
|
234
|
+
context "with a page beyond the last result" do
|
|
235
235
|
let(:page) { 5000 }
|
|
236
236
|
let(:rows) { 5000 }
|
|
237
237
|
let(:user_params) { { q: all_docs_query, page: page, rows: rows } }
|
|
@@ -310,7 +310,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
310
310
|
|
|
311
311
|
# SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
|
|
312
312
|
describe "Searches should return spelling suggestions", :integration do
|
|
313
|
-
context "
|
|
313
|
+
context "with a just-poor-enough-query term" do
|
|
314
314
|
let(:user_params) { { q: 'boo' } }
|
|
315
315
|
|
|
316
316
|
it 'has (multiple) spelling suggestions' do
|
|
@@ -320,7 +320,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
320
320
|
end
|
|
321
321
|
end
|
|
322
322
|
|
|
323
|
-
context "
|
|
323
|
+
context "with another just-poor-enough-query term" do
|
|
324
324
|
let(:user_params) { { q: 'politica' } }
|
|
325
325
|
|
|
326
326
|
it 'has multiple spelling suggestions' do
|
|
@@ -335,7 +335,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
335
335
|
end
|
|
336
336
|
end
|
|
337
337
|
|
|
338
|
-
context "
|
|
338
|
+
context "with a title search" do
|
|
339
339
|
let(:user_params) { { q: 'yehudiyam', 'spellcheck.dictionary': "title" } }
|
|
340
340
|
|
|
341
341
|
it 'has spelling suggestions' do
|
|
@@ -344,7 +344,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
344
344
|
end
|
|
345
345
|
end
|
|
346
346
|
|
|
347
|
-
context "
|
|
347
|
+
context "with an author search" do
|
|
348
348
|
let(:user_params) { { q: 'shirma', 'spellcheck.dictionary': "author" } }
|
|
349
349
|
|
|
350
350
|
it 'has spelling suggestions' do
|
|
@@ -353,7 +353,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
|
353
353
|
end
|
|
354
354
|
end
|
|
355
355
|
|
|
356
|
-
context "
|
|
356
|
+
context "with a subject search" do
|
|
357
357
|
let(:user_params) { { q: 'wome', 'spellcheck.dictionary': "subject" } }
|
|
358
358
|
|
|
359
359
|
it 'has spelling suggestions' do
|
|
@@ -16,9 +16,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
|
16
16
|
run "bundle install"
|
|
17
17
|
end
|
|
18
18
|
options = Rails.gem_version >= Gem::Version.new('8.0.0') ? '--authentication' : '--devise'
|
|
19
|
-
if ENV['BLACKLIGHT_API_TEST'].present?
|
|
20
|
-
options += ' --skip-assets'
|
|
21
|
-
end
|
|
19
|
+
options += ' --skip-assets' if ENV['BLACKLIGHT_API_TEST'].present?
|
|
22
20
|
|
|
23
21
|
generate :'blacklight:install', options
|
|
24
22
|
end
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
RSpec.describe "catalog/_document_list" do
|
|
4
4
|
let(:view_type) { 'some-view' }
|
|
5
|
-
let(:view_config) {
|
|
5
|
+
let(:view_config) { Blacklight::Configuration::ViewConfig.new(key: view_type, document_component: Blacklight::DocumentComponent, partials: []) }
|
|
6
6
|
|
|
7
7
|
before do
|
|
8
|
-
allow(view_config).to receive_messages(key: view_type, document_component: Blacklight::DocumentComponent, partials: [])
|
|
9
8
|
allow(view).to receive_messages(document_index_view_type: view_type, documents: [], blacklight_config: nil)
|
|
10
9
|
assign(:response, instance_double(Blacklight::Solr::Response, start: 0))
|
|
11
10
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'rexml/document'
|
|
4
|
-
|
|
5
3
|
RSpec.describe "catalog/index" do
|
|
6
4
|
let(:document_list) do
|
|
7
5
|
10.times.map do |i|
|
|
@@ -16,6 +14,8 @@ RSpec.describe "catalog/index" do
|
|
|
16
14
|
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
|
17
15
|
let(:search_builder) { Blacklight::SearchBuilder.new(view) }
|
|
18
16
|
let(:response) { Blacklight::Solr::Response.new({ response: { numFound: 30 } }, search_builder) }
|
|
17
|
+
# Parse the feed with Nokogiri to test namespaced elements that have_css won't test
|
|
18
|
+
let(:response_xml) { Nokogiri::XML(rendered) }
|
|
19
19
|
|
|
20
20
|
before do
|
|
21
21
|
allow(view).to receive_messages(action_name: 'index', blacklight_config: blacklight_config)
|
|
@@ -26,9 +26,6 @@ RSpec.describe "catalog/index" do
|
|
|
26
26
|
params['content_format'] = 'some_format'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
# We need to use rexml to test certain things that have_tag wont' test
|
|
30
|
-
let(:response_xml) { REXML::Document.new(rendered) }
|
|
31
|
-
|
|
32
29
|
it "has contextual information" do
|
|
33
30
|
render template: 'catalog/index', formats: [:atom]
|
|
34
31
|
|
|
@@ -44,21 +41,20 @@ RSpec.describe "catalog/index" do
|
|
|
44
41
|
it "gets paging data correctly from response" do
|
|
45
42
|
render template: 'catalog/index', formats: [:atom]
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
expect(response_xml.
|
|
49
|
-
expect(response_xml.
|
|
50
|
-
expect(response_xml.elements["/feed/opensearch:itemsPerPage"].text).to eq "10"
|
|
44
|
+
expect(response_xml.at_xpath("/xmlns:feed/opensearch:totalResults").text).to eq "30"
|
|
45
|
+
expect(response_xml.at_xpath("/xmlns:feed/opensearch:startIndex").text).to eq "10"
|
|
46
|
+
expect(response_xml.at_xpath("/xmlns:feed/opensearch:itemsPerPage").text).to eq "10"
|
|
51
47
|
end
|
|
52
48
|
|
|
53
49
|
it "includes an opensearch Query role=request" do
|
|
54
50
|
render template: 'catalog/index', formats: [:atom]
|
|
55
51
|
|
|
56
|
-
expect(response_xml.
|
|
57
|
-
query_el = response_xml.
|
|
52
|
+
expect(response_xml.xpath("/xmlns:feed/opensearch:itemsPerPage")).to have(1).item
|
|
53
|
+
query_el = response_xml.at_xpath("/xmlns:feed/opensearch:Query")
|
|
58
54
|
expect(query_el).not_to be_nil
|
|
59
|
-
expect(query_el
|
|
60
|
-
expect(query_el
|
|
61
|
-
expect(query_el
|
|
55
|
+
expect(query_el["role"]).to eq "request"
|
|
56
|
+
expect(query_el["searchTerms"]).to eq ""
|
|
57
|
+
expect(query_el["startPage"]).to eq "2"
|
|
62
58
|
end
|
|
63
59
|
|
|
64
60
|
it "has ten entries" do
|
|
@@ -116,27 +112,27 @@ RSpec.describe "catalog/index" do
|
|
|
116
112
|
end
|
|
117
113
|
|
|
118
114
|
describe "with an author" do
|
|
119
|
-
let(:entry) { response_xml.
|
|
115
|
+
let(:entry) { response_xml.xpath("/xmlns:feed/xmlns:entry")[0] }
|
|
120
116
|
|
|
121
117
|
it "has author tag" do
|
|
122
118
|
render template: 'catalog/index', formats: [:atom]
|
|
123
|
-
expect(entry.
|
|
119
|
+
expect(entry.at_xpath("xmlns:author/xmlns:name").text).to eq 'xyz'
|
|
124
120
|
end
|
|
125
121
|
end
|
|
126
122
|
|
|
127
123
|
describe "without an author" do
|
|
128
|
-
let(:entry) { response_xml.
|
|
124
|
+
let(:entry) { response_xml.xpath("/xmlns:feed/xmlns:entry")[1] }
|
|
129
125
|
|
|
130
126
|
it "does not have an author tag" do
|
|
131
127
|
render template: 'catalog/index', formats: [:atom]
|
|
132
|
-
expect(entry.
|
|
128
|
+
expect(entry.at_xpath("xmlns:author/xmlns:name")).to be_nil
|
|
133
129
|
end
|
|
134
130
|
end
|
|
135
131
|
end
|
|
136
132
|
|
|
137
133
|
describe "when content_format is specified" do
|
|
138
134
|
describe "for an entry with content available" do
|
|
139
|
-
let(:entry) { response_xml.
|
|
135
|
+
let(:entry) { response_xml.xpath("/xmlns:feed/xmlns:entry")[1].to_s }
|
|
140
136
|
|
|
141
137
|
it "includes a link rel tag" do
|
|
142
138
|
render template: 'catalog/index', formats: [:atom]
|
|
@@ -150,7 +146,7 @@ RSpec.describe "catalog/index" do
|
|
|
150
146
|
end
|
|
151
147
|
|
|
152
148
|
describe "for an entry with NO content available" do
|
|
153
|
-
let(:entry) { response_xml.
|
|
149
|
+
let(:entry) { response_xml.xpath("/xmlns:feed/xmlns:entry")[5].to_s }
|
|
154
150
|
|
|
155
151
|
it "does not have content embedded" do
|
|
156
152
|
render template: 'catalog/index', formats: [:atom]
|
|
@@ -15,7 +15,7 @@ RSpec.describe "shared/_user_util_links" do
|
|
|
15
15
|
count = rand(99)
|
|
16
16
|
allow(controller).to receive(:render_bookmarks_control?).and_return true
|
|
17
17
|
allow(view).to receive_messages(blacklight_config: blacklight_config, has_user_authentication_provider?: false)
|
|
18
|
-
allow(view).to
|
|
18
|
+
allow(view).to receive(:current_or_guest_user).and_return(instance_double(User, bookmarks: double(count: count)))
|
|
19
19
|
render "shared/user_util_links"
|
|
20
20
|
expect(rendered).to have_css('#bookmarks_nav span.badge[data-role=bookmark-counter]', text: count.to_s)
|
|
21
21
|
end
|
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: 9.
|
|
4
|
+
version: 9.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Rochkind
|
|
@@ -418,6 +418,8 @@ files:
|
|
|
418
418
|
- ".github/workflows/release_8_x_scheduled.yml"
|
|
419
419
|
- ".github/workflows/test.yml"
|
|
420
420
|
- ".gitignore"
|
|
421
|
+
- ".prettierignore"
|
|
422
|
+
- ".prettierrc.json"
|
|
421
423
|
- ".rspec"
|
|
422
424
|
- ".rubocop.yml"
|
|
423
425
|
- ".rubocop_todo.yml"
|
|
@@ -538,6 +540,7 @@ files:
|
|
|
538
540
|
- app/components/blacklight/metadata_field_layout_component.html.erb
|
|
539
541
|
- app/components/blacklight/metadata_field_layout_component.rb
|
|
540
542
|
- app/components/blacklight/metadata_field_plain_text_layout_component.rb
|
|
543
|
+
- app/components/blacklight/open_graph_metadata_component.rb
|
|
541
544
|
- app/components/blacklight/response/facet_group_component.html.erb
|
|
542
545
|
- app/components/blacklight/response/facet_group_component.rb
|
|
543
546
|
- app/components/blacklight/response/facet_toggle_button_component.html.erb
|
|
@@ -649,6 +652,7 @@ files:
|
|
|
649
652
|
- app/presenters/blacklight/index_presenter.rb
|
|
650
653
|
- app/presenters/blacklight/json_presenter.rb
|
|
651
654
|
- app/presenters/blacklight/link_alternate_presenter.rb
|
|
655
|
+
- app/presenters/blacklight/open_graph_presenter.rb
|
|
652
656
|
- app/presenters/blacklight/rendering/abstract_step.rb
|
|
653
657
|
- app/presenters/blacklight/rendering/helper_method.rb
|
|
654
658
|
- app/presenters/blacklight/rendering/join.rb
|
|
@@ -750,6 +754,7 @@ files:
|
|
|
750
754
|
- config/locales/blacklight.fr.yml
|
|
751
755
|
- config/locales/blacklight.hu.yml
|
|
752
756
|
- config/locales/blacklight.it.yml
|
|
757
|
+
- config/locales/blacklight.ja.yml
|
|
753
758
|
- config/locales/blacklight.nl.yml
|
|
754
759
|
- config/locales/blacklight.pt-BR.yml
|
|
755
760
|
- config/locales/blacklight.sq.yml
|
|
@@ -850,6 +855,7 @@ files:
|
|
|
850
855
|
- lib/generators/blacklight/test_support_generator.rb
|
|
851
856
|
- lib/generators/blacklight/user_generator.rb
|
|
852
857
|
- lib/railties/blacklight.rake
|
|
858
|
+
- package-lock.json
|
|
853
859
|
- package.json
|
|
854
860
|
- rollup.config.js
|
|
855
861
|
- spec/components/blacklight/advanced_search_form_component_spec.rb
|
|
@@ -903,6 +909,7 @@ files:
|
|
|
903
909
|
- spec/features/facet_missing_spec.rb
|
|
904
910
|
- spec/features/facets_spec.rb
|
|
905
911
|
- spec/features/modal_spec.rb
|
|
912
|
+
- spec/features/open_graph_spec.rb
|
|
906
913
|
- spec/features/record_view_spec.rb
|
|
907
914
|
- spec/features/search_context_spec.rb
|
|
908
915
|
- spec/features/search_crawler_spec.rb
|
|
@@ -980,6 +987,7 @@ files:
|
|
|
980
987
|
- spec/presenters/blacklight/index_presenter_spec.rb
|
|
981
988
|
- spec/presenters/blacklight/json_presenter_spec.rb
|
|
982
989
|
- spec/presenters/blacklight/link_alternate_presenter_spec.rb
|
|
990
|
+
- spec/presenters/blacklight/open_graph_presenter_spec.rb
|
|
983
991
|
- spec/presenters/blacklight/rendering/pipeline_spec.rb
|
|
984
992
|
- spec/presenters/blacklight/show_presenter_spec.rb
|
|
985
993
|
- spec/presenters/blacklight/thumbnail_presenter_spec.rb
|
|
@@ -1036,7 +1044,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1036
1044
|
- !ruby/object:Gem::Version
|
|
1037
1045
|
version: '0'
|
|
1038
1046
|
requirements: []
|
|
1039
|
-
rubygems_version: 4.0.
|
|
1047
|
+
rubygems_version: 4.0.22
|
|
1040
1048
|
specification_version: 4
|
|
1041
1049
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
|
1042
1050
|
index.
|
|
@@ -1092,6 +1100,7 @@ test_files:
|
|
|
1092
1100
|
- spec/features/facet_missing_spec.rb
|
|
1093
1101
|
- spec/features/facets_spec.rb
|
|
1094
1102
|
- spec/features/modal_spec.rb
|
|
1103
|
+
- spec/features/open_graph_spec.rb
|
|
1095
1104
|
- spec/features/record_view_spec.rb
|
|
1096
1105
|
- spec/features/search_context_spec.rb
|
|
1097
1106
|
- spec/features/search_crawler_spec.rb
|
|
@@ -1169,6 +1178,7 @@ test_files:
|
|
|
1169
1178
|
- spec/presenters/blacklight/index_presenter_spec.rb
|
|
1170
1179
|
- spec/presenters/blacklight/json_presenter_spec.rb
|
|
1171
1180
|
- spec/presenters/blacklight/link_alternate_presenter_spec.rb
|
|
1181
|
+
- spec/presenters/blacklight/open_graph_presenter_spec.rb
|
|
1172
1182
|
- spec/presenters/blacklight/rendering/pipeline_spec.rb
|
|
1173
1183
|
- spec/presenters/blacklight/show_presenter_spec.rb
|
|
1174
1184
|
- spec/presenters/blacklight/thumbnail_presenter_spec.rb
|