blacklight 5.11.1 → 5.11.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5d4dba8182fcbbaa71a0f1e263c992b5ead7a54
4
- data.tar.gz: a2ad75e6e2097d1881685a1f3e35414c885a70c0
3
+ metadata.gz: fbed788b9563305a5fdc48a4d8c24b8a96387e6b
4
+ data.tar.gz: 0bd82d604396b69091d6f50fba853f2af67f06aa
5
5
  SHA512:
6
- metadata.gz: 2ec8a493c2c4e80ce27b9c901f6fb9de931d058d6a81f6dbc57ee2b54d4f1a321a13626d9df1342e430903cdf655ee1a380f38506f3e31b0af5708b23a5d2d96
7
- data.tar.gz: 02343ff43095be1ffe760572b3cb1737dd14a38ab08178f5c3b9997fd46695895c627321dce537cc027f1c1059805ad37b5b268595077866cbad1b771f7212bf
6
+ metadata.gz: ef476787e4c81ac178e2ed8f2c86bcac92709d023e1a241d0581b30e39196b0d687df4979aa749077c61c9a65d97f0b2fb391e9feb8dee087a9a6fd4ef9af6e2
7
+ data.tar.gz: c5e5be39ab6a4e978d550ae344a6aa543d633f65f1ca74f04310c91984b321db9f4e7a9a433ce7e8bb7325919b80106d2d6c99474212d00411ecd2670492f4ea
data/.travis.yml CHANGED
@@ -15,6 +15,8 @@ matrix:
15
15
  env: "RAILS_VERSION=4.1.9"
16
16
  - rvm: 2.1.5
17
17
  env: "RAILS_VERSION=4.2.0"
18
+ - rvm: 2.1.5
19
+ env: "RAILS_VERSION=4.2.1"
18
20
  - rvm: jruby
19
21
  env: "RAILS_VERSION=4.2.0 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
20
22
  - rvm: 1.9.3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.11.1
1
+ 5.11.2
@@ -87,13 +87,11 @@ module Blacklight::ConfigurationHelperBehavior
87
87
  # Look up the label for the facet field
88
88
  def facet_field_label field
89
89
  field_config = blacklight_config.facet_fields[field]
90
+ defaults = [:"blacklight.search.fields.facet.#{field}", :"blacklight.search.fields.#{field}"]
91
+ defaults << field_config.label if field_config
92
+ defaults << field.to_s.humanize
90
93
 
91
- field_label(
92
- :"blacklight.search.fields.facet.#{field}",
93
- :"blacklight.search.fields.#{field}",
94
- (field_config.label if field_config),
95
- field.to_s.humanize
96
- )
94
+ field_label *defaults
97
95
  end
98
96
 
99
97
  def view_label view
@@ -59,6 +59,10 @@ module Blacklight::Document
59
59
  @_source.send :[], *args
60
60
  end
61
61
 
62
+ def _read_attribute(attr)
63
+ self[attr]
64
+ end
65
+
62
66
  # Helper method to check if value/multi-values exist for a given key.
63
67
  # The value can be a string, or a RegExp
64
68
  # Multiple "values" can be given; only one needs to match.
@@ -153,4 +157,4 @@ module Blacklight::Document
153
157
  self
154
158
  end
155
159
  end
156
- end
160
+ end
@@ -232,6 +232,9 @@ module Blacklight::Solr
232
232
  def facet_value_to_fq_string(facet_field, value)
233
233
  facet_config = blacklight_config.facet_fields[facet_field]
234
234
 
235
+ solr_field = facet_config.field if facet_config and not facet_config.query
236
+ solr_field ||= facet_field
237
+
235
238
  local_params = []
236
239
  local_params << "tag=#{facet_config.tag}" if facet_config and facet_config.tag
237
240
 
@@ -243,17 +246,17 @@ module Blacklight::Solr
243
246
  facet_config.query[value][:fq]
244
247
  when (facet_config and facet_config.date)
245
248
  # in solr 3.2+, this could be replaced by a !term query
