blacklight 4.4.0 → 4.4.1

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: b1463e41c998a83ef595ee4dafe4a390d5cd90be
4
- data.tar.gz: a9b62fea9a0454a432ac5ecd95e8f8952438da5d
3
+ metadata.gz: e233726683e123e23d25e7f85920aff1fc6174ae
4
+ data.tar.gz: 747930b852dfb6a093710a6ba264562063926348
5
5
  SHA512:
6
- metadata.gz: 57b6f5e61c7ed3faf05c151ff3915fe48fedac1be2edb2b9f0deae5879265118e8d1f7b961541915a54b41ac2098cea36fb1d4c5d77eaf125360c60a17721b5b
7
- data.tar.gz: 54d4dc8f7f4fe286dd0ec6faae2c73e95e1e7fb644f6418d3cf6b52de96cd7cacc84c5baa5e6ce65472f507c4548d83f38a3d884134bf5e0047fda2f69be42dd
6
+ metadata.gz: b7c98286303cdc3c45e41bb2991615aa9a082ca5d770fef9e9b5eb538ee8e59a7c754ef4bb10b27597c779590d5d4ed9214135e315997753aae76da4cb7e7fa3
7
+ data.tar.gz: 07af82e4ba9cf21b51bff27c3219d701db867a02c59aaba3a4920a746be4ec555c5d2910a5f59505a976afd2aa629ef78567fc577c569b14741a96234157abdd
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.4.0
1
+ 4.4.1
@@ -92,7 +92,7 @@ module Blacklight::BlacklightHelperBehavior
92
92
  wrapping_class = options.delete(:wrapping_class) || "documentFunctions"
93
93
 
94
94
  content = []
95
- content << render(:partial => 'catalog/bookmark_control', :locals => {:document=> document}.merge(options)) if has_user_authentication_provider? and current_or_guest_user
95
+ content << render(:partial => 'catalog/bookmark_control', :locals => {:document=> document}.merge(options)) if render_bookmarks_control?
96
96
 
97
97
  content_tag("div", content.join("\n").html_safe, :class=> wrapping_class)
98
98
  end
@@ -100,11 +100,14 @@ module Blacklight::BlacklightHelperBehavior
100
100
  # Save function area for item detail 'show' view, normally
101
101
  # renders next to title. By default includes 'Bookmarks'
102
102
  def render_show_doc_actions(document=@document, options={})
103
- wrapping_class = options.delete(:documentFunctions) || "documentFunctions"
103
+ # I'm not sure why this key is documentFunctions and #render_index_doc_actions uses wrapping_class.
104
+ # TODO: remove documentFunctions key in Blacklight 5.x
105
+ wrapping_class = options.delete(:documentFunctions) || options.delete(:wrapping_class) || "documentFunctions"
106
+
104
107
  content = []
105
- content << render(:partial => 'catalog/bookmark_control', :locals => {:document=> document}.merge(options)) if has_user_authentication_provider? and current_or_guest_user
108
+ content << render(:partial => 'catalog/bookmark_control', :locals => {:document=> document}.merge(options)) if render_bookmarks_control?
106
109
 
107
- content_tag("div", content.join("\n").html_safe, :class=>"documentFunctions")
110
+ content_tag("div", content.join("\n").html_safe, :class=> wrapping_class)
108
111
  end
109
112
 
110
113
  ##
@@ -621,4 +624,8 @@ module Blacklight::BlacklightHelperBehavior
621
624
  render :partial => 'catalog/group_default'
622
625
  end
623
626
 
627
+ def render_bookmarks_control?
628
+ has_user_authentication_provider? and current_or_guest_user.present?
629
+ end
630
+
624
631
  end
@@ -104,7 +104,7 @@ module Blacklight::CatalogHelperBehavior
104
104
 
105
105
  def has_thumbnail? document
106
106
  blacklight_config.index.thumbnail_method or
107
- blacklight_config.index.thumbnail_field && document.has_field?(blacklight_config.index.thumbnail_field)
107
+ blacklight_config.index.thumbnail_field && document.has?(blacklight_config.index.thumbnail_field)
108
108
  end
