blacklight-gallery 4.6.0 → 4.6.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
  SHA256:
3
- metadata.gz: b3f0a42b90e61a4eb36e76d0be574f4d8f3f2a8c55afb3de20e69bca1f88a086
4
- data.tar.gz: b74abe92f757dd6a2cfd6a7043364915a591030fd1bd6560bb6f64f973d80f94
3
+ metadata.gz: 8b75282f6589ca914165117342f3f5122f114ec3fcb399dfc5ae660eaeb678ea
4
+ data.tar.gz: 7f63ed97b52f21db2a92688e8d9e20ad17997c74a98cdacfd0e488c7d675c6ae
5
5
  SHA512:
6
- metadata.gz: 6bdc5e6d5bb2eba2f1d425513ce9d8623e73968734601c2fc239cb9937b809cfb7b86a6e3334ace2cd4c4a0d3155448597258b259f2d66ed329c95f43d2e5c77
7
- data.tar.gz: f8019948c79a90819b928c8548430fd7df8dce919de4f3d3e0a331ab54e344c4d7ed2f987c9df937f308663ca360c6cde6a751b06edeebfc1f3458423b9ad48d
6
+ metadata.gz: 5122d73ef112b00f340999c31faa6cb572c1ea83dc639164475be9f91596ad64c995cc0acfb9226145c343cf191b4f9f401af5a9912eda82cbdad507a69d24f6
7
+ data.tar.gz: f83b3438b30ce60a936a5ca98694dc2a50c01d41cf37b8fdc0a8de628f171d0396d5d8de952a65936cff015cafedf482e9ccf963e51df1b958bede7c9e0c4b5e
@@ -19,6 +19,7 @@ jobs:
19
19
  experimental: [false]
20
20
  additional_engine_cart_rails_options: [""]
21
21
  additional_name: [""]
22
+ view_component_version: ["~> 3.12"]
22
23
  include:
23
24
  - ruby: "3.1"
24
25
  rails_version: 6.1.7
@@ -35,6 +36,12 @@ jobs:
35
36
  blacklight_version: "github"
36
37
  experimental: true
37
38
  additional_name: Blacklight main branch
39
+ - ruby: "3.2"
40
+ rails_version: "7.0.4"
41
+ blacklight_version: "~> 7.0"
42
+ experimental: false
43
+ view_component_version: "~> 2.83"
44
+ additional_name: "/ ViewComponent 2"
38
45
  - ruby: "3.2"
39
46
  rails_version: "7.0.4"
40
47
  blacklight_version: "github"
@@ -44,6 +51,7 @@ jobs:
44
51
  env:
45
52
  RAILS_VERSION: ${{ matrix.rails_version }}
46
53
  BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
54
+ VIEW_COMPONENT_VERSION: ${{ matrix.view_component_version }}
47
55
  ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
48
56
  steps:
49
57
  - uses: actions/checkout@v4
@@ -2,18 +2,18 @@
2
2
  <div class="osd-toolbar row">
3
3
  <div class="col-md-6 pagination">
4
4
  <% if count > 1 %>
5
- <% osd_config = osd_config_referencestrip.merge(osd_config) %>
6
- <a id="<%= id_prefix %>-previous"><%= render Blacklight::Gallery::Icons::ChevronLeftComponent.new %></a>
7
- <span id="<%= id_prefix %>-page">1</span> of <%= count %>
8
- <a id="<%= id_prefix %>-next"><%= render Blacklight::Gallery::Icons::ChevronRightComponent.new %></a>
5
+ <% multi_page_osd_config = osd_config_referencestrip.merge(osd_config) %>
6
+ <a id="<%= @id_prefix %>-previous"><%= render Blacklight::Gallery::Icons::ChevronLeftComponent.new %></a>
7
+ <span id="<%= @id_prefix %>-page">1</span>&nbsp; of <%= count %>
8
+ <a id="<%= @id_prefix %>-next"><%= render Blacklight::Gallery::Icons::ChevronRightComponent.new %></a>
9
9
  <% end %>
