blacklight-spotlight 3.0.1 → 3.2.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spotlight/admin/blocks/block.js +4 -0
  3. data/app/controllers/spotlight/pages_controller.rb +1 -5
  4. data/app/helpers/spotlight/job_trackers_helper.rb +1 -1
  5. data/app/jobs/spotlight/process_bulk_updates_csv_job.rb +1 -1
  6. data/app/jobs/spotlight/reindex_exhibit_job.rb +9 -1
  7. data/app/models/sir_trevor_rails/blocks/browse_block.rb +1 -1
  8. data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +3 -3
  9. data/app/models/spotlight/page.rb +8 -0
  10. data/app/models/spotlight/search.rb +3 -1
  11. data/app/views/layouts/spotlight/base.html.erb +5 -2
  12. data/app/views/shared/_body_preamble.html.erb +0 -0
  13. data/app/views/shared/_footer.html.erb +0 -1
  14. data/app/views/shared/_masthead.html.erb +1 -1
  15. data/app/views/shared/_user_util_links.html.erb +8 -2
  16. data/app/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb +1 -1
  17. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -0
  18. data/config/locales/spotlight.en.yml +1 -1
  19. data/lib/generators/spotlight/install_generator.rb +16 -7
  20. data/lib/spotlight/version.rb +1 -1
  21. data/lib/tasks/spotlight_tasks.rake +4 -1
  22. data/spec/examples.txt +1497 -1493
  23. data/spec/factories/bulk_updates.rb +6 -0
  24. data/spec/features/javascript/blocks/search_result_block_spec.rb +1 -1
  25. data/spec/features/report_a_problem_spec.rb +1 -0
  26. data/spec/fixtures/iiif_responses.rb +81 -81
  27. data/spec/fixtures/updated-bulk-update-template-no-cols.csv +4 -0
  28. data/spec/jobs/spotlight/process_bulk_updates_csv_job_spec.rb +8 -0
  29. data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +19 -1
  30. data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -2
  31. data/spec/models/spotlight/page_configurations_spec.rb +2 -2
  32. data/spec/test_app_templates/catalog_controller.rb +0 -1
  33. data/spec/views/spotlight/pages/show.html.erb_spec.rb +17 -6
  34. metadata +5 -4
  35. data/spec/views/shared/_footer.html.erb_spec.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa6373c3275db7c952f719176557baa81d7f21818746c68abe7b8d1bfbbdb0c7
4
- data.tar.gz: 789394e88efa3b2db41013c109902e552436ae9303aaaab70e3a81c846b7ea25
3
+ metadata.gz: 56b89965ba03cecc57a91706bab8ab9d93033988608116063650459bebd4182c
4
+ data.tar.gz: 9600146cf5c35a2d763c144d936ffd7e5bfc27a0f519e356dfba500696cbb8f1
5
5
  SHA512:
6
- metadata.gz: dcd66ee6d299ec878775b8377adbc6a724de13f39ecafe8f3250f96b8accacbd77d64883e70a1503827838098450cb1036d33aee17ed2563227fd85486306e55
7
- data.tar.gz: '04726186bf0f0c89c2a4d22b0bb7bca1b82ad04c662522565b3eceacacd0d44d71b2313280922b9ea7d23ef51f75f5d18ab830052e8d8d40abb6dd96d925d71f'
6
+ metadata.gz: 40df9ad1c5506195ee5601834532b10e0551e362ad546e6594e88e1f4f00bd59b23b58b788b2c0541de8f907d1cfee87ef5d37131a75a208fa0e903817061a2b
7
+ data.tar.gz: 8cb8bc71aa03bd906b2bdea4c51b0783d5c7be866ce0dd6ac25ac34f54c65ae106f271bd84762061c10adb795082c5cc0f358d51fcff24b947e1060b7704707d
@@ -1,5 +1,9 @@
1
1
  (function ($){
2
2
  Spotlight.Block = SirTrevor.Block.extend({
3
+ scribeOptions: {
4
+ allowBlockElements: true,
5
+ tags: { p: true }
6
+ },
3
7
  formable: true,
4
8
  editorHTML: function() {
5
9
  return _.template(this.template)(this);
@@ -3,9 +3,6 @@
3
3
  module Spotlight
4
4
  ##
5
5
  # Base CRUD controller for pages
6
- # rubocop:disable Metrics/ClassLength
7
- # Disableing class length because this is a base
8
- # controller that gives other controllers their behavior
9
6
  class PagesController < Spotlight::ApplicationController
10
7
  before_action :authenticate_user!, except: [:show]
11
8
  before_action :load_locale_specific_page, only: %i[destroy edit show update]
@@ -32,7 +29,7 @@ module Spotlight
32
29
 
33
30
  respond_to do |format|
34
31
  format.html
35
- format.json { render json: @pages.for_locale.published.to_json(methods: [:thumbnail_image_url]) }
32
+ format.json { render json: @pages.for_default_locale.published.to_json(methods: [:thumbnail_image_url]) }
36
33
  end
37
34
  end
38
35
 
@@ -208,5 +205,4 @@ module Spotlight
208
205
  end
209
206
  end
210
207
  end
211
- # rubocop:enable Metrics/ClassLength
212
208
  end
@@ -4,7 +4,7 @@ module Spotlight
4
4
  # HTML <meta> tag helpers
5
5
  module JobTrackersHelper
6
6
  def job_status_icon(job_tracker)
7
- content_tag :span, title: t(job_tracker.status || 'missing', scope: 'spotlight.job_trackers.status') do # rubocop:disable Rails/ContentTag
7
+ content_tag :span, title: t(job_tracker.status || 'missing', scope: 'spotlight.job_trackers.status') do
8
8
  if job_tracker.enqueued? || job_tracker.in_progress?
9
9
  '⏱'
10
10
  elsif job_tracker.completed?
@@ -43,7 +43,7 @@ module Spotlight
43
43
  needs_reindex = false
44
44
 
45
45
  begin
46
- if sidecar.public != to_bool(row[config.csv_visibility])
46
+ if row.headers.include?(config.csv_visibility) && sidecar.public != to_bool(row[config.csv_visibility])
47
47
  sidecar.update(public: to_bool(row[config.csv_visibility]))
48
48
  needs_reindex = true
49
49
  end
@@ -14,7 +14,7 @@ module Spotlight
14
14
 
15
15
  # Use the provided batch size, or calculate a reasonable default
16
16
  batch_count = (count.to_f / batch_size).ceil if batch_size
17
- batch_count ||= 1 + Math.log(count).round # e.g. 10 => 3, 100 => 6, 1000 => 8
17
+ batch_count ||= batch_count_based_on_number_of_resources(count)
18
18
 
19
19
  return Spotlight::ReindexJob.perform_now(exhibit, reports_on: job_tracker) if batch_count == 1
20
20
 
@@ -26,6 +26,8 @@ module Spotlight
26
26
  job_tracker.update(status: 'pending')
27
27
  end
28
28
 
29
+ private
30
+
29
31
  def perform_later_in_batches(exhibit, of:)
30
32
  last = 0
31
33
  exhibit.resources.select(:id).in_batches(of: of) do |batch|
@@ -35,5 +37,11 @@ module Spotlight
35
37
 
36
38
  Spotlight::ReindexJob.perform_later(exhibit, reports_on: job_tracker, start: last)
37
39
  end
40
+
41
+ def batch_count_based_on_number_of_resources(count)
42
+ return 1 if count.zero?
43
+
44
+ 1 + Math.log(count).round # e.g. 10 => 3, 100 => 6, 1000 => 8
45
+ end
38
46
  end
39
47
  end
@@ -31,7 +31,7 @@ module SirTrevorRails
31
31
  send(:'display-item-counts') == 'true'
32
32
  end
33
33
 
34
- def as_json
34
+ def as_json(*)
35
35
  result = super
36
36
 
37
37
  result[:data][:item] ||= {}
@@ -12,7 +12,7 @@ module SirTrevorRails
12
12
  end
13
13
 
14
14
  def pages
15
- @pages ||= parent.exhibit.pages.published.where(slug: item_ids).sort do |a, b|
15
+ @pages ||= parent.exhibit.pages.for_default_locale.published.where(slug: item_ids).sort do |a, b|
16
16
  ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
17
17
  end
18
18
  end
@@ -22,13 +22,13 @@ module SirTrevorRails
22
22
  end
23
23
 
24
24
  # rubocop:disable Metrics/MethodLength
25
- def as_json
25
+ def as_json(*)
26
26
  result = super
27
27
  result[:data][:item] ||= {}
28
28
 
29
29
  result[:data][:item].transform_values! do |v|
30
30
  begin
31
- v['thumbnail_image_url'] = parent.exhibit.pages.find(v['id']).thumbnail_image_url
31
+ v['thumbnail_image_url'] = parent.exhibit.pages.for_default_locale.find(v['id']).thumbnail_image_url
32
32
  rescue ActiveRecord::RecordNotFound
33
33
  v = nil
34
34
  end
@@ -46,6 +46,12 @@ module Spotlight
46
46
 
47
47
  after_update :update_translated_pages_weights_and_parent_page
48
48
 
49
+ def title
50
+ return super if I18n.locale == I18n.default_locale
51
+
52
+ translated_page_for(I18n.locale)&.title || super
53
+ end
54
+
49
55
  def content_changed!
50
56
  @content = nil
51
57
  end
@@ -133,6 +139,8 @@ module Spotlight
133
139
  end
134
140
 
135
141
  def translated_page_for(locale)
142
+ return self if locale == self.locale
143
+
136
144
  translated_pages.for_locale(locale).first
137
145
  end
138
146
 
@@ -55,7 +55,9 @@ module Spotlight
55
55
  end
56
56
 
57
57
  def count
58
- documents.size
58
+ @count ||= Rails.cache.fetch([exhibit, self, 'count']) do
59
+ documents.size
60
+ end
59
61
  end
60
62
 
61
63
  delegate :blacklight_config, to: :exhibit
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
-
7
+ <%= render partial: 'shared/analytics' %>
8
8
  <title><%= h(@page_title || application_name.to_s) %></title>
9
9
  <link href="<%= current_exhibit ? spotlight.opensearch_exhibit_catalog_url(current_exhibit, format: 'xml') : main_app.opensearch_catalog_url(format: 'xml') %>" title="<%= h(@page_title || application_name.to_str) %>" type="application/opensearchdescription+xml" rel="search"/>
10
10
  <%= favicon_link_tag 'favicon.ico' %>
@@ -22,8 +22,11 @@
22
22
  <%= javascript_tag '$.fx.off = true;' if Rails.env.test? %>
23
23
  </head>
24
24
  <body class="<%= render_body_class %>">
25
+ <%= render partial: 'shared/body_preamble' %>
25
26
  <div id="skip-link">
26
- <%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
27
+ <% if should_render_spotlight_search_bar? %>
28
+ <%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
29
+ <% end %>
27
30
  <%= link_to t('blacklight.skip_links.main_content'), '#main-container', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
28
31
  <%= content_for(:skip_links) %>
29
32
  </div>
File without changes
@@ -1 +0,0 @@
1
- <%= render 'shared/analytics' %>
@@ -1,4 +1,4 @@
1
- <% if show_contact_form? %>
1
+ <% if show_contact_form? && (current_exhibit.nil? || !current_page?(spotlight.new_exhibit_contact_form_path(current_exhibit))) %>
2
2
  <div id="report-problem-form">
3
3
  <%= render 'spotlight/shared/report_a_problem' %>
4
4
  </div>
@@ -1,8 +1,14 @@
1
- <ul class="navbar-nav mr-auto">
1
+ <% nav_actions = capture do %>
2
2
  <%= render_nav_actions do |config, action|%>
3
3
  <li class="nav-item"><%= action %></li>
4
4
  <% end %>
5
- </ul>
5
+ <% end %>
6
+
7
+ <% if nav_actions.present? %>
8
+ <ul class="navbar-nav mr-auto">
9
+ <%= nav_actions %>
10
+ </ul>
11
+ <% end %>
6
12
 
7
13
  <ul class="navbar-nav">
8
14
  <%= render '/spotlight/shared/locale_picker' %>
@@ -1 +1 @@
1
- <%= sanitize iframe_block.code, tags: %w(iframe), attributes: %w(id width height marginwidth marginheight src frameborder allowfullscreen sandbox seamless srcdoc scrolling) %>
1
+ <%= sanitize iframe_block.code, tags: %w(iframe), attributes: %w(id aria-label title width height marginwidth marginheight src frameborder allowfullscreen sandbox seamless srcdoc scrolling) %>
@@ -17,6 +17,7 @@
17
17
  </div>
18
18
  <% end %>
19
19
 
20
+ <h2 class="sr-only visually-hidden"><%= t('blacklight.search.search_results') %></h2>
20
21
  <%= render_document_index_with_view(block_document_index_view_type(search_results_block), document_list) %>
21
22
  <%= render 'results_pagination' %>
22
23
  <%- end %>
@@ -50,7 +50,7 @@ en:
50
50
  destroy: Delete group
51
51
  spotlight/role:
52
52
  create: Add a new user
53
- destroy: Remove from site
53
+ destroy: Remove from exhibit
54
54
  spotlight/search:
55
55
  destroy: Delete
56
56
  edit_long: Edit this saved search
@@ -39,8 +39,7 @@ module Spotlight
39
39
 
40
40
  def friendly_id
41
41
  gem 'friendly_id'
42
- # we need to immediately run `bundle install` while pointing at github.
43
- Bundler.with_clean_env { run 'bundle install' }
42
+ bundle_install
44
43
  generate 'friendly_id'
45
44
  end
46
45
 
@@ -56,7 +55,7 @@ module Spotlight
56
55
  def sitemaps
57
56
  gem 'sitemap_generator'
58
57
 
59
- Bundler.with_clean_env { run 'bundle install' }
58
+ bundle_install
60
59
 
61
60
  copy_file 'config/sitemap.rb', 'config/sitemap.rb'
62
61
 
@@ -91,7 +90,7 @@ module Spotlight
91
90
  end
92
91
 
93
92
  def add_model_mixin
94
- if File.exist? 'app/models/solr_document.rb'
93
+ if File.exist? File.expand_path('app/models/solr_document.rb', destination_root)
95
94
  inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do
96
95
  "\n include Spotlight::SolrDocument\n"
97
96
  end
@@ -101,7 +100,7 @@ module Spotlight
101
100
  end
102
101
 
103
102
  def add_solr_indexing_mixin
104
- if File.exist? 'app/models/solr_document.rb'
103
+ if File.exist? File.expand_path('app/models/solr_document.rb', destination_root)
105
104
  inject_into_file 'app/models/solr_document.rb', after: "include Spotlight::SolrDocument\n" do
106
105
  "\n include #{options[:solr_update_class]}\n"
107
106
  end
@@ -111,7 +110,7 @@ module Spotlight
111
110
  end
112
111
 
113
112
  def add_search_builder_mixin
114
- if File.exist? 'app/models/search_builder.rb'
113
+ if File.exist? File.expand_path('app/models/search_builder.rb', destination_root)
115
114
  inject_into_file 'app/models/search_builder.rb', after: "include Blacklight::Solr::SearchBuilderBehavior\n" do
116
115
  "\n include Spotlight::SearchBuilder\n"
117
116
  end
@@ -126,12 +125,13 @@ module Spotlight
126
125
 
127
126
  def add_osd_viewer
128
127
  gem 'blacklight-gallery', '~> 3.0'
128
+ bundle_install
129
129
  generate 'blacklight_gallery:install'
130
130
  end
131
131
 
132
132
  def add_oembed
133
133
  gem 'blacklight-oembed', '~> 1.0'
134
- Bundler.with_clean_env { run 'bundle install' }
134
+ bundle_install
135
135
  generate 'blacklight_oembed:install'
136
136
  copy_file 'config/initializers/oembed.rb'
137
137
  end
@@ -160,6 +160,7 @@ module Spotlight
160
160
 
161
161
  def generate_devise_invitable
162
162
  gem 'devise_invitable'
163
+ bundle_install
163
164
  generate 'devise_invitable:install'
164
165
  generate 'devise_invitable', 'User'
165
166
  end
@@ -167,5 +168,13 @@ module Spotlight
167
168
  def add_translations
168
169
  copy_file 'config/initializers/translation.rb'
169
170
  end
171
+
172
+ private
173
+
174
+ def bundle_install
175
+ inside destination_root do
176
+ Bundler.with_clean_env { run 'bundle install' }
177
+ end
178
+ end
170
179
  end
171
180
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spotlight
4
- VERSION = '3.0.1'
4
+ VERSION = '3.2.0'
5
5
  end
@@ -21,7 +21,10 @@ namespace :spotlight do
21
21
  print 'Exhibit title: '
22
22
  title = $stdin.gets.chomp
23
23
 
24
- exhibit = Spotlight::Exhibit.create!(title: title)
24
+ print 'Exhibit URL slug: '
25
+ slug = @stdin.gets.chomp
26
+
27
+ exhibit = Spotlight::Exhibit.create!({ title: title, slug: slug })
25
28
 
26
29
  puts 'Who can admin this exhibit?'
27
30