blacklight-gallery 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/blacklight_gallery/_gallery.scss +5 -0
- data/app/components/blacklight/gallery/slideshow_preview_component.rb +15 -2
- data/lib/blacklight/gallery/version.rb +1 -1
- data/spec/components/blacklight/gallery/slideshow_preview_component_spec.rb +52 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 293ba63382be492c6f0e70f34542b75cd37b3c21904ef7f4482ae90e59709a69
|
4
|
+
data.tar.gz: 9f930cbb7b02a7353bb98aec29393b7f0bee7febefcff4b53e919ae294becd25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18434c888670a0925c24fbfd7ad0ca57c341a40dc91ea138bed735ed208ef236989509b76d6971a8856a8126a9b7282fa3c480fbf98677bd624df4d71c62892
|
7
|
+
data.tar.gz: 9caafa8f14d044098c1d1b7c94d221b6398004a63d72bd580992498f12ca580882e1417977e3e64b2d61d52ae2caf9d9c79b3a8a1e2c4cc121d93ae5cc7780b0
|
@@ -11,11 +11,24 @@ module Blacklight
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def before_render
|
14
|
-
|
15
|
-
thumbnail(content_tag(:div, t('.missing_image', scope: [:blacklight_gallery]), class: 'thumbnail thumbnail-placeholder')) if thumbnail.blank?
|
14
|
+
populate_thumbnail_slot if thumbnail.blank?
|
16
15
|
super
|
17
16
|
end
|
18
17
|
|
18
|
+
# populate the thumbnail slot with a value if one wasn't explicitly provided
|
19
|
+
def populate_thumbnail_slot
|
20
|
+
thumbnail_content = presenter.thumbnail.render({ alt: presenter.heading }) if presenter.thumbnail.exists?
|
21
|
+
unless thumbnail_content.present?
|
22
|
+
thumbnail_content = content_tag(
|
23
|
+
:div,
|
24
|
+
t(:missing_image, scope: %i[blacklight_gallery catalog grid_slideshow]),
|
25
|
+
class: 'thumbnail thumbnail-placeholder'
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
thumbnail(thumbnail_content)
|
30
|
+
end
|
31
|
+
|
19
32
|
def presenter
|
20
33
|
@presenter ||= @view_context.document_presenter(@document)
|
21
34
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Gallery::SlideshowPreviewComponent, type: :component do
|
6
|
+
subject(:component) { described_class.new(document: document, document_counter: 5, presenter: presenter, **attr) }
|
7
|
+
|
8
|
+
let(:attr) { {} }
|
9
|
+
let(:view_context) { controller.view_context }
|
10
|
+
let(:render) do
|
11
|
+
component.render_in(view_context)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:rendered) do
|
15
|
+
Capybara::Node::Simple.new(render)
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
19
|
+
let(:presenter) { Blacklight::IndexPresenter.new(document, view_context, blacklight_config) }
|
20
|
+
|
21
|
+
before do
|
22
|
+
allow(view_context).to receive(:blacklight_config).and_return(blacklight_config)
|
23
|
+
allow(view_context).to receive(:current_search_session).and_return(nil)
|
24
|
+
allow(view_context).to receive(:search_session).and_return({})
|
25
|
+
|
26
|
+
# dumb hack to get our stubbing into the thumbnail component
|
27
|
+
allow(controller).to receive(:view_context).and_return(view_context)
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:blacklight_config) do
|
31
|
+
Blacklight::Configuration.new.tap do |config|
|
32
|
+
config.index.thumbnail_field = 'thumbnail_path_ss'
|
33
|
+
config.track_search_session = false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'default thumbnail' do
|
38
|
+
let(:document) { SolrDocument.new(id: 'abc', thumbnail_path_ss: 'http://example.com/image.jpg') }
|
39
|
+
|
40
|
+
it 'renders the thumbnail' do
|
41
|
+
puts render
|
42
|
+
expect(rendered).to have_selector '.thumbnail img[@src="http://example.com/image.jpg"]'
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the presenter returns nothing' do
|
46
|
+
let(:document) { SolrDocument.new(id: 'abc') }
|
47
|
+
|
48
|
+
subject { rendered }
|
49
|
+
it { is_expected.to have_selector '.thumbnail-placeholder', text: 'Missing' }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
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: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -307,6 +307,7 @@ files:
|
|
307
307
|
- solr/conf/xslt/luke.xsl
|
308
308
|
- spec/components/blacklight/gallery/document_component_spec.rb
|
309
309
|
- spec/components/blacklight/gallery/slideshow_component_spec.rb
|
310
|
+
- spec/components/blacklight/gallery/slideshow_preview_component_spec.rb
|
310
311
|
- spec/features/gallery_spec.rb
|
311
312
|
- spec/features/masonry_spec.rb
|
312
313
|
- spec/features/slideshow_spec.rb
|
@@ -345,6 +346,7 @@ summary: Gallery display for Blacklight
|
|
345
346
|
test_files:
|
346
347
|
- spec/components/blacklight/gallery/document_component_spec.rb
|
347
348
|
- spec/components/blacklight/gallery/slideshow_component_spec.rb
|
349
|
+
- spec/components/blacklight/gallery/slideshow_preview_component_spec.rb
|
348
350
|
- spec/features/gallery_spec.rb
|
349
351
|
- spec/features/masonry_spec.rb
|
350
352
|
- spec/features/slideshow_spec.rb
|