10
10
  </div>
11
11
  <div class="col-md-6 controls">
12
- <a id="<%= id_prefix %>-zoom-in"><%= render Blacklight::Gallery::Icons::AddCircleComponent.new %></a>
13
- <a id="<%= id_prefix %>-zoom-out"><%= render Blacklight::Gallery::Icons::RemoveCircleComponent.new %></a>
14
- <a id="<%= id_prefix %>-home"><%= render Blacklight::Gallery::Icons::ResizeSmallComponent.new %></a>
15
- <a id="<%= id_prefix %>-full-page"><%= render Blacklight::Gallery::Icons::CustomFullscreenComponent.new %></a>
12
+ <a id="<%= @id_prefix %>-zoom-in"><%= render Blacklight::Gallery::Icons::AddCircleComponent.new %></a>
13
+ <a id="<%= @id_prefix %>-zoom-out"><%= render Blacklight::Gallery::Icons::RemoveCircleComponent.new %></a>
14
+ <a id="<%= @id_prefix %>-home"><%= render Blacklight::Gallery::Icons::ResizeSmallComponent.new %></a>
15
+ <a id="<%= @id_prefix %>-full-page"><%= render Blacklight::Gallery::Icons::CustomFullscreenComponent.new %></a>
16
16
  </div>
17
17
  </div>
18
- <%= helpers.openseadragon_picture_tag image, class: 'osd-image row', data: { openseadragon: osd_config } %>
18
+ <%= helpers.openseadragon_picture_tag image, class: 'osd-image row', data: { openseadragon: multi_page_osd_config ? multi_page_osd_config : osd_config } %>
19
19
  </div>
@@ -12,6 +12,7 @@ module Blacklight
12
12
  @presenter = presenter
13
13
  @view_config = view_config
14
14
  @classes = classes
15
+ @id_prefix = id_prefix
15
16
  end
16
17
 
17
18
  def image
@@ -33,21 +34,20 @@ module Blacklight
33
34
  def osd_config
34
35
  {
35
36
  crossOriginPolicy: false,
36
- zoomInButton: "#{id_prefix}-zoom-in",
37
- zoomOutButton: "#{id_prefix}-zoom-out",
38
- homeButton: "#{id_prefix}-home",
39
- fullPageButton: "#{id_prefix}-full-page",
40
- nextButton: "#{id_prefix}-next",
41
- previousButton: "#{id_prefix}-previous"
37
+ zoomInButton: "#{@id_prefix}-zoom-in",
38
+ zoomOutButton: "#{@id_prefix}-zoom-out",
39
+ homeButton: "#{@id_prefix}-home",
40
+ fullPageButton: "#{@id_prefix}-full-page",
41
+ nextButton: "#{@id_prefix}-next",
42
+ previousButton: "#{@id_prefix}-previous"
42
43
  }
43
44
  end
44
45
 
45
46
  def osd_config_referencestrip
46
47
  {
47
48
  showReferenceStrip: true,
48
- referenceStripPosition: 'OUTSIDE',
49
+ sequenceMode: true,
49
50
  referenceStripScroll: 'vertical',
50
- referenceStripWidth: 100,
51
51
  referenceStripBackgroundColor: 'transparent'
52
52
  }
53
53
  end
@@ -7,7 +7,8 @@ module Blacklight
7
7
 
8
8
  def initialize(document:, document_counter: nil, **args)
9
9
  super(document: document, document_counter: document_counter, **args)
10
- @document_counter = document_counter || @counter
10
+
11
+ @slide_to = @counter - 1
11
12
  end
12
13
 
13
14
  def before_render
