blacklight-gallery 2.1.0 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +45 -0
  3. data/app/assets/javascripts/blacklight_gallery/default.js +0 -1
  4. data/app/assets/javascripts/blacklight_gallery/masonry.js +1 -1
  5. data/app/assets/javascripts/blacklight_gallery/osd_viewer.js +1 -1
  6. data/app/assets/javascripts/blacklight_gallery/slideshow.js +1 -2
  7. data/app/assets/stylesheets/blacklight_gallery/_gallery.scss +8 -3
  8. data/app/assets/stylesheets/blacklight_gallery/_masonry.scss +60 -22
  9. data/app/assets/stylesheets/blacklight_gallery/_slideshow.scss +5 -3
  10. data/app/components/blacklight/gallery/document_component.html.erb +21 -0
  11. data/app/components/blacklight/gallery/document_component.rb +11 -0
  12. data/app/components/blacklight/gallery/slideshow_component.html.erb +12 -0
  13. data/app/components/blacklight/gallery/slideshow_component.rb +40 -0
  14. data/app/components/blacklight/gallery/slideshow_preview_component.html.erb +5 -0
  15. data/app/components/blacklight/gallery/slideshow_preview_component.rb +28 -0
  16. data/app/helpers/blacklight/gallery_helper.rb +0 -38
  17. data/app/models/concerns/blacklight/gallery/openseadragon_solr_document.rb +1 -1
  18. data/app/views/catalog/_document_gallery.html.erb +4 -3
  19. data/app/views/catalog/_document_masonry.html.erb +2 -3
  20. data/app/views/catalog/_document_slideshow.html.erb +26 -5
  21. data/app/views/catalog/_slideshow_modal.html.erb +2 -3
  22. data/blacklight-gallery.gemspec +3 -3
  23. data/lib/blacklight/gallery/engine.rb +0 -1
  24. data/lib/blacklight/gallery/version.rb +1 -1
  25. data/lib/generators/blacklight_gallery/install_generator.rb +9 -3
  26. data/lib/generators/blacklight_gallery/templates/blacklight_gallery.js +2 -1
  27. data/spec/components/blacklight/gallery/document_component_spec.rb +46 -0
  28. data/spec/components/blacklight/gallery/slideshow_component_spec.rb +67 -0
  29. data/spec/features/gallery_spec.rb +3 -4
  30. data/spec/features/masonry_spec.rb +2 -3
  31. data/spec/features/slideshow_spec.rb +0 -2
  32. data/spec/fixtures/sample_solr_documents.yml +2495 -0
  33. data/spec/models/concerns/openseadragon_solr_document_spec.rb +1 -1
  34. data/spec/spec_helper.rb +4 -11
  35. data/spec/views/catalog/_document_slideshow.html.erb_spec.rb +15 -5
  36. metadata +33 -33
  37. data/.travis.yml +0 -38
  38. data/app/views/catalog/_grid_slideshow.html.erb +0 -11
  39. data/app/views/catalog/_index_gallery.html.erb +0 -14
  40. data/app/views/catalog/_index_masonry.html.erb +0 -8
  41. data/app/views/catalog/_index_masonry_default.html.erb +0 -1
  42. data/app/views/catalog/_index_slideshow.html.erb +0 -11
  43. data/app/views/catalog/_slideshow.html.erb +0 -23
  44. data/spec/helpers/blacklight/gallery_helper_spec.rb +0 -110
  45. data/spec/views/catalog/_index_gallery.html.erb_spec.rb +0 -22
  46. data/spec/views/catalog/_index_masonry.html.erb_spec.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4078c05e9420ccca75758be7fac8ccb01a4a512d8931f629c683bce2572b739
4
- data.tar.gz: a68b999ad88d7f80760a70acfd86f897cebe7d1c48744b893cb78fe85f567458
3
+ metadata.gz: 75869737771a35a9b62824ee70d28c70a0048121d3def3e8dd7b1144329b9065
4
+ data.tar.gz: c01ad9d99b5c5489d90595dc1c379694f791729b1a378a342b2fe10ce4ecfb1a
5
5
  SHA512:
6
- metadata.gz: '08669e46871077bba5222f7531675089ad2ad947a1a8ca366c041f220d01a960c5932475e250bcb43b5b9c04c83d8ffd08bb5a82a8db888533c6b13f21b31d73'
7
- data.tar.gz: 2dab16fdf85d599cf8a5cd05ff6c8b81e77436c59123d3b392bbc4dc01a04195d35c21f22728ba82a0ec5841f16b6e991b31b726e01239441ddb62493c6e8de0
6
+ metadata.gz: 52c8c610adee9c17b16d4960db2b12eb37a9a4348d6c91d6dc43632226799363c29e76559d0cf57359958dbfca501b389946940ccfd1c09a45bcfbcbfa8f32fc
7
+ data.tar.gz: e676667a4f344a36ba3b99da60e08e58f1a484e57bd552ad8c4dba44d960f9670dae8871ca5ed889e2b7217de45d20b12e0fcf759fdd5a92740ce255f656bbd4
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ rails_version: [6.1.1]
15
+ ruby: [2.7, 3.0]
16
+ env:
17
+ RAILS_VERSION: ${{ matrix.rails_version }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Install dependencies with Rails ${{ matrix.rails_version }}
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rake
28
+ test_rails52:
29
+ runs-on: ubuntu-latest
30
+ strategy:
31
+ matrix:
32
+ rails_version: [5.2.4.4, 6.0.3.4]
33
+ ruby: [2.7]
34
+ env:
35
+ RAILS_VERSION: ${{ matrix.rails_version }}
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ - name: Set up Ruby ${{ matrix.ruby }}
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby }}
42
+ - name: Install dependencies with Rails ${{ matrix.rails_version }}
43
+ run: bundle install
44
+ - name: Run tests
45
+ run: bundle exec rake
@@ -1,5 +1,4 @@
1
1
  //= require imagesloaded.min.js
2
2
  //= require masonry.min.js
3
3
  //= require blacklight_gallery/slideshow
4
- //= require blacklight_gallery/osd_viewer
5
4
  //= require blacklight_gallery/masonry
@@ -10,5 +10,5 @@
10
10
  })(jQuery);
11
11
 
12
12
  Blacklight.onLoad(function() {
13
- $('[data-behavior="masonry-gallery"]').BlacklightMasonry();
13
+ $('.documents-masonry').BlacklightMasonry();
14
14
  });
@@ -1 +1 @@
1
- //= require openseadragon/rails
1
+ //= require openseadragon/rails
@@ -85,7 +85,6 @@
85
85
  });
86
86
 
