lib/generators/spotlight/install_generator.rb in blacklight-spotlight-3.5.0.4 vs lib/generators/spotlight/install_generator.rb in blacklight-spotlight-3.6.0.beta1
- old
+ new
@@ -8,33 +8,21 @@
class Install < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
class_option :solr_update_class, type: :string, default: 'Spotlight::SolrDocument::AtomicUpdates'
class_option :mailer_default_url_host, type: :string, default: '' # e.g. localhost:3000
- # we're not (yet) using webpacker, so we need to re-add sprockets functionality
+ # we're not using webpacker, so we need to re-add sprockets functionality
def add_js_rails6
return unless Rails.version.to_i == 6
- gem 'coffee-rails', '~> 4.2'
- gem 'uglifier', '>= 1.3.0'
-
- append_to_file 'app/assets/config/manifest.js', "\n//= link_directory ../javascripts .js\n"
- append_to_file 'app/assets/javascripts/application.js', "\n//= require_tree .\n"
+ # By default rails generates javascript_pack_tag, we'll change this to javascript_include_tag
gsub_file 'app/views/layouts/application.html.erb', /pack/, 'include'
- inject_into_file 'config/environments/production.rb', after: ' # config.assets.css_compressor = :sass' do
- "\n config.assets.js_compressor = :uglifier"
- end
-
- # but since webpacker exists in the gemfile, we still need to run the
- # install before rails will start
- run 'bundle exec rails webpacker:install'
end
- def add_js_rails7
- return unless Rails.version.to_i == 7
-
+ 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"
end
def inject_spotlight_routes
route "mount Spotlight::Engine, at: 'spotlight'"
gsub_file 'config/routes.rb', /^\s*root.*/ do |match|
@@ -65,13 +53,13 @@
bundle_install
copy_file 'config/sitemap.rb', 'config/sitemap.rb'
- say <<-EOS.strip_heredoc, :red
- Added a default sitemap_generator configuration in config/sitemap.rb; please
- update the default host to match your environment
+ say <<~EOS, :red
+ Added a default sitemap_generator configuration in config/sitemap.rb; please
+ update the default host to match your environment
EOS
end
def assets
copy_file 'spotlight.scss', 'app/assets/stylesheets/spotlight.scss'
@@ -130,17 +118,21 @@
def add_example_catalog_controller
copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb'
end
def add_osd_viewer
- gem 'blacklight-gallery', '~> 4.0'
- bundle_install
+ unless Bundler.locked_gems.dependencies.key? 'blacklight-gallery'
+ gem 'blacklight-gallery', '~> 4.0'
+ bundle_install
+ end
generate 'blacklight_gallery:install'
end
def add_oembed
- gem 'blacklight-oembed', '~> 1.0'
- bundle_install
+ unless Bundler.locked_gems.dependencies.key? 'blacklight-oembed'
+ gem 'blacklight-oembed', '~> 1.0'
+ bundle_install
+ end
generate 'blacklight_oembed:install'
copy_file 'config/initializers/oembed.rb'
end
def add_mailer_defaults