blacklight-spotlight 3.0.0.rc6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/spotlight/featured_image.rb +33 -0
- data/app/views/spotlight/about_pages/_sidebar.html.erb +2 -2
- data/app/views/spotlight/browse/_search.html.erb +3 -3
- data/app/views/spotlight/browse/_search_title.html.erb +1 -1
- data/app/views/spotlight/feature_pages/_sidebar.html.erb +1 -1
- data/app/views/spotlight/pages/show.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -1
- data/db/migrate/20210506070809_add_indexes_for_featured_images.rb +9 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/examples.txt +12 -11
- data/spec/models/spotlight/featured_image_spec.rb +12 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 744fbdb9eab230da1278b056d9e86e5474e42641e7392cc2d3e0f1a45c9639bb
|
4
|
+
data.tar.gz: 99b069606c5854c4f7361a14d05f7ac4716bf61250e1d1c215094754474a6088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 190fb6c64ce2200ad5123f94fc10f6c9490053eb2b4229cdbf96fd4b82897b2b3a8b1977a597f49f7a6b58a0b84ef3eff2e5157210f4d9f3f0731f368259e089
|
7
|
+
data.tar.gz: 4cd54b3fbd339222e04dab49f1c7c3072901034f38fe86202759a601ec8f80a122546a6a1feb21f53c5246e07527b6df87c8656396752cb71c2ca68b524b923d
|
@@ -31,6 +31,8 @@ module Spotlight
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
after_save :bust_containing_resource_caches
|
35
|
+
|
34
36
|
attr_accessor :upload_id
|
35
37
|
|
36
38
|
def iiif_url
|
@@ -87,5 +89,36 @@ module Spotlight
|
|
87
89
|
def iiif_service_base
|
88
90
|
iiif_tilesource&.sub('/info.json', '')
|
89
91
|
end
|
92
|
+
|
93
|
+
# This is an unfortunate work-around because:
|
94
|
+
# - when this instance is updated through accepts_nested_attributes_for on a parent model,
|
95
|
+
# the parent model is not necessarily updated (to bust caches, etc)
|
96
|
+
# - this model doesn't have an association back to where it is being used
|
97
|
+
# - these images can be used by multiple model instances (e.g. various translations of a feature page)
|
98
|
+
# - this model is used by different types of models (polymorphic use), so belongs_to/has_many doesn't help
|
99
|
+
# - potentially a problem with https://github.com/rails/rails/issues/26726
|
100
|
+
#
|
101
|
+
# Ideally, we might create a join table to connect this model to where it is used, but 🤷♂️
|
102
|
+
# Instead, we check each place this might be used and touch it
|
103
|
+
def bust_containing_resource_caches
|
104
|
+
if Rails.version > '6'
|
105
|
+
Spotlight::Search.where(thumbnail: self).or(Spotlight::Search.where(masthead: self)).touch_all
|
106
|
+
Spotlight::Page.where(thumbnail: self).touch_all
|
107
|
+
Spotlight::Exhibit.where(thumbnail: self).or(Spotlight::Exhibit.where(masthead: self)).touch_all
|
108
|
+
Spotlight::Contact.where(avatar: self).touch_all
|
109
|
+
Spotlight::Resources::Upload.where(upload: self).touch_all
|
110
|
+
else
|
111
|
+
bust_containing_resource_caches_rails5
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Rails 5 doesn't support touch_all.
|
116
|
+
def bust_containing_resource_caches_rails5
|
117
|
+
Spotlight::Search.where(thumbnail: self).or(Spotlight::Search.where(masthead: self)).find_each(&:touch)
|
118
|
+
Spotlight::Page.where(thumbnail: self).find_each(&:touch)
|
119
|
+
Spotlight::Exhibit.where(thumbnail: self).or(Spotlight::Exhibit.where(masthead: self)).find_each(&:touch)
|
120
|
+
Spotlight::Contact.where(avatar: self).find_each(&:touch)
|
121
|
+
Spotlight::Resources::Upload.where(upload: self).find_each(&:touch)
|
122
|
+
end
|
90
123
|
end
|
91
124
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% cache_unless current_user, [current_exhibit, @page] do %>
|
1
|
+
<% cache_unless current_user, [current_exhibit, @page, I18n.locale] do %>
|
2
2
|
<h2 class="nav-heading h4"><%= current_exhibit.main_navigations.about.label_or_default %></h2>
|
3
3
|
<ul class="nav sidenav flex-column">
|
4
4
|
<% current_exhibit.about_pages.for_locale.published.each do |page| %>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
</li>
|
8
8
|
<% end %>
|
9
9
|
</ul>
|
10
|
-
<%= cache current_exhibit do %>
|
10
|
+
<%= cache [current_exhibit, I18n.locale] do %>
|
11
11
|
<%= render 'contacts' if current_exhibit.contacts.published.present? %>
|
12
12
|
<% end %>
|
13
13
|
<% end %>
|
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% group ||= @group %>
|
2
|
+
<%= cache [@exhibit, group || '', search, I18n.locale] do %>
|
3
3
|
<div class="col-md-4 col-12 category">
|
4
4
|
<%= link_to group.present? ? spotlight.exhibit_browse_group_path(@exhibit, group, search) : spotlight.exhibit_browse_path(@exhibit, search) do %>
|
5
5
|
<div class="image-overlay">
|
6
6
|
<%= image_tag(search.thumbnail_image_url || 'spotlight/default_browse_thumbnail.jpg', class: 'img-responsive', alt: '') %>
|
7
7
|
<div class="text-overlay">
|
8
8
|
<h2 class="browse-category-title">
|
9
|
-
<span class="title"><%= search.title%></span>
|
9
|
+
<span class="title"><%= search.title %></span>
|
10
10
|
<% if search.subtitle.present? %><span class="category-subtitle"><%= search.subtitle %></span><% end %>
|
11
11
|
<small class="item-count"><%= t :'spotlight.browse.search.item_count', count: search.count %></small>
|
12
12
|
</h2>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<span class="title"><%= search.title %></span>
|
2
2
|
<% if search.subtitle.present? %><span class="subtitle"><%= search.subtitle %></span><% end %>
|
3
|
-
<small class="item-count"><%= t :'spotlight.browse.search.item_count', count:
|
3
|
+
<small class="item-count"><%= t :'spotlight.browse.search.item_count', count: search.count %></small>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% cache_unless current_user, [current_exhibit, @page] do %>
|
1
|
+
<% cache_unless current_user, [current_exhibit, @page, I18n.locale] do %>
|
2
2
|
<ol class="nav sidenav flex-column">
|
3
3
|
<% @exhibit.feature_pages.for_locale.published.at_top_level.each do |feature_section| %>
|
4
4
|
<li class="<%= 'active' if current_page? [spotlight, @exhibit, feature_section] %>">
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<%= render 'sidebar' %>
|
6
6
|
<% end if @page.display_sidebar?%>
|
7
7
|
|
8
|
-
<%= cache_unless current_user, [@page, request.query_string] do %>
|
8
|
+
<%= cache_unless current_user, [current_exhibit, @page, I18n.locale, request.query_string] do %>
|
9
9
|
<div class="clearfix">
|
10
10
|
<%= render 'edit_page_link' if can? :edit, @page %>
|
11
11
|
<% if @page.should_display_title? %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
<% views = blacklight_view_config_for_search_block(search_results_block) %>
|
12
12
|
<% if views.length > 1 -%>
|
13
|
-
<div id="sortAndPerPage" class="clearfix" role="navigation" aria-label="<%= t('blacklight.search.per_page.aria_label', default: 'Results navigation')%>">
|
13
|
+
<div id="sortAndPerPage" class="clearfix my-3" role="navigation" aria-label="<%= t('blacklight.search.per_page.aria_label', default: 'Results navigation')%>">
|
14
14
|
<div class="search-widgets float-right">
|
15
15
|
<%= render partial: 'view_type_group', locals: { block: search_results_block } %>
|
16
16
|
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddIndexesForFeaturedImages < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
add_index(:spotlight_searches, [:thumbnail_id])
|
4
|
+
add_index(:spotlight_searches, [:masthead_id])
|
5
|
+
add_index(:spotlight_exhibits, [:thumbnail_id])
|
6
|
+
add_index(:spotlight_exhibits, [:masthead_id])
|
7
|
+
add_index(:spotlight_pages, [:thumbnail_id])
|
8
|
+
end
|
9
|
+
end
|
data/lib/spotlight/version.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -319,12 +319,12 @@ example_id
|
|
319
319
|
./spec/features/add_iiif_manifest_spec.rb[1:2] | passed | 0.44223 seconds |
|
320
320
|
./spec/features/add_iiif_manifest_spec.rb[1:3] | passed | 0.35011 seconds |
|
321
321
|
./spec/features/add_items_spec.rb[1:1:1] | passed | 0.11038 seconds |
|
322
|
-
./spec/features/add_items_spec.rb[1:1:2] | passed |
|
322
|
+
./spec/features/add_items_spec.rb[1:1:2] | passed | 7.21 seconds |
|
323
323
|
./spec/features/add_items_spec.rb[1:1:3] | passed | 0.30893 seconds |
|
324
324
|
./spec/features/add_items_spec.rb[1:1:4] | passed | 0.10614 seconds |
|
325
325
|
./spec/features/add_items_spec.rb[1:1:5] | passed | 0.1024 seconds |
|
326
326
|
./spec/features/add_items_spec.rb[1:1:6:1] | passed | 0.12445 seconds |
|
327
|
-
./spec/features/add_items_spec.rb[1:2:1] |
|
327
|
+
./spec/features/add_items_spec.rb[1:2:1] | failed | 9.47 seconds |
|
328
328
|
./spec/features/autocomplete_typeahead_spec.rb[1:1:1:1] | passed | 1.51 seconds |
|
329
329
|
./spec/features/autocomplete_typeahead_spec.rb[1:1:1:2] | passed | 2.28 seconds |
|
330
330
|
./spec/features/autocomplete_typeahead_spec.rb[1:1:1:3] | passed | 1.48 seconds |
|
@@ -1002,17 +1002,18 @@ example_id
|
|
1002
1002
|
./spec/models/spotlight/feature_page_spec.rb[1:6:1] | passed | 0.05814 seconds |
|
1003
1003
|
./spec/models/spotlight/feature_page_spec.rb[1:6:2] | passed | 0.06073 seconds |
|
1004
1004
|
./spec/models/spotlight/feature_page_spec.rb[1:6:3] | passed | 0.0646 seconds |
|
1005
|
-
./spec/models/spotlight/featured_image_spec.rb[1:1:1] | passed | 0.
|
1006
|
-
./spec/models/spotlight/featured_image_spec.rb[1:2:1
|
1007
|
-
./spec/models/spotlight/featured_image_spec.rb[1:
|
1008
|
-
./spec/models/spotlight/featured_image_spec.rb[1:
|
1009
|
-
./spec/models/spotlight/featured_image_spec.rb[1:
|
1010
|
-
./spec/models/spotlight/featured_image_spec.rb[1:
|
1011
|
-
./spec/models/spotlight/featured_image_spec.rb[1:3:
|
1012
|
-
./spec/models/spotlight/featured_image_spec.rb[1:3:2] | passed | 0.00639 seconds |
|
1013
|
-
./spec/models/spotlight/featured_image_spec.rb[1:3:3] | passed | 0.00339 seconds |
|
1005
|
+
./spec/models/spotlight/featured_image_spec.rb[1:1:1] | passed | 0.79698 seconds |
|
1006
|
+
./spec/models/spotlight/featured_image_spec.rb[1:2:1] | unknown | |
|
1007
|
+
./spec/models/spotlight/featured_image_spec.rb[1:3:1:1] | unknown | |
|
1008
|
+
./spec/models/spotlight/featured_image_spec.rb[1:3:1:2] | unknown | |
|
1009
|
+
./spec/models/spotlight/featured_image_spec.rb[1:3:1:3:1] | unknown | |
|
1010
|
+
./spec/models/spotlight/featured_image_spec.rb[1:3:2:1] | unknown | |
|
1011
|
+
./spec/models/spotlight/featured_image_spec.rb[1:3:2:2] | unknown | |
|
1014
1012
|
./spec/models/spotlight/featured_image_spec.rb[1:4:1] | passed | 0.00095 seconds |
|
1015
1013
|
./spec/models/spotlight/featured_image_spec.rb[1:4:2] | passed | 0.00084 seconds |
|
1014
|
+
./spec/models/spotlight/featured_image_spec.rb[1:4:3] | unknown | |
|
1015
|
+
./spec/models/spotlight/featured_image_spec.rb[1:5:1] | unknown | |
|
1016
|
+
./spec/models/spotlight/featured_image_spec.rb[1:5:2] | unknown | |
|
1016
1017
|
./spec/models/spotlight/field_metadata_spec.rb[1:1:1] | passed | 0.04225 seconds |
|
1017
1018
|
./spec/models/spotlight/field_metadata_spec.rb[1:1:2] | passed | 0.04504 seconds |
|
1018
1019
|
./spec/models/spotlight/field_metadata_spec.rb[1:1:3:1] | passed | 0.04166 seconds |
|
@@ -5,6 +5,18 @@ describe Spotlight::FeaturedImage do
|
|
5
5
|
|
6
6
|
let(:temp_image) { FactoryBot.create(:temporary_image) }
|
7
7
|
|
8
|
+
describe '#bust_containing_resource_caches' do
|
9
|
+
let!(:feature_page) { FactoryBot.create(:feature_page, thumbnail: temp_image) }
|
10
|
+
let!(:feature_page2) { FactoryBot.create(:feature_page, thumbnail: temp_image) }
|
11
|
+
|
12
|
+
it 'changes the updated_at for all resources that might be using this image' do
|
13
|
+
temp_image.save
|
14
|
+
|
15
|
+
expect(feature_page.updated_at).to be < feature_page.reload.updated_at
|
16
|
+
expect(feature_page2.updated_at).to be < feature_page2.reload.updated_at
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
8
20
|
context 'with an uploaded image' do
|
9
21
|
it 'copies the temporary uploaded image to this model' do
|
10
22
|
featured_image.source = 'remote'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-
|
14
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activejob-status
|
@@ -1458,6 +1458,7 @@ files:
|
|
1458
1458
|
- db/migrate/20210305070001_remove_class_from_sirtrevor_image_blocks.rb
|
1459
1459
|
- db/migrate/20210305171150_create_bulk_updates.rb
|
1460
1460
|
- db/migrate/20210308090000_migrate_caption_values_for_title_key.rb
|
1461
|
+
- db/migrate/20210506070809_add_indexes_for_featured_images.rb
|
1461
1462
|
- lib/blacklight/spotlight.rb
|
1462
1463
|
- lib/generators/spotlight/install_generator.rb
|
1463
1464
|
- lib/generators/spotlight/scaffold_resource_generator.rb
|
@@ -1829,9 +1830,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1829
1830
|
version: '2.6'
|
1830
1831
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1831
1832
|
requirements:
|
1832
|
-
- - "
|
1833
|
+
- - ">="
|
1833
1834
|
- !ruby/object:Gem::Version
|
1834
|
-
version:
|
1835
|
+
version: '0'
|
1835
1836
|
requirements: []
|
1836
1837
|
rubygems_version: 3.2.3
|
1837
1838
|
signing_key:
|