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
- #blacklight_dynamic_sitemap ⇒ Object
- #catalog_controller ⇒ Object
- #configure_usage_stats ⇒ Object
- #copy_helper ⇒ Object
- #create_workflow ⇒ Object
- #datatables ⇒ Object
- #dotenv ⇒ Object
- #health_check ⇒ 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_listeners ⇒ Object
add listener code to provide developers a hint that listening to events is a good development pattern.
- #inject_required_seeds ⇒ Object
-
#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_application_config ⇒ Object
- #insert_builder ⇒ Object
- #install_assets ⇒ Object
- #install_blacklight_gallery ⇒ Object
- #install_config ⇒ Object
- #install_mailboxer ⇒ Object
- #lando ⇒ Object
- #noid_rails_database_minter_initialize ⇒ Object
- #qa_tables ⇒ Object
- #replace_blacklight_layout ⇒ Object
- #riiif_image_server ⇒ Object
- #run_required_generators ⇒ Object
- #universalviewer_files ⇒ Object
- #use_browser_validations ⇒ Object
Instance Method Details
#blacklight_dynamic_sitemap ⇒ Object
215 216 217 |
# File 'lib/generators/hyrax/install_generator.rb', line 215 def blacklight_dynamic_sitemap copy_file 'app/views/blacklight_dynamic_sitemap/sitemap/show.xml.builder', 'app/views/blacklight_dynamic_sitemap/sitemap/show.xml.builder' end |
#catalog_controller ⇒ Object
134 135 136 |
# File 'lib/generators/hyrax/install_generator.rb', line 134 def catalog_controller copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb" end |
#configure_usage_stats ⇒ Object
103 104 105 |
# File 'lib/generators/hyrax/install_generator.rb', line 103 def configure_usage_stats copy_file 'config/analytics.yml', 'config/analytics.yml' end |
#copy_helper ⇒ Object
138 139 140 |
# File 'lib/generators/hyrax/install_generator.rb', line 138 def copy_helper copy_file 'hyrax_helper.rb', 'app/helpers/hyrax_helper.rb' end |
#create_workflow ⇒ Object
90 91 92 93 |
# File 'lib/generators/hyrax/install_generator.rb', line 90 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
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/generators/hyrax/install_generator.rb', line 169 def datatables javascript_manifest = 'app/assets/javascripts/application.js' insert_into_file javascript_manifest, after: /jquery.?\n/ do "//= require jquery.dataTables\n" \ "//= require dataTables.bootstrap4\n" end insert_into_file 'app/assets/stylesheets/application.css', before: ' *= require_self' do " *= require dataTables.bootstrap4\n" end end |
#dotenv ⇒ Object
208 209 210 211 212 213 |
# File 'lib/generators/hyrax/install_generator.rb', line 208 def dotenv copy_file '.env' gem_group :development, :test do gem 'dotenv-rails', '~> 2.8' end end |
#health_check ⇒ Object
185 186 187 |
# File 'lib/generators/hyrax/install_generator.rb', line 185 def health_check generate 'hyrax:health_check' unless [:'skip-health-check'] end |
#inject_ability ⇒ Object
we’re going to inject this into the local app, so that it’s easy to disable.
108 109 110 111 112 113 |
# File 'lib/generators/hyrax/install_generator.rb', line 108 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
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/generators/hyrax/install_generator.rb', line 122 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_listeners ⇒ Object
add listener code to provide developers a hint that listening to events is a good development pattern
117 118 119 |
# File 'lib/generators/hyrax/install_generator.rb', line 117 def inject_listeners generate "hyrax:listeners" end |
#inject_required_seeds ⇒ Object
146 147 148 149 150 |
# File 'lib/generators/hyrax/install_generator.rb', line 146 def inject_required_seeds insert_into_file 'db/seeds.rb' do 'Hyrax::RequiredDataSeeder.new.generate_seed_data' end end |
#inject_routes ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/generators/hyrax/install_generator.rb', line 63 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 BlacklightDynamicSitemap::Engine => '/'\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
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/generators/hyrax/install_generator.rb', line 78 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_application_config ⇒ Object
193 194 195 196 197 |
# File 'lib/generators/hyrax/install_generator.rb', line 193 def insert_application_config insert_into_file 'config/application.rb', after: /config\.load_defaults [0-9.]+$/ do "\n config.active_job.queue_adapter = ENV.fetch('HYRAX_ACTIVE_JOB_QUEUE') { 'async' }.to_sym\n" end end |
#insert_builder ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/generators/hyrax/install_generator.rb', line 54 def insert_builder insert_into_file 'app/models/search_builder.rb', after: /include Blacklight::Solr::SearchBuilderBehavior/ do "\n # Add a filter query to restrict the search to documents the current user has access to\n"\ " include Hydra::AccessControlsEnforcement\n"\ " include Hyrax::SearchFilters\n" end end |
#install_assets ⇒ Object
152 153 154 |
# File 'lib/generators/hyrax/install_generator.rb', line 152 def install_assets generate "hyrax:assets" end |
#install_blacklight_gallery ⇒ Object
162 163 164 165 166 167 |
# File 'lib/generators/hyrax/install_generator.rb', line 162 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
95 96 97 |
# File 'lib/generators/hyrax/install_generator.rb', line 95 def install_config generate "hyrax:config" end |
#install_mailboxer ⇒ Object
99 100 101 |
# File 'lib/generators/hyrax/install_generator.rb', line 99 def install_mailboxer generate "mailboxer:install" end |
#lando ⇒ Object
204 205 206 |
# File 'lib/generators/hyrax/install_generator.rb', line 204 def lando copy_file '.lando.yml' end |
#noid_rails_database_minter_initialize ⇒ Object
181 182 183 |
# File 'lib/generators/hyrax/install_generator.rb', line 181 def noid_rails_database_minter_initialize generate 'noid:rails:install' end |
#qa_tables ⇒ Object
142 143 144 |
# File 'lib/generators/hyrax/install_generator.rb', line 142 def qa_tables generate 'qa:local:tables' end |
#replace_blacklight_layout ⇒ Object
49 50 51 52 |
# File 'lib/generators/hyrax/install_generator.rb', line 49 def replace_blacklight_layout gsub_file 'app/controllers/application_controller.rb', /layout :determine_layout.+$/, "include Hyrax::ThemedLayoutController\n with_themed_layout '1_column'\n" end |
#riiif_image_server ⇒ Object
189 190 191 |
# File 'lib/generators/hyrax/install_generator.rb', line 189 def riiif_image_server generate 'hyrax:riiif' unless [:'skip-riiif'] end |
#run_required_generators ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/generators/hyrax/install_generator.rb', line 40 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' : ''}" generate 'browse_everything:config' end |
#universalviewer_files ⇒ Object
199 200 201 202 |
# File 'lib/generators/hyrax/install_generator.rb', line 199 def universalviewer_files rake('hyrax:universal_viewer:install') rake('yarn:install') end |
#use_browser_validations ⇒ Object
156 157 158 159 160 |
# File 'lib/generators/hyrax/install_generator.rb', line 156 def use_browser_validations gsub_file 'config/initializers/simple_form.rb', /browser_validations = false/, 'browser_validations = true' end |