blacklight-spotlight 3.1.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/stylesheets/spotlight/_breadcrumbs.scss +2 -4
  4. data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +2 -2
  5. data/app/controllers/concerns/spotlight/controller.rb +13 -12
  6. data/app/controllers/spotlight/attachments_controller.rb +1 -1
  7. data/app/controllers/spotlight/custom_search_fields_controller.rb +1 -1
  8. data/app/controllers/spotlight/pages_controller.rb +3 -7
  9. data/app/controllers/spotlight/searches_controller.rb +6 -1
  10. data/app/helpers/spotlight/application_helper.rb +1 -1
  11. data/app/helpers/spotlight/job_trackers_helper.rb +1 -1
  12. data/app/helpers/spotlight/main_app_helpers.rb +1 -1
  13. data/app/helpers/spotlight/pages_helper.rb +12 -0
  14. data/app/helpers/spotlight/title_helper.rb +0 -2
  15. data/app/mailers/spotlight/confirmation_mailer.rb +2 -1
  16. data/app/models/sir_trevor_rails/block.rb +85 -0
  17. data/app/models/sir_trevor_rails/blocks/displayable.rb +1 -1
  18. data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +2 -2
  19. data/app/models/spotlight/contact_email.rb +1 -1
  20. data/app/models/spotlight/page.rb +8 -0
  21. data/app/models/spotlight/page_configurations.rb +1 -1
  22. data/app/models/spotlight/page_content/sir_trevor.rb +13 -4
  23. data/app/models/translation.rb +18 -0
  24. data/app/services/spotlight/exhibit_import_export_service.rb +1 -1
  25. data/app/views/layouts/spotlight/base.html.erb +3 -1
  26. data/app/views/shared/_site_sidebar.html.erb +1 -1
  27. data/app/views/spotlight/catalog/admin.html.erb +1 -1
  28. data/app/views/spotlight/confirmation_mailer/confirmation_instructions.html.erb +3 -3
  29. data/app/views/spotlight/exhibits/_import.html.erb +1 -1
  30. data/app/views/spotlight/exhibits/_languages.html.erb +2 -2
  31. data/app/views/spotlight/filters/_form.html.erb +1 -1
  32. data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
  33. data/app/views/spotlight/search_configurations/_document_index_view_types.html.erb +1 -1
  34. data/app/views/spotlight/search_configurations/_facet_metadata.html.erb +4 -2
  35. data/app/views/spotlight/search_configurations/_facets.html.erb +1 -1
  36. data/app/views/spotlight/searches/_form.html.erb +1 -1
  37. data/app/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb +1 -1
  38. data/app/views/spotlight/sir_trevor/blocks/_video_block.html.erb +5 -0
  39. data/app/views/spotlight/translations/_browse_categories.html.erb +1 -1
  40. data/app/views/spotlight/translations/_groups.html.erb +1 -1
  41. data/app/views/spotlight/translations/_import.html.erb +1 -1
  42. data/app/views/spotlight/translations/_metadata.html.erb +1 -1
  43. data/app/views/spotlight/translations/_search_fields.html.erb +1 -1
  44. data/config/i18n-tasks.yml +2 -1
  45. data/config/locales/spotlight.de.yml +40 -0
  46. data/config/locales/spotlight.en.yml +13 -4
  47. data/lib/generators/spotlight/install_generator.rb +40 -2
  48. data/lib/generators/spotlight/templates/config/initializers/translation.rb +15 -13
  49. data/lib/generators/spotlight/templates/solr/config/schema.xml +32 -50
  50. data/lib/generators/spotlight/templates/solr/config/solrconfig.xml +14 -12
  51. data/lib/spotlight/engine.rb +4 -2
  52. data/lib/spotlight/version.rb +1 -1
  53. data/lib/tasks/spotlight_tasks.rake +41 -3
  54. data/spec/controllers/spotlight/about_pages_controller_spec.rb +1 -3
  55. data/spec/controllers/spotlight/catalog_controller_spec.rb +4 -4
  56. data/spec/controllers/spotlight/contact_forms_controller_spec.rb +2 -2
  57. data/spec/controllers/spotlight/contacts_controller_spec.rb +2 -2
  58. data/spec/controllers/spotlight/exhibits_controller_spec.rb +1 -1
  59. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +2 -2
  60. data/spec/controllers/spotlight/featured_images_controller_spec.rb +4 -4
  61. data/spec/controllers/spotlight/groups_controller_spec.rb +1 -1
  62. data/spec/controllers/spotlight/searches_controller_spec.rb +3 -3
  63. data/spec/controllers/spotlight/solr_controller_spec.rb +1 -1
  64. data/spec/controllers/spotlight/tags_controller_spec.rb +1 -1
  65. data/spec/examples.txt +1512 -1501
  66. data/spec/features/autocomplete_typeahead_spec.rb +3 -2
  67. data/spec/features/edit_search_fields_spec.rb +1 -1
  68. data/spec/features/exhibit_themes_spec.rb +3 -1
  69. data/spec/features/javascript/blocks/solr_documents_block_spec.rb +2 -0
  70. data/spec/helpers/spotlight/pages_helper_spec.rb +1 -1
  71. data/spec/i18n_spec.rb +2 -3
  72. data/spec/lib/migration/iiif_spec.rb +2 -2
  73. data/spec/models/sir_trevor_rails/block_spec.rb +72 -0
  74. data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +19 -1
  75. data/spec/models/solr_document_spec.rb +4 -4
  76. data/spec/models/spotlight/browse_category_search_builder_spec.rb +3 -1
  77. data/spec/models/spotlight/page_spec.rb +1 -11
  78. data/spec/models/translation_spec.rb +12 -0
  79. data/spec/services/spotlight/etl/pipeline_spec.rb +1 -1
  80. data/spec/spec_helper.rb +2 -3
  81. data/spec/support/views/test_view_helpers.rb +1 -0
  82. data/spec/test_app_templates/catalog_controller.rb +3 -3
  83. data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -1
  84. data/spec/views/spotlight/pages/show.html.erb_spec.rb +1 -0
  85. data/spec/views/spotlight/search_configurations/_facet_metadata.html.erb_spec.rb +27 -1
  86. data/spec/views/spotlight/tags/index.html.erb_spec.rb +0 -1
  87. metadata +113 -20
  88. data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 470ee8ce65eb987c54dedfe26ea4db9904c9f883df098df123adf369a40636cf
