blacklight-gallery 1.7.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +45 -0
  3. data/README.md +1 -1
  4. data/app/assets/images/blacklight/pause_slideshow.svg +1 -0
  5. data/app/assets/images/blacklight/start_slideshow.svg +1 -0
  6. data/app/assets/javascripts/blacklight_gallery/default.js +0 -1
  7. data/app/assets/javascripts/blacklight_gallery/masonry.js +1 -1
  8. data/app/assets/javascripts/blacklight_gallery/osd_viewer.js +1 -1
  9. data/app/assets/javascripts/blacklight_gallery/slideshow.js +11 -8
  10. data/app/assets/stylesheets/blacklight_gallery/_gallery.scss +11 -17
  11. data/app/assets/stylesheets/blacklight_gallery/_masonry.scss +55 -24
  12. data/app/assets/stylesheets/blacklight_gallery/_osd_viewer.scss +2 -2
  13. data/app/assets/stylesheets/blacklight_gallery/_slideshow.scss +11 -3
  14. data/app/components/blacklight/gallery/document_component.html.erb +20 -0
  15. data/app/components/blacklight/gallery/document_component.rb +11 -0
  16. data/app/components/blacklight/gallery/slideshow_component.html.erb +12 -0
  17. data/app/components/blacklight/gallery/slideshow_component.rb +40 -0
  18. data/app/components/blacklight/gallery/slideshow_preview_component.html.erb +5 -0
  19. data/app/components/blacklight/gallery/slideshow_preview_component.rb +28 -0
  20. data/app/helpers/blacklight/gallery_helper.rb +0 -38
  21. data/app/models/concerns/blacklight/gallery/openseadragon_solr_document.rb +1 -1
  22. data/app/views/catalog/_document_gallery.html.erb +4 -3
  23. data/app/views/catalog/_document_masonry.html.erb +2 -3
  24. data/app/views/catalog/_document_slideshow.html.erb +26 -9
  25. data/app/views/catalog/_openseadragon_default.html.erb +14 -15
  26. data/app/views/catalog/_slideshow_modal.html.erb +2 -2
  27. data/blacklight-gallery.gemspec +4 -4
  28. data/config/locales/blacklight-gallery.ar.yml +8 -4
  29. data/config/locales/blacklight-gallery.en.yml +6 -2
  30. data/config/locales/blacklight-gallery.es.yml +3 -2
  31. data/config/locales/blacklight-gallery.fr.yml +3 -2
  32. data/config/locales/blacklight-gallery.it.yml +3 -2
  33. data/config/locales/blacklight-gallery.pt-BR.yml +3 -0
  34. data/config/locales/blacklight-gallery.zh.yml +3 -2
  35. data/lib/blacklight/gallery/engine.rb +0 -2
  36. data/lib/blacklight/gallery/version.rb +1 -1
  37. data/lib/generators/blacklight_gallery/install_generator.rb +10 -3
  38. data/lib/generators/blacklight_gallery/templates/blacklight_gallery.js +2 -1
  39. data/spec/components/blacklight/gallery/document_component_spec.rb +46 -0
  40. data/spec/components/blacklight/gallery/slideshow_component_spec.rb +67 -0
  41. data/spec/features/gallery_spec.rb +3 -4
  42. data/spec/features/masonry_spec.rb +2 -3
  43. data/spec/features/slideshow_spec.rb +0 -2
  44. data/spec/models/concerns/openseadragon_solr_document_spec.rb +1 -1
  45. data/spec/spec_helper.rb +4 -11
  46. data/spec/views/catalog/_document_slideshow.html.erb_spec.rb +15 -5
  47. metadata +45 -39
  48. data/.travis.yml +0 -21
  49. data/app/views/catalog/_grid_slideshow.html.erb +0 -11
  50. data/app/views/catalog/_index_gallery.html.erb +0 -14
  51. data/app/views/catalog/_index_masonry.html.erb +0 -8
  52. data/app/views/catalog/_index_masonry_default.html.erb +0 -1
  53. data/app/views/catalog/_index_slideshow.html.erb +0 -11
  54. data/app/views/catalog/_slideshow.html.erb +0 -15
  55. data/spec/helpers/blacklight/gallery_helper_spec.rb +0 -110
  56. data/spec/views/catalog/_index_gallery.html.erb_spec.rb +0 -22
  57. 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: 88f1e7482c4ccd593780df7fe914534583e803b8cb7586a98db381f425ca3326
4
- data.tar.gz: f91d53c9e4d750ab085d7ba97c1a67f7d26e2dde31541b273e7195098453fedb
3
+ metadata.gz: 167f895cb50e7732ca7512b278aeacca04067b617da016f2a3b144c49a0fab53
4
+ data.tar.gz: e15f31f491f90153c9f4f90f0b124030e12c3e678bbcc2c448160bb55f403700
5
5
  SHA512:
