From 2ccaccaced4f42eecf320b639e0a82a46efe2c3f Mon Sep 17 00:00:00 2001 From: Julie Allinson Date: Mon, 29 Apr 2019 09:23:45 +0000 Subject: [PATCH] add universal_viewer install task --- lib/generators/hyrax/install_generator.rb | 4 +--- lib/tasks/universal_viewer.rake | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 lib/tasks/universal_viewer.rake diff --git a/lib/generators/hyrax/install_generator.rb b/lib/generators/hyrax/install_generator.rb index d87b23f4d5..9352aa866f 100644 --- a/lib/generators/hyrax/install_generator.rb +++ b/lib/generators/hyrax/install_generator.rb @@ -174,9 +174,7 @@ def riiif_image_server end def universalviewer_files - copy_file 'package.json', 'package.json' - copy_file 'uv.html', 'config/uv/uv.html' - copy_file 'uv-config.json', 'config/uv/uv-config.json' + rake('hyrax:universal_viewer:install') end # Blacklight::Controller will by default add an after_action filter to discard all flash messages on xhr requests. diff --git a/lib/tasks/universal_viewer.rake b/lib/tasks/universal_viewer.rake new file mode 100644 index 0000000000..76cb04e355 --- /dev/null +++ b/lib/tasks/universal_viewer.rake @@ -0,0 +1,15 @@ +namespace :hyrax do + namespace :universal_viewer do + desc "Install Universal Viewer" + task install: :environment do + # Copy the files into place + hyrax_templates_path = File.join(Gem.loaded_specs['hyrax'].full_gem_path, 'lib', 'generators', 'hyrax', 'templates') + copy_file File.join(hyrax_templates_path, 'package.json'), Rails.root.join('package.json') + Dir.mkdir(Rails.root.join('config', 'uv')) unless File.exist?(Rails.root.join('config', 'uv')) + copy_file File.join(hyrax_templates_path, 'uv.html'), Rails.root.join('config', 'uv', 'uv.html') + copy_file File.join(hyrax_templates_path, 'uv-config.json'), Rails.root.join('config', 'uv', 'uv-config.json') + + puts 'Universal Viewer (UV) configs copied into place, install UV by running yarn install or rake assets:precompile' + end + end +end