blacklight-spotlight 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b12afe1e6f1ab467dd5f467712531eefba3b6e3
4
- data.tar.gz: 6013ba28f723ffae008846bb85ed2a8b01d818fd
3
+ metadata.gz: 4477ac2d54b4a5009867cbcff8bdf710b93bee8d
4
+ data.tar.gz: 3c274d2b475395ca0f55da0e5c000fe0338b772f
5
5
  SHA512:
6
- metadata.gz: d424c79909a478c681e245d548dbcbe1246a90715ce3a5df852d81c6f21b0aa90e64644cac8ac08372981f2db5750cff3f27efb78d0983b2e0153842d45af125
7
- data.tar.gz: 585cf4431078a9401d7d7726117545cb7d7dae8e867da5888bcef48e8c2ced5a8346f8646ba0bbce0812de1277faf05a600d1b6b5ace2eac3431a5cd8cc9a198
6
+ metadata.gz: 53ac3d47317e9e867604f218abc36bf0995979eefeddfe54090595322e47edae1b3384cb14055293c92f9f0b7d2c146ab9b5478bec2572a69e24c97ec6679f09
7
+ data.tar.gz: 551bc13319ac8f7992d78dc82b49e16832500cd7dd9d5a7c2d6c184ad4a25308b5609da8583ff249e29ea5e42aabc75477e16ebb04ae1eccc4a7ad631b008f59
@@ -10,22 +10,25 @@ module Spotlight
10
10
  return to_enum(:solr_documents) unless block_given?
11
11
 
12
12
  start = 0
13
- response = repository.search(exhibit_search_params.merge(start: start))
13
+ search_params = exhibit_search_builder.merge(q: '*:*', fl: '*')
14
+
15
+ response = repository.search(search_params.start(start).to_h)
14
16
 
15
17
  while response.documents.present?
16
18
  response.documents.each { |x| yield x }
17
19
  start += response.documents.length
18
- response = repository.search(exhibit_search_params.merge(start: start))
20
+ response = repository.search(search_params.start(start).to_h)
19
21
  end
20
22
  end
21
23
 
22
24
  private
23
25
 
24
- def exhibit_search_params
25
- params = { q: '*:*', fl: '*' }
26
- params[:fq] ||= []
27
- params[:fq] << solr_data if Spotlight::Engine.config.filter_resources_by_exhibit
28
- params
26
+ def exhibit_search_builder
27
+ blacklight_config.search_builder_class.new(true, exhibit_search_builder_context).except(:apply_permissive_visibility_filter)
28
+ end
29
+
30
+ def exhibit_search_builder_context
31
+ OpenStruct.new(blacklight_config: blacklight_config, current_exhibit: self)
29
32
  end
30
33
 
31
34
  def repository
@@ -67,8 +67,6 @@ module Spotlight
67
67
  # Create a new config based on the defaults
68
68
  config = default_blacklight_config.inheritable_copy
69
69
 
70
- config.search_builder_class.send(:include, Spotlight::Catalog::AccessControlsEnforcement::SearchBuilder)
71
-
72
70
  config.show.merge! show unless show.blank?
73
71
  config.index.merge! index unless index.blank?
74
72
 
@@ -75,6 +75,16 @@ module Spotlight
75
75
  end
76
76
  end
77
77
 
78
+ def add_search_builder_mixin
79
+ if File.exist? 'app/models/search_builder.rb'
80
+ inject_into_file 'app/models/search_builder.rb', after: "include Blacklight::Solr::SearchBuilderBehavior\n" do
81
+ "\n include Spotlight::Catalog::AccessControlsEnforcement::SearchBuilder\n"
82
+ end
83
+ else
84
+ say 'Unable to find SearchBuilder class; add `include Spotlight::Catalog::AccessControlsEnforcement::SearchBuilder` to the class manually.'
85
+ end
86
+ end
87
+
78
88
  def add_example_catalog_controller
79
89
  copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb'
80
90
  end
@@ -12,6 +12,12 @@ module Spotlight
12
12
  ##
13
13
  # SearchBuilder mixin
14
14
  module SearchBuilder
15
+ extend ActiveSupport::Concern
16
+
17
+ included do
18
+ self.default_processor_chain += [:apply_permissive_visibility_filter, :apply_exhibit_resources_filter]
19
+ end
20
+
15
21
  def apply_permissive_visibility_filter(solr_params)
16
22
  return unless current_exhibit
17
23
  return if scope.respond_to?(:can?) && scope.can?(:curate, current_exhibit) && !blacklight_params[:public]
@@ -1,4 +1,4 @@
1
1
  #
2
2
  module Spotlight
3
- VERSION = '0.9.2'
3
+ VERSION = '0.10.0'
4
4
  end
@@ -174,9 +174,11 @@ describe Spotlight::Exhibit, type: :model do
174
174
 
175
175
  describe '#solr_documents' do
176
176
  let(:blacklight_config) { Blacklight::Configuration.new }
177
+ let(:slug) { 'some_slug' }
177
178
 
178
179
  before do
179
180
  allow(subject).to receive(:blacklight_config).and_return(blacklight_config)
181
+ allow(subject).to receive(:slug).and_return(slug)
180
182
  end
181
183
 
182
184
  it 'enumerates the documents in the exhibit' do
@@ -184,7 +186,7 @@ describe Spotlight::Exhibit, type: :model do
184
186
  end
185
187
 
186
188
  it 'pages through the index' do
187
- allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 0)).and_return(double(documents: [1, 2, 3]))
189
+ allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).and_return(double(documents: [1, 2, 3]))
188
190
  allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 3)).and_return(double(documents: [4, 5, 6]))
189
191
  allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 6)).and_return(double(documents: []))
190
192
 
@@ -197,7 +199,8 @@ describe Spotlight::Exhibit, type: :model do
197
199
  end
198
200
 
199
201
  it 'filters the solr results using the exhibit filter' do
200
- allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(fq: [subject.solr_data])).and_return(double(documents: []))
202
+ expected_query_params = { fq: ["spotlight_exhibit_slug_#{subject.slug}_bsi:true"] }
203
+ allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(expected_query_params)).and_return(double(documents: []))
201
204
  expect(subject.solr_documents.to_a).to be_blank
202
205
  end
203
206
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-11-30 00:00:00.000000000 Z
14
+ date: 2015-12-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -935,6 +935,7 @@ files:
935
935
  - app/views/spotlight/catalog/_document_visibility_control.html.erb
936
936
  - app/views/spotlight/catalog/_edit_default.html.erb
937
937
  - app/views/spotlight/catalog/_index_compact_default.html.erb
938
+ - app/views/spotlight/catalog/_status_header.html.erb
938
939
  - app/views/spotlight/catalog/admin.html.erb
939
940
  - app/views/spotlight/catalog/edit.html.erb
940
941
  - app/views/spotlight/catalog/new.html.erb