6
- metadata.gz: 5ed81094a38b233941ad06c6b62e5555a407809151d87b902c9d5422fbe3953f9a58691510253c407f3f7e756b9d703ab4da4515558ecb9caf3cdbe6fdd986ce
7
- data.tar.gz: 05cca47ed3750c5c3b8663b910a106d1d1b2437d36e46972c7a52a215659966c0b1798f16dabb35601674f9234b3cb87777afafd426e71566a03ade868d485dd
6
+ metadata.gz: 4d7a2c5179ad2a1d18aa23fd8207aa6198d7385d1f17860edfae67d6bd1afcc897482013f271e6a4cb3ce0e519923a85b9bbdbb99ae922f348047bfef627a3db
7
+ data.tar.gz: 34ab421a4cf0bd262eae19e95bfe014de1e7eaa39c1661e5a6a2afc612996e357a1fd1d7be2b0f0ac68e85700adca1974e46aecde4fda4ac5e72c1e83e2e43df
@@ -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
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Blacklight::Gallery
2
- [![Gem Version](https://badge.fury.io/rb/blacklight-gallery.svg)](http://badge.fury.io/rb/blacklight-gallery)
2
+ [![Gem Version](https://badge.fury.io/rb/blacklight-gallery.svg)](http://badge.fury.io/rb/blacklight-gallery) [![Build Status](https://travis-ci.org/projectblacklight/blacklight-gallery.svg?branch=master)](https://travis-ci.org/projectblacklight/blacklight-gallery)
3
3
 
4
4
  Gallery views for Blacklight search results
5
5
 
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 14H9V8h2v8zm4 0h-2V8h2v8z"></path></svg
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 14.5v-9l6 4.5-6 4.5z"></path></svg>
@@ -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
@@ -72,16 +72,19 @@
72
72
  var $img = this.$element.find('.frame img'),
73
73
  _this = this;
74
74
 
75
- // pause slideshow on image mouseenter event
76
- $img.on('mouseenter', function() { _this.pause(); });
75
+ $(document).on('click', '[data-behavior="pause-slideshow"]', function(e) {
76
+ e.preventDefault();
77
77
 
78
- // play slideshow on image mouseleave event
79
- $img.on('mouseleave', function() {
80
- if (_this.options.autoPlay) _this.play();
78
+ _this.pause();
81
79
  });
82
80
 
83
- $(document).on('click', '[data-slide], [data-slide-to]', function(e) {
81
+ $(document).on('click', '[data-behavior="start-slideshow"]', function(e) {
82
+ e.preventDefault();
84
83
 
84
+ _this.play();
85
+ });
86
+
87
+ $(document).on('click', '[data-slide], [data-slide-to]', function(e) {
85
88
  e.preventDefault();
86
89
 
87
90
  pos = parseInt($(this).attr('data-slide-to'), 10) || $(this).attr('data-slide');
@@ -99,7 +102,7 @@
99
102
 
100
103
 
101
104
  Slideshow.DEFAULTS = {
102
- autoPlay: true,
105
+ autoPlay: false,
103
106
  interval: 5000 // in milliseconds
104
107
  }
105
108
 
@@ -118,5 +121,5 @@
118
121
 
119
122
 
120
123
  Blacklight.onLoad(function() {
121
- $('#slideshow').slideshow();
124
+ $('.documents-slideshow').slideshow();
122
125
  });
@@ -1,21 +1,7 @@
1
- .gallery {
2
-
3
- display: -webkit-box;
4
- display: -moz-box;
5
- display: -ms-flexbox;
6
- display: -webkit-flex;
7
- display: flex;
8
- flex-flow: row wrap;
9
- -webkit-flex-wrap: wrap;
10
-
11
-
1
+ .documents-gallery {
12
2
  .document {
13
3
  border-bottom: none;
14
-
15
- -webkit-box-flex: 1;
16
- -moz-box-flex: 1;
17
- -ms-flex: 1;
18
- flex: 1;
4
+ display: flex;
19
5
 
20
6
  min-height: 250px;
21
7
  -webkit-flex: 1 0 250px;
@@ -39,12 +25,20 @@
39
25
 
40
26
  .document-metadata {
41
27
  dt, dd {
28
+ flex: 0 0 100%;
29
+ max-width: 100%;
30
+ padding-left: 0;
31
+ padding-right: 0;
42
32
  float: none;
43
33
  width: auto;
44
34
  clear: none;
45
35
  text-align: left;
46
36
  margin: 0;
47
37
  }
48
-
49
38
  }
50
39
  }
40
+
41
+ .documents-gallery, .documents-masonry, .documents-slideshow {
42
+ padding-bottom: $spacer;
43
+ border-bottom: $pagination-border-width solid $pagination-border-color
44
+ }
@@ -1,35 +1,66 @@
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
+ &:hover, &:focus {
4
+ .caption-area {
5
+ display: block;
6
+ }
7
+ }
8
8
 
9
- .img-thumbnail {
10
- border-radius: 0;
11
- padding: 0;
9
+ margin-bottom: $spacer;
10
+ position: relative;
11
+ width: auto;
12
+
13
+ .thumbnail-container {
14
+ position: relative;
15
+ min-height: 200px;
16
+ min-width: 200px;
12
17
  }
13
18
 
14
- .caption {
15
- &:first-child { display: block; } // To display captions when there is no image
16
- a {
17
- color: $gray-300;
19
+ .caption-area {
20
+ // styling for documents without thumbnails
21
+ &:first-child {
22
+ display: block;
23
+ max-height: 100%;
24
+ background-color: rgba(0,0,0,0.7) !important;
18
25
  }
19
- line-height: 17px;
20
- background-color: rgba(0,0,0,0.3);
21
- text-align: center;
26
+ @extend .bg-dark;
27
+ @extend .text-white;
28
+ display: none;
29
+ padding: 5px 7px;
30
+ background-color: rgba(0,0,0,0.5) !important;
22
31
  position: absolute;
23
32
  bottom: 0;
24
- right: 0;
25
- left: 0;
26
- width: 100%;
27
- padding: 5px 7px;
33
+ overflow-x: hidden;
34
+ overflow-y: scroll;
35
+ max-height: 75%;
36
+ }
37
+
38
+ .document-counter {
28
39
  display: none;
29
40
  }
30
- &:hover {
31
- .caption {
32
- display: block;
41
+
42
+ .index_title {
43
+ @extend .h6;
44
+ a, a:hover, a:visited, a:active {
45
+ @extend .stretched-link;
46
+ color: $gray-300
47
+ }
48
+ }
49
+
50
+ .document-metadata {
51
+ dt {
52
+ color: $gray-300;
53
+ }
54
+ dt, dd {
55
+ flex: 0 0 100%;
56
+ max-width: 100%;
57
+ padding-left: 0;
58
+ padding-right: 0;
59
+ float: none;
60
+ width: auto;
61
+ clear: none;
62
+ text-align: left;
63
+ margin: 0;
33
64
  }
34
65
  }
35
66
  }
@@ -1,4 +1,4 @@
1
- #document {
1
+ .openseadragon-container {
2
2
 
3
3
  .osd-toolbar {
4
4
  padding: 5px 0;
@@ -26,4 +26,4 @@
26
26
  height: 400px;
27
27
 
28
28
  }
29
- }
29
+ }
@@ -93,9 +93,15 @@ $gray-dark: #343a40 !default;
93
93
  padding: 4px 10px;
94
94
  text-align: center;
95
95
  }
96
+
97
+ .controls {
98
+ svg {
99
+ fill: $gray-light;
100
+ }
101
+ }
96
102
  }
97
103
 
98
- .slideshow-documents {
104
+ .documents-slideshow {
99
105
  margin: 0;
100
106
 
101
107
  .info {
@@ -114,10 +120,12 @@ $gray-dark: #343a40 !default;
114
120
  }
115
121
 
116
122
  .grid {
123
+ display: flex;
124
+ flex-wrap: wrap;
117
125
  $square-thumb-size: 100px;
118
126
 
119
127
  .document {
120
- float: left;
128
+ display: flex;
121
129
  margin-right: 20px;
122
130
  margin-top: 0;
123
131
  padding-top: 0;
@@ -134,7 +142,7 @@ $gray-dark: #343a40 !default;
134
142
  position: relative;
135
143
  width: $square-thumb-size;
136
144
 
137
- a > img {
145
+ img {
138
146
  height: $square-thumb-size;
139
147
  max-height: none;
140
148
  max-width: none;
@@ -0,0 +1,20 @@
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
+ <%= thumbnail %>
5
+
6
+ <div class="caption-area">
7
+ <div class="caption container">
8
+ <header class="documentHeader row">
9
+ <%= content_tag @title_component, class: 'index_title document-title-heading' do %>
10
+ <%= before_title %><%= title %><%= after_title %>
11
+ <% end %>
12
+ <%= actions %>
13
+ </header>
14
+ <%= content %>
15
+ <%= metadata %>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ <% end %>
20
+ <% 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