109
109
 
110
110
  def render_thumbnail_tag document, image_options = {}, url_options = {}
@@ -120,7 +120,9 @@ module Blacklight::CatalogHelperBehavior
120
120
  end
121
121
 
122
122
  def thumbnail_url document
123
- document.get(blacklight_config.index.thumbnail_field, :sep => nil).first if document.has_field?(blacklight_config.index.thumbnail_field)
123
+ if document.has? blacklight_config.index.thumbnail_field
124
+ document.first(blacklight_config.index.thumbnail_field)
125
+ end
124
126
  end
125
127
 
126
128
  def add_group_facet_params_and_redirect group
@@ -10,7 +10,7 @@
10
10
  <% end %>
11
11
 
12
12
  <div class="util-links-other">
13
- <% if current_or_guest_user %>
13
+ <% if render_bookmarks_control? %>
14
14
  <%= link_to t('blacklight.header_links.bookmarks'), bookmarks_path %>
15
15
  <% end %>
16
16
  <% if has_user_authentication_provider? and current_user %>
@@ -5,6 +5,6 @@
5
5
  <%= render_document_partial document, :thumbnail, :document_counter => document_counter %>
6
6
 
7
7
  <% # main container for doc partial view -%>
8
- <%= render_document_partial document, :index %>
8
+ <%= render_document_partial document, :index, :document_counter => document_counter %>
9
9
 
10
10
  </div>
@@ -1,4 +1,4 @@
1
- <%- if has_thumbnail?(document) && tn = render_thumbnail_tag(document, nil, :counter => document_counter + 1 + @response.params[:start].to_i) %>
1
+ <%- if has_thumbnail?(document) && tn = render_thumbnail_tag(document, {}, :counter => document_counter_with_offset(document_counter)) %>
2
2
  <div class="document-thumbnail">
3
3
  <%= tn %>
4
4
  </div>
@@ -62,9 +62,9 @@ module Blacklight::Solr::Document
62
62
  # doc.has?(:location_facet, 'Clemons')
63
63
  # doc.has?(:id, 'h009', /^u/i)
64
64
  def has?(k, *values)
65
- return if @_source[k].nil?
66
- return true if @_source.key?(k) and values.empty?
67
- target = @_source[k]
65
+ return true if key?(k) and values.empty?
66
+ return false if self[k].nil?
67
+ target = self[k]
68
68
  if target.is_a?(Array)
69
69
  values.each do |val|
70
70
  return target.any?{|tv| val.is_a?(Regexp) ? (tv =~ val) : (tv==val)}
@@ -74,6 +74,10 @@ module Blacklight::Solr::Document
74
74
  end
75
75
  end
76
76
 
77
+ def key? k
78
+ @_source.key? k
79
+ end
80
+
77
81
  def has_highlight_field? k
78
82
  return false if @solr_response['highlighting'].blank? or @solr_response['highlighting'][self.id].blank?
79
83
 
@@ -93,14 +97,18 @@ module Blacklight::Solr::Document
93
97
  # - :default - a value to return when the key doesn't exist
94
98
  # if :sep is nil and the field is a multivalued field, the array is returned
95
99
  def get(key, opts={:sep=>', ', :default=>nil})
96
- if @_source.key? key
97
- val = @_source[key]
100
+ if key? key
101
+ val = self[key]
98
102
  (val.is_a?(Array) and opts[:sep]) ? val.join(opts[:sep]) : val
99
103
  else
100
104
  opts[:default]
101
105
  end
102
106
  end
103
107
 
108
+ def first key
109
+ Array(self[key]).first
110
+ end
111
+
104
112
  def id
105
113
  self[self.class.unique_key]
106
114
  end
@@ -311,6 +311,7 @@ module Blacklight::SolrHelper
311
311
 
312
312
 
313
313
  if blacklight_config.add_facet_fields_to_solr_request
314
+ solr_parameters[:facet] = true
314
315
  solr_parameters[:'facet.field'] ||= []
315
316
  solr_parameters[:'facet.field'] += blacklight_config.facet_fields_to_add_to_solr
316
317
 
@@ -131,13 +131,13 @@ describe CatalogHelper do
131
131
 
132
132
  it "should have a thumbnail if a thumbnail_field is configured and it exists in the document" do
133
133
  helper.stub(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_field => :xyz) ))
134
- document = double(:has_field? => true)
134
+ document = double(:has? => true)
135
135
  expect(helper.has_thumbnail? document).to be_true
136
136
  end
137
137
 
138
138
  it "should not have a thumbnail if the thumbnail_field is missing from the document" do
139
139
  helper.stub(:blacklight_config => OpenStruct.new(:index => OpenStruct.new(:thumbnail_field => :xyz) ))
140
- document = double(:has_field? => false)
140
+ document = double(:has? => false)
141
141
  expect(helper.has_thumbnail? document).to be_false
142
142
  end
143
143
 
@@ -161,8 +161,8 @@ describe CatalogHelper do
161
161
  helper.stub(:blacklight_config => double(:index => OpenStruct.new(:thumbnail_field => :xyz)))
162
162
  document = double()
163
163
 
164
- document.stub(:has_field?).with(:xyz).and_return(true)
165
- document.stub(:get).with(:xyz, :sep => nil).and_return(["http://example.com/some.jpg"])
164
+ document.stub(:has?).with(:xyz).and_return(true)
165
+ document.stub(:first).with(:xyz).and_return("http://example.com/some.jpg")
166
166
 
167
167
  helper.should_receive(:link_to_document).with(document, :label => image_tag("http://example.com/some.jpg"))
168
168
  helper.render_thumbnail_tag document
@@ -188,15 +188,15 @@ describe CatalogHelper do
188
188
  it "should pull the configured thumbnail field out of the document" do
189
189
  helper.stub(:blacklight_config => double(:index => double(:thumbnail_field => "xyz")))
190
190
  document = double()
191
- document.stub(:has_field?).with("xyz").and_return(true)
192
- document.stub(:get).with("xyz", :sep => nil).and_return(["asdf"])
191
+ document.stub(:has?).with("xyz").and_return(true)
192
+ document.stub(:first).with("xyz").and_return("asdf")
193
193
  expect(helper.thumbnail_url document).to eq("asdf")
194
194
  end
195
195
 
196
196
  it "should return nil if the thumbnail field doesn't exist" do
197
197
  helper.stub(:blacklight_config => double(:index => double(:thumbnail_field => "xyz")))
198
198
  document = double()
199
- document.stub(:has_field?).with("xyz").and_return(false)
199
+ document.stub(:has?).with("xyz").and_return(false)
200
200
  expect(helper.thumbnail_url document).to be_nil
201
201
  end
202
202
  end
@@ -231,5 +231,18 @@ describe "Blacklight::Solr::Document" do
231
231
  end
232
232
  end
233
233
  end
234
+
235
+ describe "#first" do
236
+ it "should get the first value from a multi-valued field" do
237
+ doc = SolrDocument.new :multi => ['a', 'b']
238
+ expect(doc.first :multi).to eq("a")
239
+ end
240
+
241
+ it "should get the value from a single-valued field" do
242
+ doc = SolrDocument.new :single => 'a'
243
+ expect(doc.first :single).to eq("a")
244
+
245
+ end
246
+ end
234
247
 
235
248
  end
@@ -290,6 +290,8 @@ describe 'Blacklight::SolrHelper' do
290
290
 
291
291
  add_facetting_to_solr(solr_parameters, {})
292
292
 
293
+ expect(solr_parameters[:facet]).to be_true
294
+
293
295
  solr_parameters[:'facet.field'].should include('test_field')
294
296
  solr_parameters[:'f.test_field.facet.sort'].should == 'count'