4
- data.tar.gz: fd573fd059d88bd4a35dc7d253a0f01b0c593c5c3f6901fb1c6c50fe6d4e5b28
3
+ metadata.gz: fc89332ff348ea70e49058e10f7ae4ffe6513218603cb2b13741eefdc15c8f24
4
+ data.tar.gz: 76ff697064cedf09069292730e9bc3d7b1beac5a8e80e0ededdebbfc8f0008c5
5
5
  SHA512:
6
- metadata.gz: c8892e30dbb4d6a7ccd1ead2a40e6d78f393bd43750bee2b5b87189976d0111b30ac649e5f30312051e7b94e6deac4b870244e8979a5d2c041a61c4739580538
7
- data.tar.gz: 5da0981d722fd045dbafc9424344eed90a8a88aeae3fdc1ef2579f8828bd41c35957ae2aa80bc980c52852d221bd9ed9948d1ba7d4f41333c0892cc1ddc5aff7
6
+ metadata.gz: 23cb9a0b04c40a53e75a91a25a7d1ce88a54b80fd5200fdee257081ed524bea31f77264d7a1a7f17ec82f5ede0dacf08c05707ddb122af99a0a071faa06824cf
7
+ data.tar.gz: 87dac4804ad58c1c2b08bd1e582dde8f492a68434f193f679a72737ae73bd6a3b2dcf2cded7281e50fd341d07e7a7b369539a0bf5efcfc981b0de5f1b795e59d
data/README.md CHANGED
@@ -9,8 +9,8 @@ Read more about what Spotlight is, our motivations for creating it, and how to i
9
9
 
10
10
  ## Requirements
