diff --git a/Gemfile b/Gemfile index b523846fa..c5ad68913 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'sneaky-save', git: 'https://github.com/einzige/sneaky-save' gem 'turbolinks', '~> 5.1.1' gem 'underscore-rails' gem 'wicked_pdf', '~> 1.1.0' -gem 'wkhtmltopdf-heroku' +gem 'wkhtmltopdf-heroku', '2.12.4' gem 'aws-sdk-rails' gem 'aws-sdk-s3' diff --git a/Gemfile.lock b/Gemfile.lock index c2297e6d7..81e522c6c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -558,7 +558,7 @@ GEM websocket-extensions (0.1.4) whacamole (1.2.0) wicked_pdf (1.1.0) - wkhtmltopdf-heroku (2.12.5.0) + wkhtmltopdf-heroku (2.12.4.0) xpath (3.2.0) nokogiri (~> 1.8) yomu (0.2.4) @@ -671,7 +671,7 @@ DEPENDENCIES webpacker (~> 3.5) whacamole wicked_pdf (~> 1.1.0) - wkhtmltopdf-heroku + wkhtmltopdf-heroku (= 2.12.4) yomu RUBY VERSION diff --git a/app/assets/javascripts/protocols/import_export/import.js b/app/assets/javascripts/protocols/import_export/import.js index e439dcac2..74fa9baac 100644 --- a/app/assets/javascripts/protocols/import_export/import.js +++ b/app/assets/javascripts/protocols/import_export/import.js @@ -500,7 +500,14 @@ function importProtocolFromFile( var tinyMceAsset = {}; var fileRef = $(this).attr('fileRef'); tinyMceAsset.tokenId = $(this).attr('tokenId'); + tinyMceAsset.fileName = $(this).children('fileName').text(); tinyMceAsset.fileType = $(this).children('fileType').text(); + if ($(this).children('fileMetadata').html() !== undefined) { + tinyMceAsset.fileMetadata = $(this).children('fileMetadata').html() + .replace('', '') + .replace(']]>', ''); + } tinyMceAsset.bytes = getAssetBytes( protocolFolders[index], stepGuid, @@ -579,6 +586,12 @@ function importProtocolFromFile( stepAssetJson.id = assetId; stepAssetJson.fileName = fileName; stepAssetJson.fileType = $(this).children('fileType').text(); + if ($(this).children('fileMetadata').html() !== undefined) { + stepAssetJson.fileMetadata = $(this).children('fileMetadata').html() + .replace('', '') + .replace(']]>', ''); + } stepAssetJson.bytes = getAssetBytes( protocolFolders[index], stepGuid, diff --git a/app/models/concerns/tiny_mce_images.rb b/app/models/concerns/tiny_mce_images.rb index b5cc990f2..02f5e9b53 100644 --- a/app/models/concerns/tiny_mce_images.rb +++ b/app/models/concerns/tiny_mce_images.rb @@ -18,7 +18,7 @@ module TinyMceImages description = TinyMceAsset.update_old_tinymce(description, self) tiny_mce_assets.each do |tm_asset| - tm_asset_key = tm_asset.image.preview.key + tm_asset_key = tm_asset.preview.key encoded_tm_asset = Base64.strict_encode64(tm_asset.image.service.download(tm_asset_key)) new_tm_asset_src = "data:image/jpg;base64,#{encoded_tm_asset}" html_description = Nokogiri::HTML(description) diff --git a/app/models/tiny_mce_asset.rb b/app/models/tiny_mce_asset.rb index 6f44bb22f..32ecac93e 100644 --- a/app/models/tiny_mce_asset.rb +++ b/app/models/tiny_mce_asset.rb @@ -139,10 +139,9 @@ class TinyMceAsset < ApplicationRecord if exists? order(:id).each do |tiny_mce_asset| asset_guid = get_guid(tiny_mce_asset.id) - asset_file_name = "rte-#{asset_guid.to_s + tiny_mce_asset.image.blob.filename.extension}" + asset_file_name = "rte-#{asset_guid}.#{tiny_mce_asset.image.blob.filename.extension}" ostream.put_next_entry("#{dir}/#{asset_file_name}") ostream.print(tiny_mce_asset.image.download) - input_file.close end end ostream diff --git a/app/utilities/protocols_exporter.rb b/app/utilities/protocols_exporter.rb index f63d31246..1c05dfa02 100644 --- a/app/utilities/protocols_exporter.rb +++ b/app/utilities/protocols_exporter.rb @@ -56,6 +56,7 @@ module ProtocolsExporter "fileRef=\"#{asset_file_name}\">\n" asset_xml << "#{img.file_name}\n" asset_xml << "#{img.content_type}\n" + asset_xml << "\n" asset_xml << "\n" tiny_assets_xml << asset_xml end @@ -104,6 +105,7 @@ module ProtocolsExporter "fileRef=\"#{asset_file_name}\">\n" asset_xml << "#{asset.file_name}\n" asset_xml << "#{asset.content_type}\n" + asset_xml << "\n" asset_xml << "\n" step_xml << asset_xml end diff --git a/app/utilities/protocols_importer.rb b/app/utilities/protocols_importer.rb index 13d0f1940..c4debc036 100644 --- a/app/utilities/protocols_importer.rb +++ b/app/utilities/protocols_importer.rb @@ -111,7 +111,10 @@ module ProtocolsImporter ) # Decode the file bytes - asset.file.attach(io: StringIO.new(Base64.decode64(asset_json['bytes'])), filename: asset_json['fileName']) + asset.file.attach(io: StringIO.new(Base64.decode64(asset_json['bytes'])), + filename: asset_json['fileName'], + content_type: asset_json['fileType'], + metadata: JSON.parse(asset_json['fileMetadata'] || '{}')) asset.save! asset_ids << asset.id @@ -153,8 +156,11 @@ module ProtocolsImporter tiny_mce_img.save! # Decode the file bytes - tiny_mce_img.image.attach(io: StringIO.new(Base64.decode64(tiny_mce_img_json['bytes'])), - filename: tiny_mce_img_json['fileName']) + file = StringIO.new(Base64.decode64(tiny_mce_img_json['bytes'])) + tiny_mce_img.image.attach(io: file, + filename: tiny_mce_img_json['fileName'], + content_type: tiny_mce_img_json['fileType'], + metadata: JSON.parse(tiny_mce_img_json['fileMetadata'] || '{}')) if description.gsub!("data-mce-token=\"#{tiny_mce_img_json['tokenId']}\"", "data-mce-token=\"#{Base62.encode(tiny_mce_img.id)}\"") else