From 86c110d7738a82a28c3090be93225ebfb53d6493 Mon Sep 17 00:00:00 2001 From: Alex Dunn Date: Tue, 28 Jan 2020 15:31:20 -0800 Subject: [PATCH] use sir-trevor fork that supports Rails 6 https://github.com/madebymany/sir-trevor-rails/pull/58 --- app/models/spotlight/page_content.rb | 2 ++ app/views/spotlight/pages/_form.html.erb | 2 +- blacklight-spotlight.gemspec | 1 - .../config/initializers/sir_trevor_rails.rb | 28 +++++++++++++++++++ .../initializers/spotlight_initializer.rb | 7 ----- lib/spotlight/engine.rb | 5 ---- spec/test_app_templates/Gemfile.extra | 1 + 7 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb diff --git a/app/models/spotlight/page_content.rb b/app/models/spotlight/page_content.rb index fbd164b9bd..bcffb7bd9a 100644 --- a/app/models/spotlight/page_content.rb +++ b/app/models/spotlight/page_content.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'spotlight/page_content/sir_trevor' + module Spotlight # Factory for picking the right page content renderer module PageContent diff --git a/app/views/spotlight/pages/_form.html.erb b/app/views/spotlight/pages/_form.html.erb index fd05360fa6..610f8dcfaa 100644 --- a/app/views/spotlight/pages/_form.html.erb +++ b/app/views/spotlight/pages/_form.html.erb @@ -40,7 +40,7 @@
<%= f.label :content, class: 'sr-only' %> - <%= f.text_area_without_bootstrap :content, value: { data: f.object.content.as_json }.to_json, class: content_editor_class(f.object), data: { 'block-types': Spotlight::Engine.config.sir_trevor_widgets } %> + <%= f.text_area_without_bootstrap :content, value: { data: f.object.content.as_json }.to_json, class: content_editor_class(f.object), data: { 'block-types': SirTrevorRails::Block.custom_block_types } %>
diff --git a/blacklight-spotlight.gemspec b/blacklight-spotlight.gemspec index d5f0fe2684..f23fdb1cff 100644 --- a/blacklight-spotlight.gemspec +++ b/blacklight-spotlight.gemspec @@ -52,7 +52,6 @@ these collections.) s.add_dependency 'roar', '~> 1.1' s.add_dependency 'roar-rails' s.add_dependency 'signet' - s.add_dependency 'sir_trevor_rails', '~> 0.5' s.add_dependency 'sprockets', '< 4' s.add_dependency 'sprockets-es6' s.add_dependency 'tophat' diff --git a/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb b/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb new file mode 100644 index 0000000000..8ab9cf28c5 --- /dev/null +++ b/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Required for 0.6 and up: +# https://github.com/madebymany/sir-trevor-rails#upgrade-guide-to-v060 +class SirTrevorRails::Block + def self.custom_block_types + %w[ + Browse + FeaturedPages + Heading + Iframe + LinkToSearch + List + Oembed + Quote + Rule + SearchResults + SolrDocuments + SolrDocumentsCarousel + SolrDocumentsEmbed + SolrDocumentsFeatures + SolrDocumentsGrid + Text + UploadedItems + Video + ] + end +end diff --git a/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb b/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb index 0c737c5fed..78a6d15bf8 100644 --- a/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +++ b/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb @@ -69,13 +69,6 @@ # Spotlight::Engine.config.ga_page_analytics_options = config.ga_analytics_options.merge(limit: 5) # Spotlight::Engine.config.ga_anonymize_ip = false # false for backwards compatibility -# ==> Sir Trevor Widget Configuration -# Spotlight::Engine.config.sir_trevor_widgets = %w( -# Heading Text List Quote Iframe Video Oembed Rule UploadedItems Browse -# FeaturedPages SolrDocuments SolrDocumentsCarousel SolrDocumentsEmbed -# SolrDocumentsFeatures SolrDocumentsGrid SearchResults -# ) -# # Page configurations made available to widgets # Spotlight::Engine.config.page_configurations = { # 'my-local-config': ->(context) { context.my_custom_data_path(context.current_exhibit) } diff --git a/lib/spotlight/engine.rb b/lib/spotlight/engine.rb index cff98785d4..e94bd047b0 100644 --- a/lib/spotlight/engine.rb +++ b/lib/spotlight/engine.rb @@ -248,11 +248,6 @@ def self.blacklight_config config.exhibit_themes = ['default'] config.default_page_content_type = 'SirTrevor' - config.sir_trevor_widgets = %w[ - Heading Text List Quote Iframe Video Oembed Rule UploadedItems Browse LinkToSearch - FeaturedPages SolrDocuments SolrDocumentsCarousel SolrDocumentsEmbed - SolrDocumentsFeatures SolrDocumentsGrid SearchResults - ] config.routes = OpenStruct.new config.routes.solr_documents = {} diff --git a/spec/test_app_templates/Gemfile.extra b/spec/test_app_templates/Gemfile.extra index c1e4c2792a..e1ec94903a 100644 --- a/spec/test_app_templates/Gemfile.extra +++ b/spec/test_app_templates/Gemfile.extra @@ -1,4 +1,5 @@ gem 'acts-as-taggable-on', github: 'mbleigh/acts-as-taggable-on' gem 'blacklight-oembed', '>= 0.1', github: 'sul-dlss/blacklight-oembed' gem 'bootstrap_form', github: 'dunn/bootstrap_form' +gem 'sir_trevor_rails', github: 'cbeer/sir-trevor-rails', branch: 'rails6' gem 'thor'