11
11
 
12
- 1. Ruby (2.5.0 or greater)
13
- 2. Rails (5.1 or greater)
12
+ 1. Ruby (2.7 or greater)
13
+ 2. Rails (5.2 or greater)
14
14
  3. Java (7 or greater) *for Solr*
15
15
  4. ImageMagick (http://www.imagemagick.org/script/index.php) due to [carrierwave](https://github.com/carrierwaveuploader/carrierwave#adding-versions)
16
16
 
@@ -1,8 +1,6 @@
1
- .breadcrumb-item {
2
- .truncated-value {
1
+ .truncated-value {
3
2
  overflow: hidden;
4
3
  text-overflow: ellipsis;
5
4
  white-space: nowrap;
6
- width: 30ex;
7
- }
5
+ max-width: 30ex;
8
6
  }
@@ -25,7 +25,7 @@ module Spotlight
25
25
 
26
26
  html_class = 'active' if current
27
27
 
28
- @context.content_tag(:li, class: "breadcrumb-item #{html_class}") do
28
+ @context.content_tag(:li, class: "breadcrumb-item truncated-value #{html_class}") do
29
29
  @context.link_to_unless(current, element_label(element), compute_path(element), element.options&.except(:current))
30
30
  end
31
31
  end
@@ -33,7 +33,7 @@ module Spotlight
33
33
  private
34
34
 
35
35
  def element_label(element)
36
- @context.content_tag(:span, class: 'truncated-value') { compute_name(element) }
36
+ @context.content_tag(:span) { compute_name(element) }
37
37
  end
38
38
  end
39
39
  end
@@ -67,38 +67,39 @@ module Spotlight
67
67
  end
68
68
  end
69
69
 
70
- def search_action_url(*args)
70
+ def search_action_url(*args, **kwargs)
71
71
  if current_exhibit
72
- exhibit_search_action_url(*args)
72
+ exhibit_search_action_url(*args, **kwargs)
73
73
  else
74
- main_app.search_catalog_url(*args)
74
+ main_app.search_catalog_url(*args, **kwargs)
75
75
  end
76
76
  end
77
77
 
78
- def search_facet_path(*args)
78
+ def search_facet_path(*args, **kwargs)
79
79
  if current_exhibit
80
- exhibit_search_facet_path(*args)
80
+ exhibit_search_facet_path(*args, **kwargs)
81
81
  else
82
- main_app.catalog_facet_url(*args)
82
+ main_app.catalog_facet_url(*args, **kwargs)
83
83
  end
84
84
  end
85
85
 
86
- def exhibit_search_action_url(*args)
86
+ def exhibit_search_action_url(*args, **kwargs)
87
87
  options = args.extract_options!
88
+ options = options.merge(kwargs)
88
89
  only_path = options[:only_path]
89
90
  options.except! :exhibit_id, :only_path
90
91
 
91
92
  if only_path
92
- spotlight.search_exhibit_catalog_path(current_exhibit, *args, options)
93
+ spotlight.search_exhibit_catalog_path(current_exhibit, *args, **options)
93
94
  else
94
- spotlight.search_exhibit_catalog_url(current_exhibit, *args, options)
95
+ spotlight.search_exhibit_catalog_url(current_exhibit, *args, **options)
95
96
  end
96
97
  end
97
98
 
98
- def exhibit_search_facet_path(*args)
99
+ def exhibit_search_facet_path(*args, **kwargs)
99
100
  options = args.extract_options!
100
- options = Blacklight::Parameters.sanitize(params.to_unsafe_h.with_indifferent_access).merge(options).except(:exhibit_id, :only_path)
101
- spotlight.facet_exhibit_catalog_url(current_exhibit, *args, options)
101
+ options = Blacklight::Parameters.sanitize(params.to_unsafe_h.with_indifferent_access).merge(options).merge(kwargs).except(:exhibit_id, :only_path)
102
+ spotlight.facet_exhibit_catalog_url(current_exhibit, *args, **options&.symbolize_keys)
102
103
  end
103
104
  end
104
105
  end
@@ -17,7 +17,7 @@ module Spotlight
17
17
 
18
18
  private
19
19
 
20
- # Only allow a trusted parameter "white list" through.
20
+ # Only allow trusted parameters through.
21
21
  def attachment_params
22
22
  params.require(:attachment).permit(:name, :file, :uid)
23
23
  end
@@ -57,7 +57,7 @@ module Spotlight
57
57
  add_breadcrumb t(:'spotlight.configuration.sidebar.search_configuration'), edit_exhibit_search_configuration_path(@exhibit)
58
58
  end
59
59
 
60
- # Only allow a trusted parameter "white list" through.
60
+ # Only allow trusted parameters through.
61
61
  def custom_search_field_params
62
62
  params.require(:custom_search_field).permit(:slug, :field, :label)
63
63
  end
@@ -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,13 +29,13 @@ 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
 
39
36
  # GET /pages/1
40
37
  def show
41
- fresh_when([@page.exhibit, @page, request.query_parameters.to_query])
38
+ fresh_when([@page.exhibit, @page])
42
39
  end
43
40
 
44
41
  def preview
@@ -192,7 +189,7 @@ module Spotlight
192
189
  add_breadcrumb t(key, title: current_exhibit.title), spotlight.exhibit_root_path(current_exhibit)
193
190
  end
194
191
 
195
- # Only allow a trusted parameter "white list" through.
192
+ # Only allow trusted parameters through.
196
193
  def page_params
197
194
  params.require(controller_name.singularize).permit(allowed_page_params)
198
195
  end
@@ -208,5 +205,4 @@ module Spotlight
208
205
  end
209
206
  end
210
207
  end
211
- # rubocop:enable Metrics/ClassLength
212
208
  end
@@ -117,9 +117,14 @@ module Spotlight
117
117
  end
118
118
 
119
119
  def query_params
120
- params.to_unsafe_h.with_indifferent_access.except(:exhibit_id, :search, *blacklisted_search_session_params).reject { |_k, v| v.blank? }
120
+ params.to_unsafe_h.with_indifferent_access.except(:exhibit_id, :search, *excluded_search_session_params).reject { |_k, v| v.blank? }
121
121
  end
122
122
 
123
+ def excluded_search_session_params
124
+ blacklisted_search_session_params
125
+ end
126
+
127
+ # @deprecated
123
128
  def blacklisted_search_session_params
124
129
  %i[id commit counter total search_id page per_page authenticity_token utf8 action controller]
125
130
  end
@@ -162,7 +162,7 @@ module Spotlight
162
162
  if current_exhibit_theme && current_exhibit.theme != 'default'
163
163
  stylesheet_link_tag "#{tag}_#{current_exhibit_theme}"
164
164
  else
165
- Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in white-list of available themes: #{current_exhibit.themes}"
165
+ Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in the list of available themes: #{current_exhibit.themes}"
166
166
  stylesheet_link_tag(tag)
167
167
  end
168
168
  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?
@@ -40,7 +40,7 @@ module Spotlight
40
40
  if current_exhibit_theme && current_exhibit&.theme != 'default'
41
41
  stylesheet_link_tag "#{tag}_#{current_exhibit_theme}"
42
42
  else
43
- Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in white-list of available themes: #{current_exhibit&.themes}"
43
+ Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in the list of available themes: #{current_exhibit&.themes}"
44
44
  stylesheet_link_tag(tag)
45
45
  end
46
46
  end
@@ -16,6 +16,18 @@ module Spotlight
16
16
  end
17
17
  end
18
18
 
19
+ def sir_trevor_format(text, format: :markdown)
20
+ if format.to_s.to_sym == :html
21
+ sir_trevor_html(text)
22
+ else
23
+ sir_trevor_markdown(text)
24
+ end
25
+ end
26
+
27
+ def sir_trevor_html(text)
28
+ sanitize(text, tags: %w[b i a br p sup])
29
+ end
30
+
19
31
  ##
20
32
  # Override the default #sir_trevor_markdown so we can use
21
33
  # a more complete markdown rendered
@@ -27,10 +27,8 @@ module Spotlight
27
27
  content_tag(:h1, html_content, class: 'page-header')
28
28
  end
29
29
 
30
- # rubocop:disable Naming/AccessorMethodName
31
30
  def set_html_page_title(title = nil)
32
31
  @page_title = strip_tags(t(:'spotlight.html_title', title: title || t(:'.title', default: :'.header'), application_name: application_name)).html_safe
33
32
  end
34
- # rubocop:enable Naming/AccessorMethodName
35
33
  end
36
34
  end
@@ -6,8 +6,9 @@ module Spotlight
6
6
  class ConfirmationMailer < ActionMailer::Base
7
7
  include Devise::Mailers::Helpers
8
8
 
9
- def confirmation_instructions(record, token, opts)
9
+ def confirmation_instructions(record, token, opts, exhibit: nil)
10
10
  @token = token
11
+ @exhibit = exhibit
11
12
  initialize_from_record(record)
12
13
  mail headers_for(:confirmation_instructions, opts)
13
14
  end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ostruct'
4
+
5
+ module SirTrevorRails
6
+ # Forked from (former) upstream sir-trevor-rails 0.6.2 gem:
7
+ # https://github.com/madebymany/sir-trevor-rails/blob/931b9554f5268158b4da8817477cdc82e4e2e69c/lib/sir_trevor_rails/block.rb
8
+ # Copyright (c) 2013-2014 by ITV plc - http://www.itv.com
9
+ class Block < OpenStruct
10
+ DEFAULT_FORMAT = :markdown
11
+
12
+ def self.from_hash(hash, parent = nil)
13
+ hash = hash.deep_dup.with_indifferent_access
14
+ type_klass(hash).new(hash, parent)
15
+ end
16
+
17
+ def format
18
+ send(:[], :format).present? ? send(:[], :format).to_sym : DEFAULT_FORMAT
19
+ end
20
+
21
+ # Sets a list of custom block types to speed up lookup at runtime.
22
+ def self.custom_block_types
23
+ # You can define your custom block types directly here or in your engine config.
24
+ Spotlight::Engine.config.sir_trevor_widgets
25
+ end
26
+
27
+ def initialize(hash, parent)
28
+ @raw_data = hash
29
+ @parent = parent
30
+ @type = hash[:type].to_sym
31
+ super(hash[:data])
32
+ end
33
+
34
+ attr_reader :parent, :type
35
+
36
+ def to_partial_path
37
+ "sir_trevor/blocks/#{self.class.name.demodulize.underscore}"
38
+ end
39
+
40
+ def as_json(*_attrs)
41
+ {
42
+ type: @type.to_s,
43
+ data: marshal_dump
44
+ }
45
+ end
46
+
47
+ # Infers the block class.
48
+ # Safe lookup that tries to identify user created block class.
49
+ #
50
+ # @param [Symbol] type
51
+ def self.block_class(type)
52
+ type_name = type.to_s.camelize
53
+ block_name = "#{type_name}Block"
54
+ if custom_block_types.include?(type_name)
55
+ begin
56
+ block_name.constantize
57
+ rescue NameError
58
+ block_class!(block_name)
59
+ end
60
+ else
61
+ block_class!(block_name)
62
+ end
63
+ end
64
+
65
+ # Infers the block class.
66
+ # Failover from block_class.
67
+ # Safe lookup against the SirTevor::Blocks namespace
68
+ # If no block is found, create one with given name and inherit from Block class
69
+ #
70
+ # @param [Constant] block_name
71
+ def self.block_class!(block_name)
72
+ SirTrevorRails::Blocks.const_get(block_name)
73
+ rescue NameError
74
+ SirTrevorRails::Blocks.const_set(block_name, Class.new(Block))
75
+ end
76
+
77
+ def self.type_klass(hash)
78
+ if self == Block
79
+ block_class(hash[:type].to_sym)
80
+ else
81
+ self
82
+ end
83
+ end
84
+ end
85
+ end
@@ -14,7 +14,7 @@ module SirTrevorRails
14
14
  end
15
15
 
16
16
  def ordered_items
17
- items.sort_by { |x| x[:weight] }.map { |x| x[:id] }
17
+ items.sort_by { |x| x[:weight].to_i }.map { |x| x[:id] }
18
18
  end
19
19
 
20
20
  private
@@ -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
@@ -28,7 +28,7 @@ module SirTrevorRails
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
@@ -33,7 +33,7 @@ module Spotlight
33
33
  end
34
34
 
35
35
  def send_devise_notification(notification, *args)
36
- notice = notification_mailer.send(notification, self, *args)
36
+ notice = notification_mailer.send(notification, self, *args, exhibit: exhibit)
37
37
  if notice.respond_to? :deliver_now
38
38
  notice.deliver_now
39
39
  else
@@ -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
 
@@ -57,7 +57,7 @@ module Spotlight
57
57
  end
58
58
 
59
59
  def available_view_configs
60
- available_view_fields.map { |k, v| { key: k, label: v.display_label(k) } }
60
+ available_view_fields.map { |k, v| { key: k, label: v.display_label } }
61
61
  end
62
62
 
63
63
  def attachment_endpoint
@@ -5,12 +5,21 @@ module Spotlight
5
5
  # Sir-Trevor created content
6
6
  class SirTrevor
7
7
  def self.parse(page, attribute)
8
- content = page.read_attribute(attribute)
9
- content ||= [].to_json
8
+ blocks = page.read_attribute(attribute)
9
+ blocks ||= [].to_json
10
10
 
11
- return SirTrevorRails::BlockArray.new if content.blank?
11
+ return [] if blocks.blank?
12
12
 
13
- SirTrevorRails::BlockArray.from_json(content, page)
13
+ blocks = JSON.parse(blocks, symbolize_names: true) if blocks.is_a?(String)
14
+
15
+ if blocks.is_a?(Hash)
16
+ blocks = blocks[:data] || blocks['data'] or
17
+ raise IndexError, 'No block data found'
18
+ end
19
+
20
+ blocks.map do |obj|
21
+ SirTrevorRails::Block.from_hash(obj, page)
22
+ end
14
23
  end
15
24
  end
16
25
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ unless defined?(Translation)
4
+ Translation = I18n::Backend::ActiveRecord::Translation
5
+ Translation.include Spotlight::CustomTranslationExtension
6
+
7
+ # Work-around for https://github.com/svenfuchs/i18n-active_record/pull/133
8
+ if Translation.respond_to?(:to_hash)
9
+ class << Translation
10
+ alias to_h to_hash
11
+ remove_method :to_hash
12
+ end
13
+
14
+ I18n::Backend::ActiveRecord.define_method(:init_translations) do
15
+ @translations = Translation.to_h
16
+ end
17
+ end
18
+ end
@@ -49,7 +49,7 @@ module Spotlight
49
49
  deserialize_featured_image(exhibit, :masthead, hash[:masthead]) if hash[:masthead]
50
50
  deserialize_featured_image(exhibit, :thumbnail, hash[:thumbnail]) if hash[:thumbnail]
51
51
 
52
- exhibit.blacklight_configuration.update hash[:blacklight_configuration].deep_stringify_keys if hash[:blacklight_configuration]
52
+ exhibit.blacklight_configuration.update hash[:blacklight_configuration].with_indifferent_access if hash[:blacklight_configuration]
53
53
 
54
54
  hash[:main_navigations].each do |attr|
55
55
  ar = exhibit.main_navigations.find_or_initialize_by(nav_type: attr[:nav_type])
@@ -24,7 +24,9 @@
24
24
  <body class="<%= render_body_class %>">
25
25
  <%= render partial: 'shared/body_preamble' %>
26
26
  <div id="skip-link">
27
- <%= 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 %>
28
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' } %>
29
31
  <%= content_for(:skip_links) %>
30
32
  </div>
@@ -7,7 +7,7 @@
7
7
  <li class="nav-item"><%= link_to t(:'spotlight.sites.edit.page_title'), spotlight.edit_site_path, class: 'nav-link' %></li>
8
8
  <% end %>
9
9
 
10
- <% if can? :manange, Spotlight::Exhibit %>
10
+ <% if can? :manage, Spotlight::Exhibit %>
11
11
  <li class="nav-item"><%= link_to t(:'spotlight.sites.edit_exhibits.page_title'), spotlight.edit_site_exhibits_path, class: 'nav-link' %></li>
12
12
  <li class="nav-item"><%= link_to t(:'spotlight.admin_users.index.page_title'), spotlight.admin_users_path, class: 'nav-link' %></li>
13
13
  <% end %>
@@ -10,7 +10,7 @@
10
10
  <%- if @response.empty? %>
11
11
  <%= render "zero_results" %>
12
12
  <%- else %>
13
- <%= render_document_index %>
13
+ <%= render_document_index(@response.documents) %>
14
14
  <%- end %>
15
15
 
16
16
  <%= render 'results_pagination' %>
@@ -1,5 +1,5 @@
1
1
  <p><%= t(:'.welcome', email: @email) %></p>
2
-
3
- <p><%= t(:'.instructions') %></p>
4
-
2
+ <br /><br />
3
+ <%= simple_format t(:'.instructions', exhibit_title: @exhibit&.title) %>
4
+ <br /><br />
5
5
  <p><%= link_to t(:'.confirm'), spotlight.contact_email_confirmation_url(:confirmation_token => @token) %></p>
@@ -4,7 +4,7 @@
4
4
  <p class="instructions"><%= t :'.instructions' %></p>
5
5
  <div class="form-group">
6
6
  <%= file_field_tag :file, class: 'form-control' %>
7
- <%= hidden_field_tag :tab, 'import' %>
7
+ <%= hidden_field_tag :tab, 'import', id: nil %>
8
8
  </div>
9
9
  <div class="form-actions">
10
10
  <div class="primary-actions">
@@ -4,7 +4,7 @@
4
4
  <%= bootstrap_form_for [current_exhibit, Spotlight::Language.new], layout: :horizontal, html: { class: 'row' }, label_col: "col-sm-3", control_col: "col-sm-9" do |f| %>
5
5
  <div class='col-sm-6'>
6
6
  <%= f.select('locale', add_exhibit_language_dropdown_options, prompt: t('.selection_prompt')) %>
7
- <%= hidden_field_tag :tab, 'language' %>
7
+ <%= hidden_field_tag :tab, 'language', id: nil %>
8
8
  </div>
9
9
  <div class='col-sm-6'>
10
10
  <%= f.submit nil, class: 'btn btn-primary' %>
@@ -48,7 +48,7 @@
48
48
  </div>
49
49
  <div class="form-actions">
50
50
  <div class="primary-actions">
51
- <%= hidden_field_tag :tab, 'language' %>
51
+ <%= hidden_field_tag :tab, 'language', id: nil %>
52
52
  <%= f.submit nil, class: 'btn btn-primary' %>
53
53
  </div>
54
54
  </div>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= f.text_field :field %>
6
6
  <%= f.text_field :value %>
7
- <%= hidden_field_tag :tab, 'filter' %>
7
+ <%= hidden_field_tag :tab, 'filter', id: nil %>
8
8
 
9
9
  <div class="form-actions">
10
10
  <div class="primary-actions">
@@ -11,7 +11,7 @@
11
11
  <% end %>
12
12
  <div class="form-actions">
13
13
  <div class="primary-actions">
14
- <%= hidden_field_tag :tab, 'upload' %>
14
+ <%= hidden_field_tag :tab, 'upload', id: nil %>
15
15
  <%= cancel_link @resource, :back, class: 'btn-sizing' %>
16
16
  <%= f.submit t('.add_item_and_continue'), name: 'add-and-continue', class: 'btn btn-secondary' %>
17
17
  <%= f.submit t('.add_item'), class: 'btn btn-primary' %>
@@ -1,7 +1,7 @@
1
1
  <%= f.form_group :document_index_view_types, label: {text: t(:'.label'), class: 'pt-0'} do %>
2
2
  <%= f.fields_for :document_index_view_types, @blacklight_configuration.document_index_view_types_selected_hash do |vt| %>
3
3
  <% @blacklight_configuration.default_blacklight_config.view.select { |_k, v| v.if != false }.each do |key, view| %>
4
- <%= vt.check_box key, label: view.display_label(key) %>
4
+ <%= vt.check_box key, label: view.display_label %>
5
5
  <% end %>
6
6
  <% end %>
7
7
  <% end %>
@@ -1,8 +1,10 @@
1
1
  <%= content_tag :span, t(:'.document_count', count: metadata[:document_count]) %>
2
2
  <% if metadata[:document_count] > 0 %>
3
3
 
4
- <% if metadata[:value_count] > Spotlight::FieldMetadata::FACET_LIMIT %>
5
- <%= content_tag :span, t(:'.too_many_values_count', count: Spotlight::FieldMetadata::FACET_LIMIT) %>
4
+ <% limit = field_config&.limit || Spotlight::FieldMetadata::FACET_LIMIT %>
5
+ <% limit = blacklight_config.default_facet_limit if limit == true %>
6
+ <% if metadata[:value_count] >= limit %>
7
+ <%= content_tag :span, t(:'.too_many_values_count', count: limit) %>
6
8
  <% else %>
7
9
  <%= content_tag :span, t(:'.value_count', count: metadata[:value_count]) %>
8
10
  <% end %>
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
  <% when :additional_options %>
18
18
  <div class="facet-metadata mr-3">
19
- <%= render partial: 'facet_metadata', locals: { metadata: metadata } %>
19
+ <%= render partial: 'facet_metadata', locals: { blacklight_config: @blacklight_configuration.blacklight_config, field_config: config, metadata: metadata } %>
20
20
  </div>
21
21
  <% else %>
22
22
  <% end %>
@@ -40,7 +40,7 @@
40
40
  <% end %>
41
41
  <%= f.form_group label: { text: t(:".default_index_view_type"), class: 'pt-0' } do %>
42
42
  <% available_document_index_views.each do |key, view| %>
43
- <%= f.radio_button :default_index_view_type, key, label: view.display_label(key) %>
43
+ <%= f.radio_button :default_index_view_type, key, label: view.display_label %>
44
44
  <% end %>
45
45
  <% end %>
46
46
  <% unless @search.query_params.blank? %>
@@ -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) %>
@@ -0,0 +1,5 @@
1
+ <% if video.source == 'vimeo' %>
2
+ <%= render partial: '/spotlight/sir_trevor/blocks/videos/vimeo', vimeo: video %>
3
+ <% elsif video.source == 'youtube' %>
4
+ <%= render partial: '/spotlight/sir_trevor/blocks/videos/youtube', youtube: video %>
5
+ <% end %>
@@ -2,7 +2,7 @@
2
2
  <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %>
3
3
  <% # Add hidden fields for the language and tab so the redirect knows how to come back here %>
4
4
  <%= hidden_field_tag :language, @language %>
5
- <%= hidden_field_tag :tab, 'browse' %>
5
+ <%= hidden_field_tag :tab, 'browse', id: nil %>
6
6
  <div class="row">
7
7
  <div class="col-4 text-right">
8
8
  <span class="browse-translations-header">
@@ -2,7 +2,7 @@
2
2
  <%= bootstrap_form_for current_exhibit, url: spotlight.exhibit_translations_path(current_exhibit), layout: :horizontal do |f| %>
3
3
  <% # Add hidden fields for the language and tab so the redirect knows how to come back here %>
4
4
  <%= hidden_field_tag :language, @language %>
5
- <%= hidden_field_tag :tab, 'groups' %>
5
+ <%= hidden_field_tag :tab, 'groups', id: nil %>
6
6
 
7
7
  <% current_exhibit.groups.each do |group| %>
8
8
  <% title_translation = Translation.find_or_initialize_by(exhibit: current_exhibit, key: "#{group.slug}.title", locale: @language) %>