class NewspaperWorks::InstallGenerator

Install Generator Class

Public Instance Methods

add_helper() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 89
def add_helper
  copy_file "newspaper_works_helper.rb", "app/helpers/newspaper_works_helper.rb"
end
add_solr_doc() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 36
def add_solr_doc
  inject_into_file 'app/models/solr_document.rb',
                   after: "include Hyrax::SolrDocumentBehavior" do
    "\n  include NewspaperWorks::Solr::Document\n"
  end
end
advanced_search_configuration() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 66
def advanced_search_configuration
  generate 'newspaper_works:blacklight_advanced_search'
end
catalog_controller_configuration() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 81
def catalog_controller_configuration
  generate 'newspaper_works:catalog_controller'
end
copy_migrations() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 8
def copy_migrations
  rake "newspaper_works:install:migrations"
end
iiif_configuration() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 51
def iiif_configuration
  generate 'newspaper_works:blacklight_iiif_search'
end
inject_assets() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 93
def inject_assets
  generate 'newspaper_works:assets'
end
inject_authorities() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 70
def inject_authorities
  inject_into_file 'config/authorities/resource_types.yml',
                   after: "term: Masters Thesis\n" do
    "  - id: Microfilm\n" \
    "    term: Microfilm\n" \
    "  - id: Newspaper\n" \
    "    term: Newspaper\n"
  end
  copy_file "config/authorities/newspaper_article_genres.yml"
end
inject_configuration() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 85
def inject_configuration
  copy_file 'config/initializers/newspaper_works.rb'
end
inject_routes() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 29
def inject_routes
  inject_into_file 'config/routes.rb',
                   after: "Rails.application.routes.draw do\n" do
    "\n  mount NewspaperWorks::Engine => '/'\n"
  end
end
register_worktypes() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 12
def register_worktypes
  inject_into_file 'config/initializers/hyrax.rb',
                   after: "Hyrax.config do |config|\n" do
    "  # Configuration generated by `rails g newspaper_works:install`\n" \
      "  config.register_curation_concern :newspaper_article\n" \
      "  config.register_curation_concern :newspaper_container\n" \
      "  config.register_curation_concern :newspaper_issue\n" \
      "  config.register_curation_concern :newspaper_page\n" \
      "  config.register_curation_concern :newspaper_title\n" \
      "  config.callback.set(:after_create_fileset) do |file_set, user|\n" \
      "    require 'newspaper_works'\n" \
      "    NewspaperWorks::Data.handle_after_create_fileset(file_set, user)\n" \
      "  end\n" \
      "  #== END GENERATED newspaper_works CONFIG ==\n\n"
  end
end
verify_biiif_installed() click to toggle source
# File lib/generators/newspaper_works/install_generator.rb, line 43
def verify_biiif_installed
  return if IO.read('app/controllers/catalog_controller.rb').include?('include BlacklightIiifSearch::Controller')
  say_status('info',
             'BLACKLIGHT IIIF SEARCH NOT INSTALLED; INSTALLING BLACKLIGHT IIIF SEARCH',
             :blue)
  generate 'blacklight_iiif_search:install'
end
verify_blacklight_adv_search_installed() click to toggle source

NOTE: BlacklightAdvancedSearch generator installs a view partial by default, remove it after install, unless app has already customized that view partial

# File lib/generators/newspaper_works/install_generator.rb, line 57
def verify_blacklight_adv_search_installed
  return if IO.read('app/controllers/catalog_controller.rb').include?('include BlacklightAdvancedSearch::Controller')
  say_status('info', 'INSTALLING BLACKLIGHT ADVANCED SEARCH', :blue)
  search_form_path = 'app/views/catalog/_search_form.html.erb'
  existing_search_form = File.exist?(search_form_path) ? true : false
  generate 'blacklight_advanced_search:install', '--force'
  remove_file search_form_path unless existing_search_form
end