246
- "#{prefix}#{facet_field}:#{RSolr.solr_escape(value)}"
249
+ "#{prefix}#{solr_field}:#{RSolr.solr_escape(value)}"
247
250
  when (value.is_a?(DateTime) or value.is_a?(Date) or value.is_a?(Time))
248
- "#{prefix}#{facet_field}:#{RSolr.solr_escape(value.to_time.utc.strftime("%Y-%m-%dT%H:%M:%SZ"))}"
251
+ "#{prefix}#{solr_field}:#{RSolr.solr_escape(value.to_time.utc.strftime("%Y-%m-%dT%H:%M:%SZ"))}"
249
252
  when (value.is_a?(TrueClass) or value.is_a?(FalseClass) or value == 'true' or value == 'false'),
250
253
  (value.is_a?(Integer) or (value.to_i.to_s == value if value.respond_to? :to_i)),
251
254
  (value.is_a?(Float) or (value.to_f.to_s == value if value.respond_to? :to_f))
252
- "#{prefix}#{facet_field}:#{RSolr.solr_escape(value.to_s)}"
255
+ "#{prefix}#{solr_field}:#{RSolr.solr_escape(value.to_s)}"
253
256
  when value.is_a?(Range)
254
- "#{prefix}#{facet_field}:[#{value.first} TO #{value.last}]"
257
+ "#{prefix}#{solr_field}:[#{value.first} TO #{value.last}]"
255
258
  else
256
- "{!raw f=#{facet_field}#{(" " + local_params.join(" ")) unless local_params.empty?}}#{value}"
259
+ "{!raw f=#{solr_field}#{(" " + local_params.join(" ")) unless local_params.empty?}}#{value}"
257
260
  end
258
261
  end
259
262
 
@@ -355,6 +355,10 @@ describe Blacklight::Solr::SearchBuilder do
355
355
 
356
356
 
357
357
  describe "#facet_value_to_fq_string" do
358
+ it "should use the configured field name" do
359
+ blacklight_config.add_facet_field :facet_key, field: "facet_name"
360
+ expect(subject.send(:facet_value_to_fq_string, "facet_key", "my value")).to eq "{!raw f=facet_name}my value"
361
+ end
358
362
 
359
363
  it "should use the raw handler for strings" do
360
364
  expect(subject.send(:facet_value_to_fq_string, "facet_name", "my value")).to eq "{!raw f=facet_name}my value"
@@ -389,19 +393,19 @@ describe Blacklight::Solr::SearchBuilder do
389
393
  end
390
394
 
391
395
  it "should pass date-type fields through" do
392
- allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
396
+ allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil, :field => 'facet_name'))
393
397
 
394
398
  expect(subject.send(:facet_value_to_fq_string, "facet_name", "2012-01-01")).to eq "facet_name:2012\\-01\\-01"
395
399
  end
396
400
 
397
401
  it "should escape datetime-type fields" do
398
- allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
402
+ allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil, :field => 'facet_name'))
399
403
 
400
404
  expect(subject.send(:facet_value_to_fq_string, "facet_name", "2003-04-09T00:00:00Z")).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
401
405
  end
402
406
 
403
407
  it "should format Date objects correctly" do
404
- allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil))
408
+ allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil, :field => 'facet_name'))
405
409
  d = DateTime.parse("2003-04-09T00:00:00")
406
410
  expect(subject.send(:facet_value_to_fq_string, "facet_name", d)).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
407
411
  end
@@ -411,7 +415,7 @@ describe Blacklight::Solr::SearchBuilder do
411
415
  end
412
416
 
413
417
  it "should add tag local parameters" do
414
- allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:query => nil, :tag => 'asdf', :date => nil))
418
+ allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:query => nil, :tag => 'asdf', :date => nil, :field => 'facet_name'))
415
419
 
416
420
  expect(subject.send(:facet_value_to_fq_string, "facet_name", true)).to eq "{!tag=asdf}facet_name:true"
417
421
  expect(subject.send(:facet_value_to_fq_string, "facet_name", "my value")).to eq "{!raw f=facet_name tag=asdf}my value"
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: 5.11.1
4
+ version: 5.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2015-03-19 00:00:00.000000000 Z
20
+ date: 2015-03-20 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails