mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 20:48:23 +08:00
Merge branch 'activestorage_migration' into features/marvinjs-integration
This commit is contained in:
commit
3b7f715e0b
7 changed files with 29 additions and 9 deletions
2
Gemfile
2
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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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('<!--[CDATA[', '')
|
||||
.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('<!--[CDATA[', '')
|
||||
.replace(' ]]-->', '')
|
||||
.replace(']]>', '');
|
||||
}
|
||||
stepAssetJson.bytes = getAssetBytes(
|
||||
protocolFolders[index],
|
||||
stepGuid,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -56,6 +56,7 @@ module ProtocolsExporter
|
|||
"fileRef=\"#{asset_file_name}\">\n"
|
||||
asset_xml << "<fileName>#{img.file_name}</fileName>\n"
|
||||
asset_xml << "<fileType>#{img.content_type}</fileType>\n"
|
||||
asset_xml << "<fileMetadata><!--[CDATA[ #{img.image.metadata.to_json} ]]--></fileMetadata>\n"
|
||||
asset_xml << "</tinyMceAsset>\n"
|
||||
tiny_assets_xml << asset_xml
|
||||
end
|
||||
|
@ -104,6 +105,7 @@ module ProtocolsExporter
|
|||
"fileRef=\"#{asset_file_name}\">\n"
|
||||
asset_xml << "<fileName>#{asset.file_name}</fileName>\n"
|
||||
asset_xml << "<fileType>#{asset.content_type}</fileType>\n"
|
||||
asset_xml << "<fileMetadata><!--[CDATA[ #{asset.file.metadata.to_json} ]]--></fileMetadata>\n"
|
||||
asset_xml << "</asset>\n"
|
||||
step_xml << asset_xml
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue