Class: CdmMigrator::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CdmMigrator::InstallGenerator
- Defined in:
- lib/generators/cdm_migrator/install/install_generator.rb
Instance Method Summary collapse
- #inject_content_dm_yml ⇒ Object
- #inject_dashboard_link ⇒ Object
- #inject_menu_presenter ⇒ Object
- #inject_stylesheets ⇒ Object
Instance Method Details
#inject_content_dm_yml ⇒ Object
67 68 69 |
# File 'lib/generators/cdm_migrator/install/install_generator.rb', line 67 def inject_content_dm_yml copy_file("config/cdm_migrator.yml", "config/cdm_migrator.yml") unless File.file?("config/cdm_migrator.yml") end |
#inject_dashboard_link ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/cdm_migrator/install/install_generator.rb', line 4 def inject_dashboard_link file_path = "app/views/hyrax/dashboard/sidebar/_tasks.html.erb" if File.file?(file_path) title = "<li class=\"h5\"><%= t('hyrax.admin.sidebar.tasks') %></li>" perm = " <% if can? :review, :submissions %>" gsub_file file_path,/[ \t]*(<li class="h5"><%= t\('hyrax\.admin\.sidebar\.tasks'\) %><\/li>)\n[\s\S]*[ \t]*(<% if can\? :review, :submissions %>)\n/ do |match| "" end gsub_file file_path,/[ \t]*(<% if can\? :review, :submissions %>)\n[\s\S]*[ \t]*(<li class="h5"><%= t\('hyrax\.admin\.sidebar\.tasks'\) %><\/li>)\n/ do |match| "" end prepend_to_file file_path do title + "\n" \ "<li>\n" \ " <%= menu.collapsable_section t('CDM Migrator'),\n" \ " icon_class: \"fa fa-map-signs\",\n" \ " id: 'collapseCdmMigrator',\n" \ " open: menu.cdm_migrator_section? do %>\n" \ " <%= menu.nav_link(main_app.cdm_start_path) do %>\n" \ " <span class=\"fa fa-map\"></span> <span class=\"sidebar-action-text\"><%= t('CDM Mapping Tool') %></span>\n" \ " <% end %>\n" \ " <%= menu.nav_link(main_app.csv_checker_path) do %>\n" \ " <span class=\"fa fa-check-circle\"></span><span>CSV Checker</span>\n" \ " <% end %>\n" \ " <%= menu.nav_link(main_app.csv_upload_path) do %>\n"\ " <span class=\"fa fa-angle-double-up\"></span> <span class=\"sidebar-action-text\"><%= t('CSV Batch Uploader') %></span>\n" \ " <% end %>\n" \ " <%= menu.nav_link(main_app.csv_my_batches_path) do %>\n" \ " <span class=\"fa fa-database\"></span> <span class=\"sidebar-action-text\"><%= t('Batches') %></span>\n" \ " <% end %>\n" \ " <% end %>\n" \ " </li>\n" + perm + "\n" end else copy_file "sidebar/_tasks.html.erb", "app/views/hyrax/dashboard/sidebar/_tasks.html.erb" end end |
#inject_menu_presenter ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/generators/cdm_migrator/install/install_generator.rb', line 43 def hyku_file_path = "app/presenters/hyku/menu_presenter.rb" hyrax_file_path = "app/presenters/hyrax/menu_presenter.rb" if File.file?(hyku_file_path) && File.readlines(hyku_file_path).join.include?("cdm_migrator_section") insert_into_file hyku_file_path, :after => /def settings_section\?\n.*\(controller_name\)\n[ \t]*end/ do "\n\n" \ " def cdm_migrator_section?\n" \ " %w[cdm csv].include?(controller_name)\n" \ " end\n" end elsif File.file?(hyrax_file_path) && File.readlines(hyrax_file_path).join.include?("cdm_migrator_section") insert_into_file hyrax_file_path, :after => /def settings_section\?\n.*\(controller_name\)\n[ \t]*end/ do "\n\n" \ " def cdm_migrator_section?\n" \ " %w[cdm csv].include?(controller_name)\n" \ " end\n" end elsif Hyku copy_file "presenters/hyku/menu_presenter.rb", "app/presenters/hyku/menu_presenter.rb" elsif Hyrax copy_file "presenters/hyrax/menu_presenter.rb", "app/presenters/hyrax/menu_presenter.rb" end end |
#inject_stylesheets ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/generators/cdm_migrator/install/install_generator.rb', line 71 def inject_stylesheets css_file_path = "app/assets/stylesheets/application.css" copy_file("stylesheets/csv_checker.css", "app/assets/stylesheets/csv_checker.css") unless File.file?("app/assets/styelsheets/csv_checker.css") insert_into_file css_file_path, :before => " *= require_self\n" do " *= require csv_checker\n " end end |