diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index ed9c521a2..f2d3bd44f 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -26,7 +26,12 @@ jobs: ruby: "3.2" blacklight_version: "~> 7.34" bootstrap_version: ~> 4.0 - additional_name: Rails 6.1 + additional_name: Rails 7.1 + - rails_version: 7.1.3.4 + ruby: 3.3 + blacklight_version: ~> 8.0 + bootstrap_version: ~> 4.0 + additional_name: Blacklight 8 - rails_version: 7.0.8.4 ruby: 3.3 blacklight_version: ~> 7.34 diff --git a/app/views/layouts/spotlight/base.html.erb b/app/views/layouts/spotlight/base.html.erb index 619527cb5..277f17b0f 100644 --- a/app/views/layouts/spotlight/base.html.erb +++ b/app/views/layouts/spotlight/base.html.erb @@ -13,7 +13,11 @@ <% else %> <%= stylesheet_link_tag "application" %> <% end %> - <%= javascript_include_tag "application" %> + <% if defined? Importmap %> + <%= javascript_importmap_tags %> + <% else %> + <%= javascript_include_tag "application" %> + <% end %> <%= csrf_meta_tags %> <%= content_for(:head) %> <%= description %> diff --git a/lib/generators/spotlight/install_generator.rb b/lib/generators/spotlight/install_generator.rb index 7f79134fd..5dd464bd8 100644 --- a/lib/generators/spotlight/install_generator.rb +++ b/lib/generators/spotlight/install_generator.rb @@ -19,11 +19,21 @@ def add_js_rails6 end def add_manifest - append_to_file 'app/assets/javascripts/application.js', "\n//= require_tree .\n" append_to_file 'app/assets/config/manifest.js', "\n//= link spotlight/manifest.js" - # Rails installed importmap by default, but we don't have importmap + Blacklight 7 working yet. - remove_file 'app/javascript/application.js' + # Blacklight 8 does not use this directory by default. + if File.exist?('app/assets/javascripts') + append_to_file 'app/assets/javascripts/application.js', "\n//= require_tree .\n" + # Rails installed importmap by default, but we don't have importmap + Blacklight 7 working yet. + remove_file 'app/javascript/application.js' + else + # install via importmap + append_to_file 'app/javascript/application.js' do + <<~CONTENT + import Spotlight from "spotlight.esm" + CONTENT + end + end end def inject_spotlight_routes diff --git a/spec/test_app_templates/Gemfile.extra b/spec/test_app_templates/Gemfile.extra index 575e79f5d..9e9b6bbc2 100644 --- a/spec/test_app_templates/Gemfile.extra +++ b/spec/test_app_templates/Gemfile.extra @@ -1,5 +1,10 @@ -if ENV['BLACKLIGHT_VERSION'] == 'edge' +case ENV['BLACKLIGHT_VERSION'] +when 'edge' gem 'blacklight', github: 'projectblacklight/blacklight' gem 'blacklight-gallery', github: 'projectblacklight/blacklight-gallery' gem 'blacklight-oembed', github: 'projectblacklight/blacklight-oembed' +when 'latest' + gem 'blacklight' +else + gem 'blacklight', ENV['BLACKLIGHT_VERSION'] if ENV['BLACKLIGHT_VERSION'] && !ENV['BLACKLIGHT_VERSION'].empty? end diff --git a/spec/test_app_templates/lib/generators/test_app_generator.rb b/spec/test_app_templates/lib/generators/test_app_generator.rb index 4d60bb9c6..86360a593 100644 --- a/spec/test_app_templates/lib/generators/test_app_generator.rb +++ b/spec/test_app_templates/lib/generators/test_app_generator.rb @@ -31,7 +31,6 @@ def run_spotlight_migrations def add_spotlight_routes_and_assets generate :'spotlight:install', '-f --mailer_default_url_host=localhost:3000' - append_to_file 'app/assets/config/manifest.js', "\n//= link application.js\n" if Rails.version > '7' && File.exist?('app/assets/config/manifest.js') end def install_test_catalog_controller