@@ -45,8 +46,8 @@ module Blacklight
45
46
  {
46
47
  'context-href': nil,
47
48
  context_href: nil,
48
- 'slide-to': @document_counter,
49
- 'bs-slide-to': @document_counter,
49
+ 'slide-to': @slide_to,
50
+ 'bs-slide-to': @slide_to,
50
51
  toggle: "modal",
51
52
  'bs-toggle': "modal",
52
53
  target: "#slideshow-modal",
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Gallery
3
- VERSION = "4.6.0"
3
+ VERSION = "4.6.1"
4
4
  end
5
5
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::Gallery::OpenseadragonEmbedComponent, type: :component do
6
+ subject(:component) do
7
+ described_class.new(
8
+ document: document,
9
+ presenter: presenter,
10
+ **attr
11
+ )
12
+ end
13
+
14
+ let(:attr) { {} }
15
+ let(:view_context) { vc_test_controller.view_context }
16
+ let(:render) do
17
+ component.render_in(view_context)
18
+ end
19
+
20
+ let(:rendered) do
21
+ Capybara::Node::Simple.new(render)
22
+ end
23
+
24
+ let(:document) do
25
+ SolrDocument.new(
26
+ id: 'x'
27
+ )
28
+ end
29
+
30
+ let(:presenter) { Blacklight::IndexPresenter.new(document, view_context, blacklight_config) }
31
+
32
+ before do
33
+ allow(view_context).to receive(:current_search_session).and_return(nil)
34
+ allow(view_context).to receive(:search_session).and_return({})
35
+ allow(view_context).to receive(:blacklight_config).and_return(blacklight_config)
36
+ end
37
+
38
+ describe 'openseadragon viewer' do
39
+ let(:blacklight_config) do
40
+ Blacklight::Configuration.new.tap do |config|
41
+ config.index.slideshow_method = :xyz
42
+ if Blacklight::VERSION > '8'
43
+ config.track_search_session.storage = false
44
+ else
45
+ config.track_search_session = false
46
+ end
47
+ end
48
+ end
49
+ it 'uses a single @id_prefix to generate unique control ids' do
50
+ expect(component.osd_config[:zoomInButton]).to include(component.instance_variable_get(:@id_prefix))
51
+ expect(component.osd_config[:zoomOutButton]).to include(component.instance_variable_get(:@id_prefix))
52
+ expect(component.osd_config[:homeButton]).to include(component.instance_variable_get(:@id_prefix))
53
+ expect(component.osd_config[:fullPageButton]).to include(component.instance_variable_get(:@id_prefix))
54
+ expect(component.osd_config[:nextButton]).to include(component.instance_variable_get(:@id_prefix))
55
+ expect(component.osd_config[:previousButton]).to include(component.instance_variable_get(:@id_prefix))
56
+ end
57
+ end
58
+ end
@@ -51,6 +51,14 @@ RSpec.describe Blacklight::Gallery::SlideshowPreviewComponent, type: :component
51
51
  expect(rendered).to have_selector '.thumbnail img[@src="http://example.com/image.jpg"]'
52
52
  end
53
53
 
54
+ it 'renders the correct slide number' do
55
+ if VIEW_COMPONENT_VERSION < 3
56
+ expect(rendered).to have_css '[data-slide-to=\"4\"][data-bs-slide-to=\"4\"]'
57
+ else
58
+ expect(rendered).to have_css '[data-slide-to=\"5\"][data-bs-slide-to=\"5\"]'
59
+ end
60
+ end
61
+
54
62
  context 'when the presenter returns nothing' do
55
63
  let(:document) { SolrDocument.new(id: 'abc') }
56
64
 
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@ require 'rspec/collection_matchers'
7
7
  require 'rspec/its'
8
8
  require 'rspec/rails'
9
9
  require 'rspec/active_model/mocks'
10
+ require 'view_component_v2_test_helpers'
10
11
 
11
12
  require 'selenium-webdriver'
12
13
 
@@ -19,4 +20,9 @@ require 'blacklight/gallery'
19
20
  RSpec.configure do |c|
20
21
  c.infer_spec_type_from_file_location!
21
22
  c.include ViewComponent::TestHelpers, type: :component
23
+ view_component_version = Gem.loaded_specs['view_component'].version
24
+ VIEW_COMPONENT_VERSION = view_component_version.segments.first
25
+ if VIEW_COMPONENT_VERSION < 3
26
+ c.include ViewComponentV2TestHelpers, type: :component
27
+ end
22
28
  end
@@ -3,3 +3,7 @@ if ENV['BLACKLIGHT_VERSION'] == 'github'
3
3
  elsif ENV['BLACKLIGHT_VERSION'] && !ENV['BLACKLIGHT_VERSION'].empty?
4
4
  gem 'blacklight', ENV['BLACKLIGHT_VERSION']
5
5
  end
6
+
7
+ unless ENV['VIEW_COMPONENT_VERSION'].to_s == ""
8
+ gem 'view_component', ENV.fetch('VIEW_COMPONENT_VERSION')
9
+ end
@@ -0,0 +1,20 @@
1
+ module ViewComponentV2TestHelpers
2
+ def vc_test_controller
3
+ @vc_test_controller ||= __vc_test_helpers_build_controller(ViewComponent::Base.test_controller.constantize)
4
+ end
5
+
6
+ def __vc_test_helpers_build_controller(klass)
7
+ klass.new.tap { |c| c.request = vc_test_request }.extend(Rails.application.routes.url_helpers)
8
+ end
9
+
10
+ def vc_test_request
11
+ require "action_controller/test_case"
12
+
13
+ @vc_test_request ||=
14
+ begin
15
+ out = ActionDispatch::TestRequest.create
16
+ out.session = ActionController::TestSession.new
17
+ out
18
+ end
19
+ end
20
+ 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: 4.6.0
4
+ version: 4.6.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: 2024-09-25 00:00:00.000000000 Z
11
+ date: 2024-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -288,6 +288,7 @@ files:
288
288
  - solr/conf/xslt/example_rss.xsl
289
289
  - solr/conf/xslt/luke.xsl
290
290
  - spec/components/blacklight/gallery/document_component_spec.rb
291
+ - spec/components/blacklight/gallery/openseadragon_embed_component_spec.rb
291
292
  - spec/components/blacklight/gallery/slideshow_component_spec.rb
292
293
  - spec/components/blacklight/gallery/slideshow_preview_component_spec.rb
293
294
  - spec/features/gallery_spec.rb
@@ -298,6 +299,7 @@ files:
298
299
  - spec/spec_helper.rb
299
300
  - spec/test_app_templates/Gemfile.extra
300
301
  - spec/test_app_templates/lib/generators/test_app_generator.rb
302
+ - spec/view_component_v2_test_helpers.rb
301
303
  - spec/views/catalog/_document_slideshow.html.erb_spec.rb
302
304
  - spec/views/catalog/_openseadragon_default.html.erb_spec.rb
303
305
  - vendor/assets/javascripts/imagesloaded.min.js
@@ -327,6 +329,7 @@ specification_version: 4
327
329
  summary: Gallery display for Blacklight
328
330
  test_files:
329
331
  - spec/components/blacklight/gallery/document_component_spec.rb
332
+ - spec/components/blacklight/gallery/openseadragon_embed_component_spec.rb
330
333
  - spec/components/blacklight/gallery/slideshow_component_spec.rb
331
334
  - spec/components/blacklight/gallery/slideshow_preview_component_spec.rb
332
335
  - spec/features/gallery_spec.rb
@@ -337,5 +340,6 @@ test_files:
337
340
  - spec/spec_helper.rb
338
341
  - spec/test_app_templates/Gemfile.extra
339
342
  - spec/test_app_templates/lib/generators/test_app_generator.rb
343
+ - spec/view_component_v2_test_helpers.rb
340
344
  - spec/views/catalog/_document_slideshow.html.erb_spec.rb
341
345
  - spec/views/catalog/_openseadragon_default.html.erb_spec.rb