Class: BlacklightMaps::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/blacklight_maps/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#assetsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/blacklight_maps/install_generator.rb', line 10

def assets
  copy_file "blacklight_maps.css.scss", "app/assets/stylesheets/blacklight_maps.css.scss"

  unless IO.read("app/assets/javascripts/application.js").include?('blacklight-maps')
    marker = IO.read("app/assets/javascripts/application.js").include?('turbolinks') ?
      '//= require turbolinks' : "//= require jquery_ujs"
    insert_into_file "app/assets/javascripts/application.js", :after => marker do
      %q{
//
// Required by Blacklight-Maps
//= require blacklight-maps}
    end
  end
end

#inject_search_builderObject



25
26
27
28
29
# File 'lib/generators/blacklight_maps/install_generator.rb', line 25

def inject_search_builder
  inject_into_file 'app/models/search_builder.rb', after: /include Blacklight::Solr::SearchBuilderBehavior.*$/ do
    "\n  include BlacklightMaps::MapsSearchBuilderBehavior\n"
  end
end

#install_catalog_controller_mixinObject



31
32
33
34
35
# File 'lib/generators/blacklight_maps/install_generator.rb', line 31

def install_catalog_controller_mixin
  inject_into_file "app/controllers/catalog_controller.rb", after: /include Blacklight::Catalog.*$/  do
    "\n  include BlacklightMaps::ControllerOverride\n"
  end
end

#install_saved_searches_controllerObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/generators/blacklight_maps/install_generator.rb', line 48

def install_saved_searches_controller
  target_file = "app/controllers/saved_searches_controller.rb"
  if File.exists?(target_file)
    inject_into_file target_file, after: /include Blacklight::SavedSearches/ do
      "\n  helper BlacklightMaps::RenderConstraintsOverride\n"
    end
  else
    copy_file "saved_searches_controller.rb", target_file
  end
end

#install_search_history_controllerObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/blacklight_maps/install_generator.rb', line 37

def install_search_history_controller
  target_file = "app/controllers/search_history_controller.rb"
  if File.exists?(target_file)
    inject_into_file target_file, after: /include Blacklight::SearchHistory/ do
      "\n  helper BlacklightMaps::RenderConstraintsOverride\n"
    end
  else
    copy_file "search_history_controller.rb", target_file
  end
end