295
297
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe "catalog/_document" do
4
+ let :document do
5
+ SolrDocument.new :id => 'xyz', :format => 'a'
6
+ end
7
+
8
+ let :blacklight_config do
9
+ Blacklight::Configuration.new
10
+ end
11
+
12
+ it "should render the header, thumbnail and index" do
13
+ view.stub(:blacklight_config).and_return(blacklight_config)
14
+ stub_template "catalog/_document_header.html.erb" => "document_header"
15
+ stub_template "catalog/_thumbnail_default.html.erb" => "thumbnail_default"
16
+ stub_template "catalog/_index_default.html.erb" => "index_default"
17
+ render :partial => "catalog/document", :locals => {:document => document, :document_counter => 1}
18
+ expect(rendered).to match /document_header/
19
+ expect(rendered).to match /thumbnail_default/
20
+ expect(rendered).to match /index_default/
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe "catalog/_thumbnail_default" do
4
+
5
+ let :document_without_thumbnail_field do
6
+ SolrDocument.new :id => 'xyz', :format => 'a'
7
+ end
8
+
9
+ let :document_with_thumbnail_field do
10
+ SolrDocument.new :id => 'xyz', :format => 'a', :thumbnail_url => 'http://localhost/logo.png'
11
+ end
12
+
13
+ let :blacklight_config do
14
+ Blacklight::Configuration.new do |config|
15
+ config.index.thumbnail_field = :thumbnail_url
16
+ end
17
+ end
18
+
19
+ before do
20
+ assign :response, mock(:params => {})
21
+ view.stub(:render_grouped_response?).and_return false
22
+ view.stub(:blacklight_config).and_return(blacklight_config)
23
+ end
24
+
25
+ it "should render the thumbnail if the document has one" do
26
+ render :partial => "catalog/thumbnail_default", :locals => {:document => document_with_thumbnail_field, :document_counter => 1}
27
+ expect(rendered).to match /document-thumbnail/
28
+ expect(rendered).to match /src="http:\/\/localhost\/logo.png"/
29
+ end
30
+
31
+ it "should not render a thumbnail if the document does not have one" do
32
+ render :partial => "catalog/thumbnail_default", :locals => {:document => document_without_thumbnail_field, :document_counter => 1}
33
+ expect(rendered).to eq ""
34
+ end
35
+ 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: 4.4.0
4
+ version: 4.4.1
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: 2013-09-17 00:00:00.000000000 Z
20
+ date: 2013-09-18 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -464,11 +464,13 @@ files:
464
464
  - spec/test_app_templates/lib/generators/test_app_generator.rb
465
465
  - spec/test_app_templates/lib/tasks/blacklight_test_app.rake
466
466
  - spec/views/catalog/_constraints_element.html.erb_spec.rb
467
+ - spec/views/catalog/_document.html.erb_spec.rb
467
468
  - spec/views/catalog/_document_list.html.erb_spec.rb
468
469
  - spec/views/catalog/_facets.html.erb_spec.rb
469
470
  - spec/views/catalog/_index_default.erb_spec.rb
470
471
  - spec/views/catalog/_show_default.erb_spec.rb
471
472
  - spec/views/catalog/_show_sidebar.erb_spec.rb
473
+ - spec/views/catalog/_thumbnail_default.erb_spec.rb
472
474
  - spec/views/catalog/index.atom.builder_spec.rb
473
475
  - tasks/blacklight.rake
474
476
  - test_support/data/test_data.utf8.mrc
@@ -559,9 +561,11 @@ test_files:
559
561
  - spec/test_app_templates/lib/generators/test_app_generator.rb
560
562
  - spec/test_app_templates/lib/tasks/blacklight_test_app.rake
561
563
  - spec/views/catalog/_constraints_element.html.erb_spec.rb
564
+ - spec/views/catalog/_document.html.erb_spec.rb
562
565
  - spec/views/catalog/_document_list.html.erb_spec.rb
563
566
  - spec/views/catalog/_facets.html.erb_spec.rb
564
567
  - spec/views/catalog/_index_default.erb_spec.rb
565
568
  - spec/views/catalog/_show_default.erb_spec.rb
566
569
  - spec/views/catalog/_show_sidebar.erb_spec.rb
570
+ - spec/views/catalog/_thumbnail_default.erb_spec.rb
567
571
  - spec/views/catalog/index.atom.builder_spec.rb