mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 07:26:15 +08:00
Code for protocol repository scinote table elements view
This commit is contained in:
parent
79e0a11054
commit
a732c8afa7
|
@ -1091,10 +1091,61 @@ class ProtocolsController < ApplicationController
|
|||
newj[i.to_s]['description'] += pio_stp_19(key['source_data'])
|
||||
end # case end
|
||||
end # finished looping over step components
|
||||
newj[i.to_s]['tables'], table_str = protocolsio_string_to_table_element(
|
||||
newj[i.to_s]['description']
|
||||
)
|
||||
newj[i.to_s]['description'] = table_str
|
||||
end # steps
|
||||
newj
|
||||
end
|
||||
|
||||
def protocolsio_string_to_table_element(description_string)
|
||||
description_string.delete! "\n"
|
||||
description_string.delete! "\t"
|
||||
description_string.delete! "\r"
|
||||
description_string.delete! "\f"
|
||||
table_whole_regex = %r{(<table\b[^>]*>.*?<\/table>)}m
|
||||
table_regex = %r{<table\b[^>]*>(.*?)<\/table>}m
|
||||
tr_regex = %r{<tr\b[^>]*>(.*?)<\/tr>}m
|
||||
td_regex = %r{<td\b[^>]*>(.*?)<\/td>}m
|
||||
table_pattern_array = description_string.scan(table_whole_regex)
|
||||
string_without_tables = description_string
|
||||
table_pattern_array.each do |table_pattern|
|
||||
string_without_tables = string_without_tables.gsub(
|
||||
table_pattern[0],
|
||||
t('protocols.protocols_io_import.comp_append.table_moved').html_safe
|
||||
)
|
||||
end
|
||||
tables = {}
|
||||
table_counter = 0
|
||||
table_strings = description_string.scan(table_regex)
|
||||
table_strings.each do |table|
|
||||
tables[table_counter.to_s] = {}
|
||||
tr_counter = 0
|
||||
tr_strings = table[0].scan(tr_regex)
|
||||
contents = {}
|
||||
contents['data'] = []
|
||||
tr_strings.each do |tr|
|
||||
td_counter = 0
|
||||
td_strings = tr[0].scan(td_regex)
|
||||
contents['data'][tr_counter] = []
|
||||
td_strings.each do |td|
|
||||
contents['data'][tr_counter].push(td[0])
|
||||
td_counter += 1
|
||||
break if td_counter >= 5
|
||||
end
|
||||
tr_counter += 1
|
||||
end
|
||||
tables[table_counter.to_s]['contents'] = Base64.encode64(
|
||||
contents.to_s.sub('=>', ':')
|
||||
)
|
||||
tables[table_counter.to_s]['name'] = nil
|
||||
table_counter += 1
|
||||
end
|
||||
# return string_without_tables, tables
|
||||
return tables, string_without_tables
|
||||
end
|
||||
|
||||
def move_protocol(action)
|
||||
rollbacked = false
|
||||
results = []
|
||||
|
|
|
@ -28,10 +28,6 @@
|
|||
<strong><%= t('protocols.protocols_io_import.preview.guideln') %></strong>
|
||||
<%= sanitize_input(json_object['guidelines'].html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['link'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.p_link') %></strong>
|
||||
<%= sanitize_input(json_object['link'].html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['manuscript_citation'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.manu_cit') %></strong>
|
||||
<%= sanitize_input(json_object['manuscript_citation'].html_safe) %><br>
|
||||
|
@ -58,6 +54,10 @@
|
|||
<%= sanitize_input(tag['tag_name'])+' , ' %><br>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if json_object['link'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.p_link') %></strong>
|
||||
<%= sanitize_input(json_object['link'].html_safe) %><br>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1390,7 +1390,7 @@ en:
|
|||
b_s_p: "Before starting protocol information:"
|
||||
warn: "Protocol warning:"
|
||||
guideln: "Guidelines:"
|
||||
p_link: "Supplied link:"
|
||||
p_link: "Link:"
|
||||
s_nobr_link: "Link:"
|
||||
s_link: "Link:"
|
||||
s_desc: "Description:"
|
||||
|
@ -1409,6 +1409,7 @@ en:
|
|||
key_wrd: "Keywords:"
|
||||
tags: "Tags:"
|
||||
comp_append:
|
||||
table_moved: "<br><strong>There was a table here, it was moved to the end of this step. </strong>"
|
||||
missing_step: "Step"
|
||||
missing_desc: "Description missing"
|
||||
general_link: "<br>Link: "
|
||||
|
@ -1426,7 +1427,7 @@ en:
|
|||
desc: "<br>Description: "
|
||||
os: "<br>OS name , OS version: "
|
||||
sub_protocol:
|
||||
title: "<br><strong>This protocol also contains an attached sub-protocol: </strong>"
|
||||
title: "<br><strong>This step also contains an attached sub-protocol: </strong>"
|
||||
author: "<br>Author: "
|
||||
safety_infor:
|
||||
title: "<br><strong>Safety information: </strong>"
|
||||
|
|
Loading…
Reference in a new issue