Class: Spotlight::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spotlight::Install
- Defined in:
- lib/generators/spotlight/install_generator.rb
Overview
spotlight:install generator
Instance Method Summary collapse
- #add_controller_mixin ⇒ Object
- #add_example_catalog_controller ⇒ Object
- #add_helper ⇒ Object
- #add_mailer_defaults ⇒ Object
- #add_model_mixin ⇒ Object
- #add_oembed ⇒ Object
- #add_osd_viewer ⇒ Object
- #add_roles_to_user ⇒ Object
- #add_search_builder_mixin ⇒ Object
- #add_solr_config_resources ⇒ Object
- #add_solr_indexing_mixin ⇒ Object
- #assets ⇒ Object
- #friendly_id ⇒ Object
- #generate_social_share_button_initializer ⇒ Object
- #inject_spotlight_routes ⇒ Object
- #paper_trail ⇒ Object
- #sitemaps ⇒ Object
Instance Method Details
#add_controller_mixin ⇒ Object
47 48 49 50 51 |
# File 'lib/generators/spotlight/install_generator.rb', line 47 def add_controller_mixin inject_into_file 'app/controllers/application_controller.rb', after: 'include Blacklight::Controller' do "\n include Spotlight::Controller\n" end end |
#add_example_catalog_controller ⇒ Object
88 89 90 |
# File 'lib/generators/spotlight/install_generator.rb', line 88 def add_example_catalog_controller copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb' end |
#add_helper ⇒ Object
53 54 55 56 |
# File 'lib/generators/spotlight/install_generator.rb', line 53 def add_helper copy_file 'spotlight_helper.rb', 'app/helpers/spotlight_helper.rb' inject_into_class 'app/helpers/application_helper.rb', ApplicationHelper, ' include SpotlightHelper' end |
#add_mailer_defaults ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/generators/spotlight/install_generator.rb', line 102 def add_mailer_defaults if [:mailer_default_url_host].present? say 'Injecting a placeholder config.action_mailer.default_url_options; be sure to update it for your environment', :yellow insert_into_file 'config/application.rb', after: "< Rails::Application\n" do <<-EOF config.action_mailer.default_url_options = { host: "#{[:mailer_default_url_host]}", from: "[email protected]" } EOF end else say 'Please add a default configuration config.action_mailer.default_url_options for your environment', :red end end |
#add_model_mixin ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/generators/spotlight/install_generator.rb', line 58 def add_model_mixin if File.exist? 'app/models/solr_document.rb' inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do "\n include Spotlight::SolrDocument\n" end else say 'Unable to find SolrDocument class; add `include Spotlight::SolrDocument` to the class manually' end end |
#add_oembed ⇒ Object
97 98 99 100 |
# File 'lib/generators/spotlight/install_generator.rb', line 97 def gem 'blacklight-oembed' generate 'blacklight_oembed:install' end |
#add_osd_viewer ⇒ Object
92 93 94 95 |
# File 'lib/generators/spotlight/install_generator.rb', line 92 def add_osd_viewer gem 'blacklight-gallery', '>= 0.3.0' generate 'blacklight_gallery:install' end |
#add_roles_to_user ⇒ Object
43 44 45 |
# File 'lib/generators/spotlight/install_generator.rb', line 43 def add_roles_to_user inject_into_class 'app/models/user.rb', User, ' include Spotlight::User' end |
#add_search_builder_mixin ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/generators/spotlight/install_generator.rb', line 78 def add_search_builder_mixin if File.exist? 'app/models/search_builder.rb' inject_into_file 'app/models/search_builder.rb', after: "include Blacklight::Solr::SearchBuilderBehavior\n" do "\n include Spotlight::Catalog::AccessControlsEnforcement::SearchBuilder\n" end else say 'Unable to find SearchBuilder class; add `include Spotlight::Catalog::AccessControlsEnforcement::SearchBuilder` to the class manually.' end end |
#add_solr_config_resources ⇒ Object
120 121 122 123 |
# File 'lib/generators/spotlight/install_generator.rb', line 120 def add_solr_config_resources copy_file 'jetty.rake', 'lib/tasks/jetty.rake' directory 'solr_conf' end |
#add_solr_indexing_mixin ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/generators/spotlight/install_generator.rb', line 68 def add_solr_indexing_mixin if File.exist? 'app/models/solr_document.rb' inject_into_file 'app/models/solr_document.rb', after: "include Spotlight::SolrDocument\n" do "\n include #{[:solr_update_class]}\n" end else say "Unable to find SolrDocument class; add `include #{[:solr_update_class]}` to the class manually" end end |
#assets ⇒ Object
38 39 40 41 |
# File 'lib/generators/spotlight/install_generator.rb', line 38 def assets copy_file 'spotlight.scss', 'app/assets/stylesheets/spotlight.scss' copy_file 'spotlight.js', 'app/assets/javascripts/spotlight.js' end |
#friendly_id ⇒ Object
19 20 21 22 |
# File 'lib/generators/spotlight/install_generator.rb', line 19 def friendly_id gem 'friendly_id' generate 'friendly_id' end |
#generate_social_share_button_initializer ⇒ Object
115 116 117 118 |
# File 'lib/generators/spotlight/install_generator.rb', line 115 def gem 'social-share-button' directory 'config' end |
#inject_spotlight_routes ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/generators/spotlight/install_generator.rb', line 11 def inject_spotlight_routes route "mount Spotlight::Engine, at: 'spotlight'" gsub_file 'config/routes.rb', /^\s*root.*/ do |match| '#' + match + ' # replaced by spotlight root path' end route "root to: 'spotlight/exhibits#index'" end |
#paper_trail ⇒ Object
24 25 26 |
# File 'lib/generators/spotlight/install_generator.rb', line 24 def paper_trail generate 'paper_trail:install' end |
#sitemaps ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/spotlight/install_generator.rb', line 28 def sitemaps gem 'sitemap_generator' 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 EOS end |