mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-08 21:06:24 +08:00
Merge branch 'images_not_imported_SCI1807' of https://github.com/Zanz2/scinote-web into images_not_imported_SCI1807
This commit is contained in:
commit
020e9ddc16
3 changed files with 36 additions and 12 deletions
|
@ -146,12 +146,17 @@ module ProtocolsIoHelper
|
||||||
Nokogiri::HTML::DocumentFragment.parse(text).to_html
|
Nokogiri::HTML::DocumentFragment.parse(text).to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_for_view(attribute_text1, size, table = 'no_table')
|
# Images are allowed in:
|
||||||
|
# Step: description, expected result
|
||||||
|
# Protocol description : description before_start warning guidelines manuscript_citation
|
||||||
|
def prepare_for_view(attribute_text1, size, table = 'no_table', image_allowed = false)
|
||||||
|
image_tag = Array(nil)
|
||||||
|
image_tag = Array('img') if image_allowed
|
||||||
if table == 'no_table'
|
if table == 'no_table'
|
||||||
attribute_text = sanitize_input(not_null(attribute_text1))
|
attribute_text = sanitize_input(not_null(attribute_text1),image_tag)
|
||||||
elsif table == 'table'
|
elsif table == 'table'
|
||||||
attribute_text = sanitize_input(
|
attribute_text = sanitize_input(
|
||||||
string_html_table_remove(not_null(attribute_text1))
|
string_html_table_remove(not_null(attribute_text1)),image_tag
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
pio_eval_len(
|
pio_eval_len(
|
||||||
|
@ -189,7 +194,9 @@ module ProtocolsIoHelper
|
||||||
br +
|
br +
|
||||||
prepare_for_view(
|
prepare_for_view(
|
||||||
iterating_key,
|
iterating_key,
|
||||||
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
|
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,
|
||||||
|
'no_table',
|
||||||
|
true
|
||||||
) +
|
) +
|
||||||
br
|
br
|
||||||
else
|
else
|
||||||
|
@ -208,7 +215,9 @@ module ProtocolsIoHelper
|
||||||
append =
|
append =
|
||||||
t('protocols.protocols_io_import.comp_append.expected_result') +
|
t('protocols.protocols_io_import.comp_append.expected_result') +
|
||||||
prepare_for_view(
|
prepare_for_view(
|
||||||
iterating_key, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
|
iterating_key, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,
|
||||||
|
'no_table',
|
||||||
|
true
|
||||||
) +
|
) +
|
||||||
'<br>'
|
'<br>'
|
||||||
return append
|
return append
|
||||||
|
@ -235,13 +244,18 @@ module ProtocolsIoHelper
|
||||||
( before_start warning guidelines manuscript_citation publish_date
|
( before_start warning guidelines manuscript_citation publish_date
|
||||||
vendor_name vendor_link keywords tags link created_on )
|
vendor_name vendor_link keywords tags link created_on )
|
||||||
]
|
]
|
||||||
|
allowed_image_attributes = %w[
|
||||||
|
( before_start warning guidelines manuscript_citation )
|
||||||
|
]
|
||||||
description_string =
|
description_string =
|
||||||
if json_hash['description'].present?
|
if json_hash['description'].present?
|
||||||
'<strong>' + t('protocols.protocols_io_import.preview.description') +
|
'<strong>' + t('protocols.protocols_io_import.preview.description') +
|
||||||
'</strong>' +
|
'</strong>' +
|
||||||
prepare_for_view(
|
prepare_for_view(
|
||||||
json_hash['description'],
|
json_hash['description'],
|
||||||
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
|
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
|
||||||
|
'no_table',
|
||||||
|
true
|
||||||
).html_safe
|
).html_safe
|
||||||
else
|
else
|
||||||
'<strong>' + t('protocols.protocols_io_import.preview.description') +
|
'<strong>' + t('protocols.protocols_io_import.preview.description') +
|
||||||
|
@ -274,12 +288,16 @@ module ProtocolsIoHelper
|
||||||
description_string += '<br>'
|
description_string += '<br>'
|
||||||
elsif json_hash[e].present?
|
elsif json_hash[e].present?
|
||||||
new_e = '<strong>' + e.humanize + '</strong>'
|
new_e = '<strong>' + e.humanize + '</strong>'
|
||||||
|
|
||||||
|
image_tag = Array(nil)
|
||||||
|
image_tag = Array('img') if allowed_image_attributes.include? e
|
||||||
description_string +=
|
description_string +=
|
||||||
new_e.to_s + ': ' +
|
new_e.to_s + ': ' +
|
||||||
pio_eval_prot_desc(
|
pio_eval_prot_desc(
|
||||||
sanitize_input(json_hash[e]),
|
sanitize_input(json_hash[e],image_tag),
|
||||||
e
|
e
|
||||||
).html_safe + '<br>'
|
).html_safe + '<br>'
|
||||||
|
# Problematicno, image_tag_testing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
description_string
|
description_string
|
||||||
|
@ -298,8 +316,8 @@ module ProtocolsIoHelper
|
||||||
newj['0']['name'] = 'Protocol info'
|
newj['0']['name'] = 'Protocol info'
|
||||||
@remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH
|
@remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH
|
||||||
newj['0']['tables'], table_str = protocolsio_string_to_table_element(
|
newj['0']['tables'], table_str = protocolsio_string_to_table_element(
|
||||||
sanitize_input(protocols_io_fill_desc(original_json).html_safe)
|
sanitize_input(protocols_io_fill_desc(original_json).html_safe,Array('img'))
|
||||||
)
|
) # Problematicno image_tag_testing
|
||||||
newj['0']['description'] = table_str
|
newj['0']['description'] = table_str
|
||||||
original_json['steps'].each_with_index do |step, pos_orig| # loop over steps
|
original_json['steps'].each_with_index do |step, pos_orig| # loop over steps
|
||||||
i = pos_orig + 1
|
i = pos_orig + 1
|
||||||
|
|
|
@ -32,8 +32,12 @@
|
||||||
publish_date: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,
|
publish_date: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,
|
||||||
link: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG,
|
link: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG,
|
||||||
vendor_link: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG } %>
|
vendor_link: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG } %>
|
||||||
|
<% allowed_image_attributes = %w[
|
||||||
|
( description before_start warning guidelines manuscript_citation )
|
||||||
|
] %>
|
||||||
<% protocol_attr_len_hash.each do |element, value|%>
|
<% protocol_attr_len_hash.each do |element, value|%>
|
||||||
<% element = element.to_s %>
|
<% element = element.to_s %>
|
||||||
|
|
||||||
<% if(json_object[element].present?) %>
|
<% if(json_object[element].present?) %>
|
||||||
<% if element == 'tags' %>
|
<% if element == 'tags' %>
|
||||||
<% translation_string = 'protocols.protocols_io_import.preview.' + element %>
|
<% translation_string = 'protocols.protocols_io_import.preview.' + element %>
|
||||||
|
@ -47,7 +51,9 @@
|
||||||
<% prot_info_string += not_null(json_object[element]) if add_to_info_string_elements.include? element %>
|
<% prot_info_string += not_null(json_object[element]) if add_to_info_string_elements.include? element %>
|
||||||
<% translation_string = 'protocols.protocols_io_import.preview.' + element %>
|
<% translation_string = 'protocols.protocols_io_import.preview.' + element %>
|
||||||
<strong><%= t(translation_string) %></strong>
|
<strong><%= t(translation_string) %></strong>
|
||||||
<%= prepare_for_view(json_object[element],protocol_attr_len_hash[element.to_sym],'table').html_safe %>
|
<% image_tag = false %>
|
||||||
|
<% image_tag = true if allowed_image_attributes.include? element %>
|
||||||
|
<%= prepare_for_view(json_object[element],protocol_attr_len_hash[element.to_sym],'table',true).html_safe %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<br>
|
<br>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -43,13 +43,13 @@
|
||||||
<% step_info_string += (key['data']) %>
|
<% step_info_string += (key['data']) %>
|
||||||
<br>
|
<br>
|
||||||
<strong><%= t('protocols.protocols_io_import.preview.strng_s_desc') %></strong>
|
<strong><%= t('protocols.protocols_io_import.preview.strng_s_desc') %></strong>
|
||||||
<%= prepare_for_view(key['data'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
|
<%= prepare_for_view(key['data'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table',true).html_safe %>
|
||||||
<br>
|
<br>
|
||||||
<% when '17' %>
|
<% when '17' %>
|
||||||
<% step_info_string += (key['data']) %>
|
<% step_info_string += (key['data']) %>
|
||||||
<br>
|
<br>
|
||||||
<strong><%= t('protocols.protocols_io_import.preview.s_exp_res') %></strong>
|
<strong><%= t('protocols.protocols_io_import.preview.s_exp_res') %></strong>
|
||||||
<%= prepare_for_view(key['data'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
|
<%= prepare_for_view(key['data'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table',true).html_safe %>
|
||||||
<br>
|
<br>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif key && whitelist_complex.include?(key['component_type_id']) %>
|
<% elsif key && whitelist_complex.include?(key['component_type_id']) %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue