Class: Hyrax::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hyrax::Install
- Defined in:
- lib/generators/hyrax/install_generator.rb
Instance Method Summary collapse
- #af_noid_database_minter_initialize ⇒ Object
- #catalog_controller ⇒ Object
- #configure_usage_stats ⇒ Object
- #copy_helper ⇒ Object
- #create_workflow ⇒ Object
- #datatables ⇒ Object
-
#inject_ability ⇒ Object
we’re going to inject this into the local app, so that it’s easy to disable.
-
#inject_hyrax_application_controller_behavior ⇒ Object
Add behaviors to the application controller.
-
#inject_routes ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work.
-
#inject_solr_document_behavior ⇒ Object
Add behaviors to the SolrDocument model.
- #insert_builder ⇒ Object
- #install_assets ⇒ Object
- #install_blacklight_gallery ⇒ Object
- #install_config ⇒ Object
- #install_mailboxer ⇒ Object
- #qa_tables ⇒ Object
- #replace_blacklight_layout ⇒ Object
- #run_required_generators ⇒ Object
- #use_browser_validations ⇒ Object
Instance Method Details
#af_noid_database_minter_initialize ⇒ Object
163 164 165 |
# File 'lib/generators/hyrax/install_generator.rb', line 163 def af_noid_database_minter_initialize generate 'active_fedora:noid:install' end |
#catalog_controller ⇒ Object
63 64 65 |
# File 'lib/generators/hyrax/install_generator.rb', line 63 def catalog_controller copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb" end |
#configure_usage_stats ⇒ Object
93 94 95 |
# File 'lib/generators/hyrax/install_generator.rb', line 93 def configure_usage_stats copy_file 'config/analytics.yml', 'config/analytics.yml' end |
#copy_helper ⇒ Object
118 119 120 |
# File 'lib/generators/hyrax/install_generator.rb', line 118 def copy_helper copy_file 'hyrax_helper.rb', 'app/helpers/hyrax_helper.rb' end |
#create_workflow ⇒ Object
80 81 82 83 |
# File 'lib/generators/hyrax/install_generator.rb', line 80 def create_workflow template('workflow.json.erb', "config/workflows/default_workflow.json") template('mediated_deposit_workflow.json.erb', "config/workflows/mediated_deposit_workflow.json") end |
#datatables ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/generators/hyrax/install_generator.rb', line 143 def datatables javascript_manifest = 'app/assets/javascripts/application.js' # Generator is broken https://github.com/rweng/jquery-datatables-rails/issues/225 # generate 'jquery:datatables:install bootstrap3' insert_into_file javascript_manifest, after: /jquery.?\n/ do "//= require jquery_ujs\n" \ "//= require dataTables/jquery.dataTables\n" \ "//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap\n" end # This is only necessary for Rails 5.1 and hopefully is temporary. # There was some trouble getting the file-manager javascript (remote forms) to work well # with rails-ujs. Note jquery_ujs was added to the block above (after jQuery) gsub_file javascript_manifest, 'require rails-ujs', '' insert_into_file 'app/assets/stylesheets/application.css', before: ' *= require_self' do " *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap\n" end end |
#inject_ability ⇒ Object
we’re going to inject this into the local app, so that it’s easy to disable.
98 99 100 101 102 103 |
# File 'lib/generators/hyrax/install_generator.rb', line 98 def inject_ability inject_into_file 'app/models/ability.rb', after: /Hydra::Ability\s*\n/ do " include Hyrax::Ability\n"\ " self.ability_logic += [:everyone_can_create_curation_concerns]\n\n" end end |
#inject_hyrax_application_controller_behavior ⇒ Object
Add behaviors to the application controller
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/generators/hyrax/install_generator.rb', line 106 def inject_hyrax_application_controller_behavior file_path = "app/controllers/application_controller.rb" if File.exist?(file_path) insert_into_file file_path, after: /Hydra::Controller::ControllerBehavior\s*\n/ do "\n # Adds Hyrax behaviors into the application controller" \ "\n include Hyrax::Controller\n" end else puts " \e[31mFailure\e[0m Could not find #{file_path}. To add Hyrax behaviors to your Controllers, you must include the Hyrax::Controller module in the Controller class definition." end end |
#inject_routes ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/hyrax/install_generator.rb', line 50 def inject_routes # Remove root route that was added by blacklight generator gsub_file 'config/routes.rb', /root (:to =>|to:) "catalog#index"/, '' inject_into_file 'config/routes.rb', after: /devise_for :users\s*\n/ do " mount Qa::Engine => '/authorities'\n"\ " mount Hyrax::Engine, at: '/'\n"\ " resources :welcome, only: 'index'\n"\ " root 'hyrax/homepage#index'\n"\ " curation_concerns_basic_routes\n"\ end end |
#inject_solr_document_behavior ⇒ Object
Add behaviors to the SolrDocument model
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/generators/hyrax/install_generator.rb', line 68 def inject_solr_document_behavior file_path = 'app/models/solr_document.rb' if File.exist?(file_path) inject_into_file file_path, after: /include Blacklight::Solr::Document.*$/ do "\n # Adds Hyrax behaviors to the SolrDocument.\n" \ " include Hyrax::SolrDocumentBehavior\n" end else puts " \e[31mFailure\e[0m Hyrax requires a SolrDocument object. This generators assumes that the model is defined in the file #{file_path}, which does not exist." end end |
#insert_builder ⇒ Object
43 44 45 46 47 |
# File 'lib/generators/hyrax/install_generator.rb', line 43 def insert_builder insert_into_file 'app/models/search_builder.rb', after: /include Hydra::AccessControlsEnforcement/ do "\n include Hyrax::SearchFilters\n" end end |
#install_assets ⇒ Object
126 127 128 |
# File 'lib/generators/hyrax/install_generator.rb', line 126 def install_assets generate "hyrax:assets" end |
#install_blacklight_gallery ⇒ Object
136 137 138 139 140 141 |
# File 'lib/generators/hyrax/install_generator.rb', line 136 def install_blacklight_gallery generate "blacklight_gallery:install" # This was pulling in an extra copy of bootstrap, so we added the needed # includes to hyrax.scss remove_file 'app/assets/stylesheets/blacklight_gallery.css.scss' end |
#install_config ⇒ Object
85 86 87 |
# File 'lib/generators/hyrax/install_generator.rb', line 85 def install_config generate "hyrax:config" end |
#install_mailboxer ⇒ Object
89 90 91 |
# File 'lib/generators/hyrax/install_generator.rb', line 89 def install_mailboxer generate "mailboxer:install" end |
#qa_tables ⇒ Object
122 123 124 |
# File 'lib/generators/hyrax/install_generator.rb', line 122 def qa_tables generate 'qa:local:tables' end |
#replace_blacklight_layout ⇒ Object
38 39 40 41 |
# File 'lib/generators/hyrax/install_generator.rb', line 38 def replace_blacklight_layout gsub_file 'app/controllers/application_controller.rb', /layout 'blacklight'/, "include Hyrax::ThemedLayoutController\n with_themed_layout '1_column'\n" end |
#run_required_generators ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/generators/hyrax/install_generator.rb', line 30 def run_required_generators say_status('info', '[Hyrax] GENERATING BLACKLIGHT', :blue) generate 'blacklight:install --devise' say_status('info', '[Hyrax] GENERATING HYDRA-HEAD', :blue) generate 'hydra:head -f' generate "hyrax:models#{[:force] ? ' -f' : ''}" end |
#use_browser_validations ⇒ Object
130 131 132 133 134 |
# File 'lib/generators/hyrax/install_generator.rb', line 130 def use_browser_validations gsub_file 'config/initializers/simple_form.rb', /browser_validations = false/, 'browser_validations = true' end |