Class: BlacklightHeatmaps::Install

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

Instance Method Summary collapse

Instance Method Details

#add_model_mixinObject



32
33
34
35
36
# File 'lib/generators/blacklight_heatmaps/install_generator.rb', line 32

def add_model_mixin
  inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do
    "\n  include BlacklightHeatmaps::GeometrySolrDocument\n"
  end
end

#configurationObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/blacklight_heatmaps/install_generator.rb', line 18

def configuration
  inject_into_file 'app/controllers/catalog_controller.rb', after: 'configure_blacklight do |config|' do
    "\n    # BlacklightHeatmaps configuration values" \
    "\n    config.geometry_field = :geo_srpt" \
    "\n    config.heatmap_distErrPct = 0.15 # Default Solr value" \
    "\n    # Basemaps configured include: 'positron', 'darkMatter', 'OpenStreetMap.HOT'" \
    "\n    config.basemap_provider = 'positron'" \
    "\n    config.show.partials.insert(1, :show_leaflet_map)" \
    "\n    config.index.respond_to.heatmaps = true" \
    "\n    config.view.heatmaps(partials: [], color_ramp: ['#ffffcc', '#a1dab4', '#41b6c4', '#2c7fb8', '#253494'])" \
    "\n"
  end
end

#copy_stylesObject



7
8
9
# File 'lib/generators/blacklight_heatmaps/install_generator.rb', line 7

def copy_styles
  copy_file 'blacklight_heatmaps.scss', 'app/assets/stylesheets/blacklight_heatmaps.scss'
end

#inject_jsObject



11
12
13
14
15
16
# File 'lib/generators/blacklight_heatmaps/install_generator.rb', line 11

def inject_js
  inject_into_file 'app/assets/javascripts/application.js', after: '//= require blacklight/blacklight' do
    "\n// Required by BlacklightHeatmaps" \
    "\n//= require blacklight_heatmaps/default"
  end
end

#inject_search_builderObject



38
39
40
41
42
# File 'lib/generators/blacklight_heatmaps/install_generator.rb', line 38

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