class DogBiscuits::DatesGenerator
Public Instance Methods
date_picker()
click to toggle source
rubocop:disable Style/GuardClause
# File lib/generators/dog_biscuits/dates_generator.rb, line 20 def date_picker if DogBiscuits.config.date_picker gem 'bootstrap-datepicker-rails' Bundler.with_clean_env do run "bundle install" end # insert into application.css css = '*= require bootstrap-datepicker' unless File.read('app/assets/stylesheets/application.css').include? css inject_into_file 'app/assets/stylesheets/application.css', before: "*= require_self" do "#{css}\n" end end # insert into application.js js = '//= require bootstrap-datepicker' unless File.read('app/assets/javascripts/application.js').include? js inject_into_file 'app/assets/javascripts/application.js', after: "//= require_tree ." do "\n #{js}" end end DogBiscuits.config.date_picker_dates.each do |date| copy_file '_date_template.html.erb', "app/views/records/edit_fields/_#{date}.html.erb" end end end
date_range()
click to toggle source
# File lib/generators/dog_biscuits/dates_generator.rb, line 51 def date_range if DogBiscuits.config.date_range gem "blacklight_range_limit" Bundler.with_clean_env do run "bundle install" end generate 'blacklight_range_limit:install' copy_file 'config/initializers/catalog_search_builder_overrides.rb', 'config/initializers/catalog_search_builder_overrides.rb' end end
date_range_js()
click to toggle source
In Hyku, the blacklight_range_limit javascript inserts jquery, this causes other js to fail cos of multiple loads
(eg. add work modal doesn't work)
To fix this, remove the standard insert from blacklight_range_limit to remove jquery
and add the require statements individually do this earlier in the file because in production, the blacklight_range_limit js doesn't work if it's at the bottom
This is a bit ugly and fragile.
# File lib/generators/dog_biscuits/dates_generator.rb, line 71 def date_range_js if File.exist?('config/initializers/version.rb') && File.read('config/initializers/version.rb').include?('Hyku') unless File.read('app/assets/javascripts/application.js').include? "//= require 'blacklight_range_limit'\n// Moved the Hyku JS *above* the Hyrax JS" rangejs = "// For blacklight_range_limit built-in JS, if you don't want it you don't need\n" rangejs += "// this:\n" rangejs += "//= require 'blacklight_range_limit'" rangejs_altered = "// For blacklight_range_limit built-in JS, if you don't want it you don't need\n" rangejs_altered += "// this:\n" rangejs_altered += "// require 'blacklight_range_limit'\n" rangejs_new = "\n//= require 'flot/jquery.flot.js'\n" rangejs_new += "//= require 'flot/jquery.flot.selection.js'\n" rangejs_new += "//= require 'bootstrap-slider'\n" rangejs_new += "//= require 'blacklight_range_limit/range_limit_distro_facets.js'\n" rangejs_new += "//= require 'blacklight_range_limit/range_limit_shared.js'\n" rangejs_new += "//= require 'blacklight_range_limit/range_limit_slider.js'\n\n" gsub_file 'app/assets/javascripts/application.js', rangejs, rangejs_altered inject_into_file 'app/assets/javascripts/application.js', before: "// Moved the Hyku JS *above* the Hyrax JS" do rangejs_new end end end end