lib/generators/spotlight/install_generator.rb in blacklight-spotlight-3.3.0 vs lib/generators/spotlight/install_generator.rb in blacklight-spotlight-3.4.0
- old
+ new
@@ -9,11 +9,11 @@
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
- def add_js
+ def add_js_rails6
return unless Rails.version.to_i == 6
gem 'coffee-rails', '~> 4.2'
gem 'uglifier', '>= 1.3.0'
@@ -27,10 +27,16 @@
# 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
+
+ append_to_file 'app/assets/javascripts/application.js', "\n//= require_tree .\n"
+ end
+
def inject_spotlight_routes
route "mount Spotlight::Engine, at: 'spotlight'"
gsub_file 'config/routes.rb', /^\s*root.*/ do |match|
'# ' + match.strip + ' # replaced by spotlight root path'
end
@@ -42,10 +48,12 @@
bundle_install
generate 'friendly_id'
end
def riiif
+ gem 'riiif'
+ Bundler.with_clean_env { run 'bundle install' }
route "mount Riiif::Engine => '/images', as: 'riiif'"
copy_file 'config/initializers/riiif.rb'
end
def paper_trail
@@ -122,11 +130,11 @@
def add_example_catalog_controller
copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb'
end
def add_osd_viewer
- gem 'blacklight-gallery', '~> 3.0'
+ gem 'blacklight-gallery', '~> 4.0'
bundle_install
generate 'blacklight_gallery:install'
end
def add_oembed
@@ -165,9 +173,39 @@
generate 'devise_invitable', 'User'
end
def add_translations
copy_file 'config/initializers/translation.rb'
+ end
+
+ def configure_queue
+ insert_into_file 'config/application.rb', after: "< Rails::Application\n" do
+ <<-EOF
+ config.active_job.queue_adapter = ENV["RAILS_QUEUE"]&.to_sym || :sidekiq
+ EOF
+ end
+ end
+
+ def configure_logging
+ insert_into_file 'config/application.rb', after: "< Rails::Application\n" do
+ <<-EOF
+ # Logging
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ config.log_level = :debug
+ config.log_formatter = ::Logger::Formatter.new
+ # log to stdout
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+ end
+ EOF
+ end
end
private
def bundle_install