From e9ca2d96ada5ed68dfa5cade236bc30278aa8fa9 Mon Sep 17 00:00:00 2001 From: Eric O Date: Tue, 15 Aug 2023 14:39:53 -0400 Subject: [PATCH] Add poster resource for Hyacinth Assets; Webdriver updates to support modern versions of Google Chrome --- Gemfile | 4 +- Gemfile.lock | 21 +++---- .../models/digital_object/asset.js | 60 +++++++++++-------- .../widgets/digital_object_editor/_header.ejs | 21 +++++++ .../hyacinth/digital_objects/downloads.rb | 8 +++ app/controllers/digital_objects_controller.rb | 39 +++++++++++- .../digital_object/assets/file_import.rb | 42 ++++++++++++- app/models/digital_object/asset.rb | 32 +++++++++- config/routes.rb | 2 + lib/tasks/hyacinth/asset_zip.rake | 3 +- spec/requests/digital_objects_spec.rb | 56 ++++++++++++++++- 11 files changed, 243 insertions(+), 45 deletions(-) diff --git a/Gemfile b/Gemfile index 6b46a3049..66fb6d668 100644 --- a/Gemfile +++ b/Gemfile @@ -148,9 +148,9 @@ group :development, :test do gem 'rspec-rails', '~> 3.3' gem 'capybara', '~> 3.32' # For testing with chromedriver - gem 'selenium-webdriver', '~> 3.142' + gem 'selenium-webdriver', '~> 4.0' # For automatically updating chromedriver - gem 'webdrivers', '~> 4.0', require: false + gem 'webdrivers', '~> 5.3.0', require: false gem 'factory_girl_rails', '>= 4.4.1' gem 'rubocop', '~> 0.58.2', require: false gem 'rubocop-rspec', '>= 1.20.1', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 0b7c97aaa..926501bee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -142,8 +142,7 @@ GEM regexp_parser (~> 1.5) xpath (~> 3.2) charlock_holmes (0.7.6) - childprocess (2.0.0) - rake (< 13.0) + childprocess (4.1.0) chosen-rails (1.5.2) coffee-rails (>= 3.2) railties (>= 3.0) @@ -433,6 +432,7 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (2.1.0) + rexml (3.2.6) rsolr (1.1.2) builder (>= 2.1.2) rspec-core (3.3.2) @@ -470,7 +470,7 @@ GEM rubyXL (3.3.15) nokogiri (>= 1.4.4) rubyzip (>= 1.1.6) - rubyzip (1.2.3) + rubyzip (1.3.0) sass (3.5.6) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -485,8 +485,9 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) + selenium-webdriver (4.1.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) sequel (5.8.0) sinatra (1.4.8) @@ -557,10 +558,10 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - webdrivers (4.1.2) + webdrivers (5.3.1) nokogiri (~> 1.6) - rubyzip (~> 1.0) - selenium-webdriver (>= 3.0, < 4.0) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0, < 4.11) wowza-secure_token (0.0.1) xml-simple (1.1.5) xpath (3.2.0) @@ -628,7 +629,7 @@ DEPENDENCIES sass sass-rails sdoc - selenium-webdriver (~> 3.142) + selenium-webdriver (~> 4.0) solrizer (>= 3.4.1) spreadsheet sqlite3 (~> 1.3.10) @@ -637,7 +638,7 @@ DEPENDENCIES underscore-rails uri_service (= 0.5.5) web-console (~> 2.0) - webdrivers (~> 4.0) + webdrivers (~> 5.3.0) wowza-secure_token (= 0.0.1) BUNDLED WITH diff --git a/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js b/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js index 5fbbd937d..52734540e 100644 --- a/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js +++ b/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js @@ -1,87 +1,99 @@ // Asset - Subclass -Hyacinth.DigitalObjectsApp.DigitalObject.Asset = function(digital_object_data){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset = function (digital_object_data) { Hyacinth.DigitalObjectsApp.DigitalObject.Base.call(this, digital_object_data); // call parent constructor this.assetData = digital_object_data['asset_data']; }; Hyacinth.extendClass(Hyacinth.DigitalObjectsApp.DigitalObject.Asset, Hyacinth.DigitalObjectsApp.DigitalObject.Base); //Extend -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFilesystemLocation = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFilesystemLocation = function () { return this.assetData['filesystem_location']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getAccessCopyLocation = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getAccessCopyLocation = function () { return this.assetData['access_copy_location']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getServiceCopyLocation = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getPosterLocation = function () { + return this.assetData['poster_location']; +}; + +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getServiceCopyLocation = function () { return this.assetData['service_copy_location']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFileChecksum = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFileChecksum = function () { return this.assetData['checksum']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFileSizeInBytes = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFileSizeInBytes = function () { return this.assetData['file_size_in_bytes']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getAccessCopyFileSizeInBytes = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getAccessCopyFileSizeInBytes = function () { return this.assetData['access_copy_file_size_in_bytes']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getServiceCopyFileSizeInBytes = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getPosterFileSizeInBytes = function () { + return this.assetData['poster_file_size_in_bytes']; +}; + +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getServiceCopyFileSizeInBytes = function () { return this.assetData['service_copy_file_size_in_bytes']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFileSizeString = function() { +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getFileSizeString = function () { return this.bytesToSizeString(this.getFileSizeInBytes()); }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getAccessCopyFileSizeString = function() { +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getAccessCopyFileSizeString = function () { return this.bytesToSizeString(this.getAccessCopyFileSizeInBytes()); }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getServiceCopyFileSizeString = function() { +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getPosterFileSizeString = function () { + return this.bytesToSizeString(this.getPosterFileSizeInBytes()); +}; + +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getServiceCopyFileSizeString = function () { return this.bytesToSizeString(this.getServiceCopyFileSizeInBytes()); }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.bytesToSizeString = function(bytes) { +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.bytesToSizeString = function (bytes) { var sizeInBytes = parseInt(bytes); var value = sizeInBytes; var unit = 'B'; - if(sizeInBytes < 1000) { - return value + ' ' + unit; - } else if(sizeInBytes < 1000000) { - value = sizeInBytes/1000; + if (sizeInBytes < 1000) { + return value + ' ' + unit; + } else if (sizeInBytes < 1000000) { + value = sizeInBytes / 1000; unit = 'kB'; - } else if(sizeInBytes < 1000000000) { - value = sizeInBytes/1000000; + } else if (sizeInBytes < 1000000000) { + value = sizeInBytes / 1000000; unit = 'MB'; } else { - value = sizeInBytes/1000000000; + value = sizeInBytes / 1000000000; unit = ' GB'; } return parseFloat(parseFloat(value).toFixed(2)) + ' ' + unit; // the outermost parseFloat call removes trailing ".00" if present, but leaves values like ".01" }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getOriginalFilename = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getOriginalFilename = function () { return this.assetData['original_filename']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getOriginalFilePath = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getOriginalFilePath = function () { return this.assetData['original_file_path']; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.hasImage = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.hasImage = function () { return Hyacinth.imageServerUrl && this.getDcType() == 'StillImage'; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.isRestrictedSizeImage = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.isRestrictedSizeImage = function () { return this.hasRestrictions() && this.restrictions.restricted_size_image; }; -Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.isRestrictedOnsite = function(){ +Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.isRestrictedOnsite = function () { return this.hasRestrictions() && this.restrictions.restricted_onsite; }; diff --git a/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs b/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs index 5e85622b1..c03ca311b 100644 --- a/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs +++ b/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs @@ -232,6 +232,27 @@ <%= digitalObject.getAccessCopyLocation() == null ? 'N/A' : digitalObject.getAccessCopyLocation() %> +
+ +
+ <% if(digitalObject.getPosterLocation() == null) { %> + N/A + <% } else { %> + Download + (<%= digitalObject.getPosterFileSizeString() %>) [<%= digitalObject.getPosterFileSizeInBytes() %> bytes] + <% } %> +
+
+
+ +
+ <%= digitalObject.getPosterLocation() == null ? 'N/A' : digitalObject.getPosterLocation() %> +
+