blacklight-gallery 0.7.0 → 0.8.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: e818cba7abe5286ac59f4451915533336dbdf8cc
4
- data.tar.gz: e6947e5e2c39fdcd8bce1c111a4ec7b3fbd9943b
3
+ metadata.gz: 7b4fda01380884b93d14ce8d3bbf36132b82b3ec
4
+ data.tar.gz: e74c17bc14f0723b121095d0f0b706c3f8d4913a
5
5
  SHA512:
6
- metadata.gz: 877ba9ab192d0dcdea0b9fdf7e0f4ff1552bcf40174583dbab32b2908a5ffa9dcb7d6919e4f11a73026356c77488eb56d8a01808f79f601087f096ec9f584481
7
- data.tar.gz: 5c8dc51a286dad2ba5eea8301b4a993b92d2ad20bdbb25763d75d76067861d66e92599db90299f250a4f670b2f6027936ea8774740250e888d3df40de5cac207
6
+ metadata.gz: 7ec1c482d1b18ddbe9c5058098d8b7c38bb9899e2f000ccbd1c26526c33e5053ea4148501d677b65837b4a2c90a11934c23f061c600cb7cb177f5d7fda86484c
7
+ data.tar.gz: 4b31cff43f788b527ba4b11c53300588da6a88b711ebb165981c0b9ec3331ab1856c0e5c135f3c146427894c222ca8c9a5b27dcd8fde5bfc3a14e13825eea204
@@ -10,6 +10,25 @@ module Blacklight
10
10
  end.join().html_safe
11
11
  end
12
12
 
13
+ def render_slideshow_tag(document, image_options = {}, url_options = {})
14
+ if blacklight_config.view_config(document_index_view_type).slideshow_method
15
+ method_name = blacklight_config.view_config(document_index_view_type).slideshow_method
16
+ send(method_name, document, image_options)
17
+ elsif blacklight_config.view_config(document_index_view_type).slideshow_field
18
+ url = slideshow_image_url(document)
19
+
20
+ image_tag url, image_options if url.present?
21
+ elsif has_thumbnail?(document)
22
+ render_thumbnail_tag(document, image_options, url_options.reverse_merge(suppress_link: true))
23
+ end
24
+ end
25
+
26
+ def slideshow_image_url(document)
27
+ if document.has? blacklight_config.view_config(document_index_view_type).slideshow_field
28
+ document.first(blacklight_config.view_config(document_index_view_type).slideshow_field)
29
+ end
30
+ end
31
+
13
32
  def gallery_wrapper_template(object)
14
33
  format = document_partial_name(object, nil)
15
34
  ['index_gallery_%{format}_wrapper', 'index_gallery'].each do |str|
@@ -1,6 +1,6 @@
1
1
  <div class="item<%= ' active' if document_counter == 0 %>">
2
2
  <div class="frame">
3
- <%= image_tag thumbnail_url(document) if thumbnail_url(document) %>
3
+ <%= render_slideshow_tag(document) %>
4
4
  <div class="caption">
5
5
  <%= index_presenter(document).label(document_show_link_field(document)) %>
6
6
  </div>
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Gallery
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Blacklight::GalleryHelper, :type => :helper do
4
+ before do
5
+ allow(helper).to receive(:blacklight_configuration_context).and_return(double(evaluate_if_unless_configuration: true))
6
+ end
4
7
  describe "#render_gallery_collection" do
5
8
  let(:template) { double }
6
9
  before do
@@ -25,4 +28,83 @@ describe Blacklight::GalleryHelper, :type => :helper do
25
28
  expect(subject.virtual_path).to eq 'catalog/_index_gallery'
26
29
  end
27
30
  end
31
+
32
+ describe "render_slideshow_tag" do
33
+ let(:document) { instance_double(SolrDocument) }
34
+
35
+ it "calls the provided slideshow method" do
36
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_method => :xyz) ))
37
+ expect(helper).to receive_messages(:xyz => "some-slideshow")
38
+ expect(helper.render_slideshow_tag(document)).to eq 'some-slideshow'
39
+ end
40
+
41
+ it "creates an image tag from the given field" do
42
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_field => :xyz) ))
43
+
44
+ allow(document).to receive(:has?).with(:xyz).and_return(true)
45
+ allow(document).to receive(:first).with(:xyz).and_return("http://example.com/some.jpg")
46
+ expect(helper.render_slideshow_tag(document)).to match /img/
47
+ end
48
+
49
+ it "does not link to the document if the url options are false" do
50
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_method => :xyz) ))
51
+ allow(helper).to receive_messages(:xyz => "some-slideshow")
52
+
53
+ result = helper.render_slideshow_tag document, {}, false
54
+ expect(result).to eq "some-slideshow"
55
+ end
56
+
57
+ it "does not link to the document if the url options have :suppress_link" do
58
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_method => :xyz) ))
59
+ allow(helper).to receive_messages(:xyz => "some-slideshow")
60
+
61
+ result = helper.render_slideshow_tag document, {}, suppress_link: true
62
+ expect(result).to eq "some-slideshow"
63
+ end
64
+
65
+
66
+ it "returns nil if no slideshow is available" do
67
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new() ))
68
+ expect(helper.render_slideshow_tag document).to be_nil
69
+ end
70
+
71
+ it "returns nil if no slideshow is returned from the slideshow method" do
72
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_method => :xyz) ))
73
+ allow(helper).to receive_messages(:xyz => nil)
74
+
75
+ expect(helper.render_slideshow_tag document).to be_nil
76
+ end
77
+
78
+ it "returns nil if no slideshow is in the document" do
79
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_field => :xyz) ))
80
+
81
+ allow(document).to receive(:has?).with(:xyz).and_return(false)
82
+
83
+ expect(helper.render_slideshow_tag document).to be_nil
84
+ end
85
+
86
+ it "falls back to a thumbnail" do
87
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
88
+ allow(helper).to receive(:xyz).and_return('thumbnail-image')
89
+
90
+ expect(helper.render_slideshow_tag document).to eq 'thumbnail-image'
91
+ end
92
+ end
93
+
94
+ describe "slideshow_url" do
95
+ it "pulls the configured slideshow field out of the document" do
96
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_field => :xyz) ))
97
+ document = instance_double(SolrDocument)
98
+ allow(document).to receive(:has?).with(:xyz).and_return(true)
99
+ allow(document).to receive(:first).with(:xyz).and_return("asdf")
100
+ expect(helper.slideshow_image_url document).to eq("asdf")
101
+ end
102
+
103
+ it "returns nil if the slideshow field doesn't exist" do
104
+ allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:slideshow_field => :xyz) ))
105
+ document = instance_double(SolrDocument)
106
+ allow(document).to receive(:has?).with(:xyz).and_return(false)
107
+ expect(helper.slideshow_image_url document).to be_nil
108
+ end
109
+ end
28
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-gallery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  version: '0'
317
317
  requirements: []
318
318
  rubyforge_project:
319
- rubygems_version: 2.6.8
319
+ rubygems_version: 2.5.2
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: Gallery display for Blacklight