87
87
  $(document).on('click', '[data-slide], [data-slide-to]', function(e) {
88
-
89
88
  e.preventDefault();
90
89
 
91
90
  pos = parseInt($(this).attr('data-slide-to'), 10) || $(this).attr('data-slide');
@@ -122,5 +121,5 @@
122
121
 
123
122
 
124
123
  Blacklight.onLoad(function() {
125
- $('#slideshow').slideshow();
124
+ $('.documents-slideshow').slideshow();
126
125
  });
@@ -1,6 +1,7 @@
1
- .gallery {
1
+ .documents-gallery {
2
2
  .document {
3
3
  border-bottom: none;
4
+ display: flex;
4
5
 
5
6
  min-height: 250px;
6
7
  -webkit-flex: 1 0 250px;
@@ -24,16 +25,20 @@
24
25
 
25
26
  .document-metadata {
26
27
  dt, dd {
28
+ flex: 0 0 100%;
29
+ max-width: 100%;
30
+ padding-left: 0;
31
+ padding-right: 0;
27
32
  float: none;
28
33
  width: auto;
29
34
  clear: none;
30
35
  text-align: left;
31
36
  margin: 0;
32
37
  }
33
-
34
38
  }
35
39
  }
36
40
 
37
- #documents .gallery, .masonry-gallery, .slideshow-documents {
41
+ .documents-gallery, .documents-masonry, .documents-slideshow {
42
+ padding-bottom: $spacer;
38
43
  border-bottom: $pagination-border-width solid $pagination-border-color
39
44
  }
@@ -1,35 +1,73 @@
1
- .masonry {
2
- &.document {
3
- padding: 0;
4
- margin: 0 $spacer $spacer 0;
5
- border-bottom: 0;
6
- background-color: $gray-300;
7
- min-height: 70px;
1
+ .documents-masonry {
2
+ .document {
3
+ max-width: 25%;
4
+
5
+ &:hover, &:focus {
6
+ .caption-area {
7
+ display: block;
8
+ }
9
+ }
10
+
11
+ margin-bottom: $spacer;
12
+ position: relative;
13
+ width: auto;
14
+
15
+ .thumbnail-container {
16
+ position: relative;
17
+ min-height: 100px;
18
+ background-color: $gray-300;
19
+ }
8
20
 
9
21
  .img-thumbnail {
10
- border-radius: 0;
11
22
  padding: 0;
23
+ border-radius: 0;
12
24
  }
13
25
 
14
- .caption {
15
- &:first-child { display: block; } // To display captions when there is no image
16
- a {
17
- color: $gray-300;
26
+ .caption-area {
27
+ // styling for documents without thumbnails
28
+ &:first-child {
29
+ display: block;
30
+ max-height: 100%;
31
+ background-color: rgba(0,0,0,0.7) !important;
18
32
  }
19
- line-height: 17px;
20
- background-color: rgba(0,0,0,0.3);
21
- text-align: center;
33
+ @extend .bg-dark;
34
+ @extend .text-white;
35
+ display: none;
36
+ padding: 5px 7px;
37
+ background-color: rgba(0,0,0,0.5) !important;
22
38
  position: absolute;
23
39
  bottom: 0;
24
- right: 0;
25
- left: 0;
26
- width: 100%;
27
- padding: 5px 7px;
40
+ overflow-x: hidden;
41
+ overflow-y: scroll;
42
+ max-height: 75%;
43
+ }
44
+
45
+ .document-counter {
28
46
  display: none;
29
47
  }
30
- &:hover {
31
- .caption {
32
- display: block;
48
+
49
+ .index_title {
50
+ @extend .h6;
51
+ a, a:hover, a:visited, a:active {
52
+ @extend .stretched-link;
53
+ color: $gray-300
54
+ }
55
+ }
56
+
57
+ .document-metadata {
58
+ dt {
59
+ color: $gray-300;
60
+ }
61
+ dt, dd {
62
+ flex: 0 0 100%;
63
+ max-width: 100%;
64
+ padding-left: 0;
65
+ padding-right: 0;
66
+ float: none;
67
+ width: auto;
68
+ clear: none;
69
+ text-align: left;
70
+ margin: 0;
33
71
  }
34
72
  }
35
73
  }
@@ -101,7 +101,7 @@ $gray-dark: #343a40 !default;
101
101
  }
102
102
  }
103
103
 
104
- .slideshow-documents {
104
+ .documents-slideshow {
105
105
  margin: 0;
106
106
 
107
107
  .info {
@@ -120,10 +120,12 @@ $gray-dark: #343a40 !default;
120
120
  }
121
121
 
122
122
  .grid {
123
+ display: flex;
124
+ flex-wrap: wrap;
123
125
  $square-thumb-size: 100px;
124
126
 
125
127
  .document {
126
- float: left;
128
+ display: flex;
127
129
  margin-right: 20px;
128
130
  margin-top: 0;
129
131
  padding-top: 0;
@@ -140,7 +142,7 @@ $gray-dark: #343a40 !default;
140
142
  position: relative;
141
143
  width: $square-thumb-size;
142
144
 
143
- a > img {
145
+ img {
144
146
  height: $square-thumb-size;
145
147
  max-height: none;
146
148
  max-width: none;
@@ -0,0 +1,21 @@
1
+ <%= render(Blacklight::DocumentComponent.new(classes: 'col', component: :div, document: @document, counter: @counter)) do |component| %>
2
+ <% component.with(:body) do %>
3
+ <div class="thumbnail-container">
4
+ <% # Checking if #thumbnail takes any args before passing image_options. #thumbnail did not take any args in version 7.14.1 and earlier %>
5
+ <%= method(:thumbnail).arity.zero? ? thumbnail : thumbnail(class: 'img-thumbnail') %>
6
+
7
+ <div class="caption-area">
8
+ <div class="caption container">
9
+ <header class="documentHeader row">
10
+ <%= content_tag @title_component, class: 'index_title document-title-heading' do %>
11
+ <%= before_title %><%= title %><%= after_title %>
12
+ <% end %>
13
+ <%= actions %>
14
+ </header>
15
+ <%= content %>
16
+ <%= metadata %>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ <% end %>
21
+ <% end %>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Gallery
5
+ class DocumentComponent < Blacklight::DocumentComponent
6
+ def render_document_class(*args)
7
+ @view_context.render_document_class(*args)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ <div class="item<%= ' active' if @counter == 1 %>">
2
+ <div class="frame">
3
+ <%= slideshow_tag %>
4
+ <div class="caption">
5
+ <%= presenter.heading %>
6
+ </div>
7
+
8
+ <span class="counter">
9
+ <%= t :'blacklight_gallery.catalog.modal_slideshow.counter', counter: @counter, count: count %>
10
+ </span>
11
+ </div>
12
+ </div>
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Gallery
5
+ class SlideshowComponent < Blacklight::DocumentComponent
6
+ def count
7
+ @document.response&.total
8
+ end
9
+
10
+ def render_document_class(*args)
11
+ @view_context.render_document_class(*args)
12
+ end
13
+
14
+ def presenter
15
+ @presenter ||= @view_context.document_presenter(@document)
16
+ end
17
+
18
+ def slideshow_tag(image_options = { alt: '' })
19
+ if view_config.slideshow_method
20
+ method_name = view_config.slideshow_method
21
+ @view_context.send(method_name, @document, image_options)
22
+ elsif view_config.slideshow_field
23
+ url = slideshow_image_url
24
+
25
+ image_tag url, image_options if url.present?
26
+ elsif presenter.thumbnail.exists?
27
+ presenter.thumbnail.thumbnail_tag(image_options, url_options.reverse_merge(suppress_link: true))
28
+ end
29
+ end
30
+
31
+ def slideshow_image_url
32
+ @document.first(view_config.slideshow_field) if @document.has? view_config.slideshow_field
33
+ end
34
+
35
+ def view_config
36
+ presenter.thumbnail.view_config
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ <%= render(Blacklight::DocumentComponent.new(classes: 'slideshow-preview-thumbnail', component: :div, document: @document, counter: @counter)) do |component| %>
2
+ <% component.with(:body) do %>
3
+ <%= @view_context.link_to_document(@document, thumbnail, class: 'thumbnail', data: { 'context-href': nil, 'slide-to': @document_counter - 1, toggle: "modal", target: "#slideshow-modal" }) %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Gallery
5
+ class SlideshowPreviewComponent < Blacklight::DocumentComponent
6
+ with_collection_parameter :document
7
+
8
+ def initialize(document:, document_counter: nil, **args)
9
+ super(document: document, document_counter: document_counter, **args)
10
+ @document_counter = document_counter || @counter
11
+ end
12
+
13
+ def thumbnail
14
+ @thumbnail ||
15
+ (presenter.thumbnail.exists? && presenter.thumbnail.render({ alt: presenter.heading })) ||
16
+ content_tag(:div, t('.missing_image', scope: [:blacklight_gallery]), class: 'thumbnail thumbnail-placeholder')
17
+ end
18
+
19
+ def presenter
20
+ @presenter ||= @view_context.document_presenter(@document)
21
+ end
22
+
23
+ def render_document_class(*args)
24
+ @view_context.render_document_class(*args)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,42 +1,4 @@
1
1
  module Blacklight
2
2
  module GalleryHelper
3
- def render_gallery_collection documents
4
- index = -1
5
- documents.map do |object|
6
- index += 1
7
- template = gallery_wrapper_template(object)
8
- template.render(self, {document: object, document_counter: index}) if template
9
-
10
- end.join().html_safe
11
- end
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
-
32
- def gallery_wrapper_template(object)
33
- format = document_partial_name(object, nil)
34
- ['index_gallery_%{format}_wrapper', 'index_gallery'].each do |str|
35
- partial = str % { format: format }
36
- logger.debug "Looking for gallery document wrapper #{partial}"
37
- template = lookup_context.find_all(partial, lookup_context.prefixes, true, [:document, :document_counter], {}).first
38
- return template if template
39
- end
40
- end
41
3
  end
42
4
  end
@@ -1,6 +1,6 @@
1
1
  module Blacklight::Gallery::OpenseadragonSolrDocument
2
2
  def to_openseadragon(view_config = nil)
3
- return unless view_config.try(:tile_source_field) &&
3
+ return unless view_config&.tile_source_field &&
4
4
  fetch(view_config.tile_source_field, nil)
5
5
  Array(fetch(view_config.tile_source_field))
6
6
  end
@@ -1,4 +1,5 @@
1
- <% # container for all documents in index view -%>
2
- <div id="documents" class="gallery row <%= blacklight_config.view_config(:gallery).classes || 'row-cols-2 row-cols-md-3' %>">
3
- <%= render_gallery_collection documents %>
1
+ <div class="container">
2
+ <div id="documents" class="<%= (Array(blacklight_config.view_config(document_index_view_type).classes || 'row-cols-2 row-cols-md-3') + ["row documents-#{document_index_view_type}"]).join(' ') %>">
3
+ <%= render documents, as: :document %>
4
+ </div>
4
5
  </div>