Class: Sufia::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sufia::Install
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sufia/install_generator.rb
Instance Method Summary collapse
- #catalog_controller ⇒ Object
- #copy_helper ⇒ Object
-
#inject_routes ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work.
-
#inject_sufia_controller_behavior ⇒ Object
Add behaviors to the application controller.
-
#inject_sufia_solr_document_behavior ⇒ Object
Add behaviors to the SolrDocument model.
- #insert_abilities ⇒ Object
- #remove_blacklight_scss ⇒ Object
- #run_required_generators ⇒ Object
- #tinymce_config ⇒ Object
Instance Method Details
#catalog_controller ⇒ Object
47 48 49 |
# File 'lib/generators/sufia/install_generator.rb', line 47 def catalog_controller copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb" end |
#copy_helper ⇒ Object
51 52 53 |
# File 'lib/generators/sufia/install_generator.rb', line 51 def copy_helper copy_file 'sufia_helper.rb', 'app/helpers/sufia_helper.rb' end |
#inject_routes ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/generators/sufia/install_generator.rb', line 64 def inject_routes gsub_file 'config/routes.rb', 'root :to => "catalog#index"', '' routing_code = "\n Hydra::BatchEdit.add_routes(self)\n" + " # This must be the very last route in the file because it has a catch-all route for 404 errors. # This behavior seems to show up only in production mode. mount Sufia::Engine => '/'\n root to: 'homepage#index'\n" sentinel = /devise_for :users/ inject_into_file 'config/routes.rb', routing_code, { after: sentinel, verbose: false } end |
#inject_sufia_controller_behavior ⇒ Object
Add behaviors to the application controller
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/sufia/install_generator.rb', line 33 def inject_sufia_controller_behavior controller_name = "ApplicationController" file_path = "app/controllers/application_controller.rb" if File.exists?(file_path) insert_into_file file_path, after: 'include Blacklight::Controller' do " \n# Adds Sufia behaviors into the application controller \n" + " include Sufia::Controller\n" end gsub_file file_path, "layout 'blacklight'", "layout 'sufia-one-column'" else puts " \e[31mFailure\e[0m Could not find #{file_path}. To add Sufia behaviors to your Controllers, you must include the Sufia::Controller module in the Controller class definition." end end |
#inject_sufia_solr_document_behavior ⇒ Object
Add behaviors to the SolrDocument model
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/generators/sufia/install_generator.rb', line 77 def inject_sufia_solr_document_behavior file_path = "app/models/solr_document.rb" if File.exists?(file_path) inject_into_file file_path, after: /include Blacklight::Solr::Document.*$/ do "\n # Adds Sufia behaviors to the SolrDocument.\n" + " include Sufia::SolrDocumentBehavior\n" end else puts " \e[31mFailure\e[0m Sufia requires a SolrDocument object. This generators assumes that the model is defined in the file #{file_path}, which does not exist." end end |
#insert_abilities ⇒ Object
26 27 28 29 30 |
# File 'lib/generators/sufia/install_generator.rb', line 26 def insert_abilities insert_into_file 'app/models/ability.rb', after: /Hydra::Ability/ do "\n include Sufia::Ability\n" end end |
#remove_blacklight_scss ⇒ Object
55 56 57 |
# File 'lib/generators/sufia/install_generator.rb', line 55 def remove_blacklight_scss remove_file 'app/assets/stylesheets/blacklight.css.scss' end |
#run_required_generators ⇒ Object
20 21 22 23 24 |
# File 'lib/generators/sufia/install_generator.rb', line 20 def run_required_generators generate "blacklight:install --devise" generate "hydra:head -f" generate "sufia:models:install" end |
#tinymce_config ⇒ Object
59 60 61 |
# File 'lib/generators/sufia/install_generator.rb', line 59 def tinymce_config copy_file "config/tinymce.yml", "config/tinymce.yml" end |