blacklight-gallery 2.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +45 -0
- data/README.md +1 -1
- data/app/assets/javascripts/blacklight_gallery/default.js +0 -1
- data/app/assets/javascripts/blacklight_gallery/masonry.js +1 -1
- data/app/assets/javascripts/blacklight_gallery/osd_viewer.js +1 -1
- data/app/assets/javascripts/blacklight_gallery/slideshow.js +1 -2
- data/app/assets/stylesheets/blacklight_gallery/_gallery.scss +11 -17
- data/app/assets/stylesheets/blacklight_gallery/_masonry.scss +55 -24
- data/app/assets/stylesheets/blacklight_gallery/_slideshow.scss +5 -3
- data/app/components/blacklight/gallery/document_component.html.erb +21 -0
- data/app/components/blacklight/gallery/document_component.rb +11 -0
- data/app/components/blacklight/gallery/slideshow_component.html.erb +12 -0
- data/app/components/blacklight/gallery/slideshow_component.rb +40 -0
- data/app/components/blacklight/gallery/slideshow_preview_component.html.erb +5 -0
- data/app/components/blacklight/gallery/slideshow_preview_component.rb +28 -0
- data/app/helpers/blacklight/gallery_helper.rb +0 -38
- data/app/models/concerns/blacklight/gallery/openseadragon_solr_document.rb +1 -1
- data/app/views/catalog/_document_gallery.html.erb +4 -3
- data/app/views/catalog/_document_masonry.html.erb +2 -3
- data/app/views/catalog/_document_slideshow.html.erb +26 -5
- data/app/views/catalog/_slideshow_modal.html.erb +2 -3
- data/blacklight-gallery.gemspec +4 -4
- data/config/locales/blacklight-gallery.ar.yml +7 -4
- data/lib/blacklight/gallery/engine.rb +0 -1
- data/lib/blacklight/gallery/version.rb +1 -1
- data/lib/generators/blacklight_gallery/install_generator.rb +10 -3
- data/lib/generators/blacklight_gallery/templates/blacklight_gallery.js +2 -1
- data/spec/components/blacklight/gallery/document_component_spec.rb +46 -0
- data/spec/components/blacklight/gallery/slideshow_component_spec.rb +67 -0
- data/spec/features/gallery_spec.rb +3 -4
- data/spec/features/masonry_spec.rb +2 -3
- data/spec/features/slideshow_spec.rb +0 -2
- data/spec/models/concerns/openseadragon_solr_document_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -11
- data/spec/views/catalog/_document_slideshow.html.erb_spec.rb +15 -5
- metadata +43 -39
- data/.travis.yml +0 -21
- data/app/views/catalog/_grid_slideshow.html.erb +0 -11
- data/app/views/catalog/_index_gallery.html.erb +0 -14
- data/app/views/catalog/_index_masonry.html.erb +0 -8
- data/app/views/catalog/_index_masonry_default.html.erb +0 -1
- data/app/views/catalog/_index_slideshow.html.erb +0 -11
- data/app/views/catalog/_slideshow.html.erb +0 -23
- data/spec/helpers/blacklight/gallery_helper_spec.rb +0 -110
- data/spec/views/catalog/_index_gallery.html.erb_spec.rb +0 -22
- data/spec/views/catalog/_index_masonry.html.erb_spec.rb +0 -34
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
notifications:
|
5
|
-
email: false
|
6
|
-
|
7
|
-
rvm:
|
8
|
-
- 2.5.3
|
9
|
-
- 2.6.0
|
10
|
-
|
11
|
-
notifications:
|
12
|
-
irc: "irc.freenode.org#blacklight"
|
13
|
-
email:
|
14
|
-
- blacklight-commits@googlegroups.com
|
15
|
-
|
16
|
-
env:
|
17
|
-
global:
|
18
|
-
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
19
|
-
- RAILS_VERSION='5.2.3'
|
20
|
-
|
21
|
-
jdk: openjdk11
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<div class="document">
|
2
|
-
<div class="thumbnail">
|
3
|
-
<%= link_to '#', data: { :'slide-to' => document_counter, toggle: "modal", target: "#slideshow-modal" } do %>
|
4
|
-
<% if thumbnail_url(document) %>
|
5
|
-
<%= image_tag thumbnail_url(document), class: 'img-thumbnail', alt: index_presenter(document).heading %>
|
6
|
-
<% else %>
|
7
|
-
<%= t('.missing_image', scope: [:blacklight_gallery]) %>
|
8
|
-
<% end %>
|
9
|
-
<% end %>
|
10
|
-
</div>
|
11
|
-
</div>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<div class="document col-6 col-md-4">
|
2
|
-
<div class="thumbnail">
|
3
|
-
<%= render_thumbnail_tag(
|
4
|
-
document,
|
5
|
-
{ class: 'img-thumbnail', alt: '' },
|
6
|
-
counter: document_counter_with_offset(document_counter),
|
7
|
-
'aria-hidden': true,
|
8
|
-
tabindex: -1
|
9
|
-
) %>
|
10
|
-
<div class="caption">
|
11
|
-
<%= render_document_partials document, blacklight_config.view_config(:gallery).partials, :document_counter => document_counter %>
|
12
|
-
</div>
|
13
|
-
</div>
|
14
|
-
</div>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<div class="masonry document col-6 col-md-3">
|
2
|
-
<div class="thumbnail">
|
3
|
-
<%= render_thumbnail_tag(document, { class: 'img-thumbnail', alt: index_presenter(document).heading }, counter: document_counter_with_offset(document_counter)) %>
|
4
|
-
<div class="caption">
|
5
|
-
<%= render_document_partials document, blacklight_config.view_config(:masonry).partials, :document_counter => document_counter %>
|
6
|
-
</div>
|
7
|
-
</div>
|
8
|
-
</div>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= link_to_document(document, truncate(index_presenter(document).label(document_show_link_field(document)), length: 89)) %>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<div class="item<%= ' active' if document_counter == 0 %>">
|
2
|
-
<div class="frame">
|
3
|
-
<%= render_slideshow_tag(document, { alt: '' }) %>
|
4
|
-
<div class="caption">
|
5
|
-
<%= index_presenter(document).label(document_show_link_field(document)) %>
|
6
|
-
</div>
|
7
|
-
<span class="counter">
|
8
|
-
<%= t :'blacklight_gallery.catalog.modal_slideshow.counter', counter: document_counter + 1, count: count %>
|
9
|
-
</span>
|
10
|
-
</div>
|
11
|
-
</div>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<div id="slideshow" class="slideshow-presenter">
|
2
|
-
<!-- Wrapper for slides -->
|
3
|
-
<div class="slideshow-inner">
|
4
|
-
<%= render collection: documents, as: :document, partial: 'index_slideshow', locals: {count: documents.count} %>
|
5
|
-
</div>
|
6
|
-
|
7
|
-
<!-- Controls -->
|
8
|
-
<a class="left carousel-control prev" href="#slideshow" data-slide="prev">
|
9
|
-
<%= blacklight_icon 'chevron_left', { additional_options: { label_context: 'previous_image' }} %>
|
10
|
-
</a>
|
11
|
-
<a class="right carousel-control next" href="#slideshow" data-slide="next">
|
12
|
-
<%= blacklight_icon 'chevron_right', { additional_options: { label_context: 'next_image' }} %>
|
13
|
-
</a>
|
14
|
-
|
15
|
-
<div class="controls text-center">
|
16
|
-
<button class="btn btn-sm btn-link" data-behavior="pause-slideshow" aria-label="<%= t('blacklight_gallery.catalog.slideshow.pause') %>">
|
17
|
-
<%= blacklight_icon 'pause_slideshow' %>
|
18
|
-
</button>
|
19
|
-
<button class="btn btn-sm btn-link" data-behavior="start-slideshow" aria-label="<%= t('blacklight_gallery.catalog.slideshow.start') %>">
|
20
|
-
<%= blacklight_icon 'start_slideshow' %>
|
21
|
-
</button>
|
22
|
-
</div>
|
23
|
-
</div>
|
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
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
|
7
|
-
describe "#render_gallery_collection" do
|
8
|
-
let(:template) { double }
|
9
|
-
before do
|
10
|
-
allow(template).to receive(:render).and_return("hello ")
|
11
|
-
allow(helper).to receive(:gallery_wrapper_template).and_return(template)
|
12
|
-
end
|
13
|
-
let(:documents) { [ double, double] }
|
14
|
-
subject { helper.render_gallery_collection documents}
|
15
|
-
|
16
|
-
it { is_expected.to eq 'hello hello ' }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#gallery_wrapper_template" do
|
20
|
-
before do
|
21
|
-
allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
22
|
-
helper.lookup_context.prefixes << "catalog"
|
23
|
-
end
|
24
|
-
|
25
|
-
subject { helper.gallery_wrapper_template SolrDocument.new }
|
26
|
-
|
27
|
-
it "should be the default template" do
|
28
|
-
expect(subject.virtual_path).to eq 'catalog/_index_gallery'
|
29
|
-
end
|
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.tap { |config| config.index.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.tap { |config| config.index.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.tap { |config| config.index.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.tap { |config| config.index.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)
|
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.tap { |config| config.index.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.tap { |config| config.index.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.tap { |config| config.index.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.tap { |config| config.index.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.tap { |config| config.index.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
|
110
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "catalog/_index_gallery.html.erb", :type => :view do
|
4
|
-
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
|
-
|
6
|
-
let(:document) { stub_model(::SolrDocument) }
|
7
|
-
|
8
|
-
before do
|
9
|
-
blacklight_config.view.gallery.partials = ['a', 'b']
|
10
|
-
allow(view).to receive_messages(blacklight_config: blacklight_config)
|
11
|
-
allow(view).to receive_messages(document: document)
|
12
|
-
allow(view).to receive_messages(document_counter: 3, document_counter_with_offset: 3)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should have thumbnail and caption" do
|
16
|
-
expect(view).to receive(:render_thumbnail_tag).with(document, { class: 'img-thumbnail', alt: '' }, hash_including(:counter)).and_return('Thumbnail')
|
17
|
-
expect(view).to receive(:render_document_partials).with(document, ['a', 'b'], document_counter: 3).and_return('Z')
|
18
|
-
render
|
19
|
-
expect(rendered).to have_selector '.thumbnail', text: 'Thumbnail'
|
20
|
-
expect(rendered).to have_selector '.caption', text: 'Z'
|
21
|
-
end
|
22
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "catalog/_document_masonry.html.erb", :type => :view do
|
4
|
-
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
|
-
let(:documents) { [stub_model(::SolrDocument), stub_model(::SolrDocument)] }
|
6
|
-
let(:presenter) { instance_double(Blacklight::IndexPresenter, heading: 'xyz')}
|
7
|
-
before do
|
8
|
-
allow(view).to receive_messages(blacklight_config: blacklight_config)
|
9
|
-
allow(view).to receive_messages(index_presenter: presenter)
|
10
|
-
allow(view).to receive_messages(documents: documents)
|
11
|
-
allow(view).to receive_messages(document_counter: 1)
|
12
|
-
allow(view).to receive_messages(document_counter_with_offset: 1)
|
13
|
-
allow(view).to receive_messages(render_document_partials: "Caption")
|
14
|
-
allow(view).to receive_messages(render_thumbnail_tag: "Thumbnail")
|
15
|
-
render
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should render a container div with a data attribute to initiate the masonry plugin' do
|
19
|
-
expect(rendered).to have_css('#documents[data-behavior="masonry-gallery"]')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should render a .masonry.document div for each document' do
|
23
|
-
expect(rendered).to have_css('.masonry.document', count: 2)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should render the thumbnail' do
|
27
|
-
expect(rendered).to have_css('.thumbnail', text: 'Thumbnail')
|
28
|
-
expect(view).to have_received(:render_thumbnail_tag).with(documents.first, { class: 'img-thumbnail', alt: 'xyz' }, counter: 1)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should render the caption' do
|
32
|
-
expect(rendered).to have_css('.caption', text: 'Caption')
|
33
|
-
end
|
34
|
-
end
|