Fixed pull request review

This commit is contained in:
Zanz2 2017-11-21 19:20:15 +01:00
parent 8226322e92
commit f577bf93b5
7 changed files with 87 additions and 159 deletions

View file

@ -261,6 +261,9 @@ var HelperModule = (function(){
} else if (type === 'info') {
alertType = ' alert-info ';
glyphSign = ' glyphicon-exclamation-sign ';
} else if (type === 'warning') {
alertType = ' alert-warning ';
glyphSign = ' glyphicon-exclamation-sign ';
}
var htmlSnippet = '<div class="alert alert' + alertType +
'alert-dismissable alert-floating">' +

View file

@ -959,10 +959,10 @@ class ProtocolsController < ApplicationController
br = '<br>'
append =
if iterating_key.present?
br + # Not sure why rubocop doesnt like this
br +
pio_eval_len(
sanitize_input(iterating_key),
ProtocolsIoHelper::PIO_S_DESC_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
br
else
@ -982,7 +982,7 @@ class ProtocolsController < ApplicationController
t('protocols.protocols_io_import.comp_append.expected_result') +
pio_eval_len(
sanitize_input(iterating_key),
ProtocolsIoHelper::PIO_S_EXPECTEDRESULT_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
'<br>'
return append
@ -1001,36 +1001,36 @@ class ProtocolsController < ApplicationController
append = t('protocols.protocols_io_import.comp_append.soft_packg.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_S_SOFT_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.soft_packg.dev') +
pio_eval_len(
sanitize_input(iterating_key['developer']),
ProtocolsIoHelper::PIO_S_SOFT_DEV_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.soft_packg.vers') +
pio_eval_len(
sanitize_input(iterating_key['version']),
ProtocolsIoHelper::PIO_S_SOFT_VERSION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_S_SOFT_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
) +
t('protocols.protocols_io_import.comp_append.soft_packg.repo') +
pio_eval_len(
sanitize_input(iterating_key['repository']),
ProtocolsIoHelper::PIO_S_SOFT_REPLINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
) +
t('protocols.protocols_io_import.comp_append.soft_packg.os') +
pio_eval_len(
sanitize_input(iterating_key['os_name']),
ProtocolsIoHelper::PIO_S_SOFT_OSNAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) + ' , ' +
pio_eval_len(
sanitize_input(iterating_key['os_version']),
ProtocolsIoHelper::PIO_S_SOFT_OSVERSION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
@ -1043,12 +1043,12 @@ class ProtocolsController < ApplicationController
append = t('protocols.protocols_io_import.comp_append.dataset.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_S_DATA_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_S_DATA_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
)
return append
end
@ -1063,22 +1063,22 @@ class ProtocolsController < ApplicationController
append = t('protocols.protocols_io_import.comp_append.command.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_S_COM_OSNAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.command.desc') +
pio_eval_len(
sanitize_input(iterating_key['description']),
ProtocolsIoHelper::PIO_S_COM_COMMAND_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.command.os') +
pio_eval_len(
sanitize_input(iterating_key['os_name']),
ProtocolsIoHelper::PIO_S_COM_OSNAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
' , ' +
pio_eval_len(
sanitize_input(iterating_key['os_version']),
ProtocolsIoHelper::PIO_S_COM_OSVERSION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
@ -1095,19 +1095,19 @@ class ProtocolsController < ApplicationController
) +
pio_eval_len(
sanitize_input(iterating_key['protocol_name']),
ProtocolsIoHelper::PIO_S_SUBPROT_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t(
'protocols.protocols_io_import.comp_append.sub_protocol.author'
) +
pio_eval_len(
sanitize_input(iterating_key['full_name']),
ProtocolsIoHelper::PIO_S_SUBPROT_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_S_SUBPROT_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
)
return append
end
@ -1123,12 +1123,12 @@ class ProtocolsController < ApplicationController
) +
pio_eval_len(
sanitize_input(iterating_key['body']),
ProtocolsIoHelper::PIO_S_SAFETY_INFO_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_S_SAFETY_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
)
return append
end
@ -1145,7 +1145,7 @@ class ProtocolsController < ApplicationController
'<strong>' + t('protocols.protocols_io_import.preview.prot_desc') +
'</strong>' + pio_eval_len(
sanitize_input(json_hash['description']),
ProtocolsIoHelper::PIO_P_DESC_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe
else
'<strong>' + t('protocols.protocols_io_import.preview.prot_desc') +
@ -1158,7 +1158,7 @@ class ProtocolsController < ApplicationController
description_string +=
new_e.to_s + ': ' + pio_eval_len(
sanitize_input(params['protocol']['created_at'].to_s),
ProtocolsIoHelper::PIO_P_CREATEDON_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) + '<br>'
elsif e == 'tags' && json_hash[e].any? && json_hash[e] != ''
new_e = '<strong>' + e.humanize + '</strong>'
@ -1171,7 +1171,7 @@ class ProtocolsController < ApplicationController
end
description_string += pio_eval_len(
tags_length_checker,
ProtocolsIoHelper::PIO_P_TAGS_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)
description_string += '<br>'
elsif json_hash[e].present?

View file

@ -3,105 +3,26 @@ module ProtocolsIoHelper
# Protocols.io limits
#=============================================================================
TEXT_MAX_LENGTH = Constants::TEXT_MAX_LENGTH
PIO_ELEMENT_RESERVED_LENGTH_BIG = TEXT_MAX_LENGTH * 0.015
PIO_ELEMENT_RESERVED_LENGTH_MEDIUM = TEXT_MAX_LENGTH * 0.01
PIO_ELEMENT_RESERVED_LENGTH_SMALL = TEXT_MAX_LENGTH * 0.005
# PROTOCOLS.IO PROTOCOL ATTRIBUTES
# Protocols io protocol description reserved length
PIO_P_DESC_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol guidelines attribute reserved length
PIO_P_GUIDELINES_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol before starting attribute reserved length
PIO_P_BEFORESTART_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol safety warnings attribute reserved length
PIO_P_SAFETYWARNING_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol manuscript citation attribute reserved length
PIO_P_MANUCIT_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol keywords attribute reserved length
PIO_P_KEYWORDS_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol tags attribute reserved length
PIO_P_TAGS_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol vendor link attribute reserved length
PIO_P_VNDLINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io protocol external link attribute reserved length
PIO_P_EXTLINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io protocol vendor name attribute reserved length
PIO_P_VNDNAME_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io protocol publish date attribute reserved length
PIO_P_PBLDATE_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.005
# Protocols io protocol created on date attribute reserved length
PIO_P_CREATEDON_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.005
PIO_P_AVAILABLE_LENGTH =
TEXT_MAX_LENGTH -
(PIO_P_DESC_RESERVED_LENGTH + PIO_P_GUIDELINES_RESERVED_LENGTH +
PIO_P_BEFORESTART_RESERVED_LENGTH + PIO_P_SAFETYWARNING_RESERVED_LENGTH +
PIO_P_MANUCIT_RESERVED_LENGTH + PIO_P_KEYWORDS_RESERVED_LENGTH +
PIO_P_TAGS_RESERVED_LENGTH + PIO_P_VNDLINK_RESERVED_LENGTH +
PIO_P_EXTLINK_RESERVED_LENGTH + PIO_P_VNDNAME_RESERVED_LENGTH +
PIO_P_PBLDATE_RESERVED_LENGTH + PIO_P_CREATEDON_RESERVED_LENGTH +
(PIO_ELEMENT_RESERVED_LENGTH_SMALL * 2 +
PIO_ELEMENT_RESERVED_LENGTH_MEDIUM * 8 +
PIO_ELEMENT_RESERVED_LENGTH_BIG * 2 +
400)
# 400 is for en.yml text
# PROTOCOLS.IO STEP ATTRIBUTES
# Protocols io step PIO_S_DESC_RESERVED_LENGTH attribute reserve
PIO_S_DESC_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io step PIO_S_SOFT_NAME_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_NAME_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0064
# Protocols io step PIO_S_SOFT_DEVELOPER_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_DEV_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0128
# Protocols io step PIO_S_SOFT_VERSION_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_VERSION_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0016
# Protocols io step PIO_S_SOFT_LINK_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_LINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io step PIO_S_SOFT_REPLINK_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_REPLINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io step PIO_S_SOFT_OSNAME_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_OSNAME_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0128
# Protocols io step PIO_S_SOFT_OSVERSION_RESERVED_LENGTH attribute reserve
PIO_S_SOFT_OSVERSION_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0032
# Protocols io step PIO_S_DATA_NAME_RESERVED_LENGTH attribute reserve
PIO_S_DATA_NAME_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0064
# Protocols io step PIO_S_DATA_LINK_RESERVED_LENGTH attribute reserve
PIO_S_DATA_LINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io step PIO_S_COM_OSNAME_RESERVED_LENGTH attribute reserve
PIO_S_COM_OSNAME_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0128
# Protocols io step PIO_S_COM_OSVERSION_RESERVED_LENGTH attribute reserve
PIO_S_COM_OSVERSION_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0032
# Protocols io step PIO_S_COM_DESCRIPTION_RESERVED_LENGTH attribute reserve
PIO_S_COM_DESCRIPTION_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0100
# Protocols io step PIO_S_COM_COMMAND_RESERVED_LENGTH attribute reserve
PIO_S_COM_COMMAND_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0100
# Protocols io step PIO_S_SUBPROT_AUTHOR_RESERVED_LENGTH attribute reserve
PIO_S_SUBPROT_AUTHOR_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.0128
# Protocols io step PIO_S_SUBPROT_NAME_RESERVED_LENGTH attribute reserve
PIO_S_SUBPROT_NAME_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io step PIO_S_SUBPROT_LINK_RESERVED_LENGTH attribute reserve
PIO_S_SUBPROT_LINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io step PIO_S_SAFETY_INFO_RESERVED_LENGTH attribute reserve
PIO_S_SAFETY_INFO_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
# Protocols io step PIO_S_SAFETY_LINK_RESERVED_LENGTH attribute reserve
PIO_S_SAFETY_LINK_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.015
# Protocols io step PIO_S_EXPECTEDRESULT_RESERVED_LENGTH attribute reserve
PIO_S_EXPECTEDRESULT_RESERVED_LENGTH = TEXT_MAX_LENGTH * 0.01
PIO_S_AVAILABLE_LENGTH =
TEXT_MAX_LENGTH -
(PIO_S_DESC_RESERVED_LENGTH + PIO_S_SOFT_NAME_RESERVED_LENGTH +
PIO_S_SOFT_DEV_RESERVED_LENGTH + PIO_S_SOFT_VERSION_RESERVED_LENGTH +
PIO_S_SOFT_LINK_RESERVED_LENGTH + PIO_S_SOFT_REPLINK_RESERVED_LENGTH +
PIO_S_SOFT_OSNAME_RESERVED_LENGTH + PIO_S_SOFT_OSVERSION_RESERVED_LENGTH +
PIO_S_DATA_NAME_RESERVED_LENGTH + PIO_S_DATA_LINK_RESERVED_LENGTH +
PIO_S_COM_OSNAME_RESERVED_LENGTH + PIO_S_COM_OSVERSION_RESERVED_LENGTH +
PIO_S_COM_DESCRIPTION_RESERVED_LENGTH + PIO_S_COM_COMMAND_RESERVED_LENGTH +
PIO_S_SUBPROT_AUTHOR_RESERVED_LENGTH + PIO_S_SUBPROT_NAME_RESERVED_LENGTH +
PIO_S_SUBPROT_LINK_RESERVED_LENGTH + PIO_S_SAFETY_INFO_RESERVED_LENGTH +
PIO_S_SAFETY_LINK_RESERVED_LENGTH + PIO_S_EXPECTEDRESULT_RESERVED_LENGTH +
(PIO_ELEMENT_RESERVED_LENGTH_SMALL * 4 +
PIO_ELEMENT_RESERVED_LENGTH_MEDIUM * 11 +
PIO_ELEMENT_RESERVED_LENGTH_BIG * 5 +
550)
# 550 reserved for en.yml translations
@ -155,21 +76,23 @@ module ProtocolsIoHelper
def pio_eval_prot_desc(text, attribute_name)
case attribute_name
when 'before_start'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_BEFORESTART_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM)
when 'warning'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_SAFETYWARNING_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM)
when 'guidelines'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_GUIDELINES_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM)
when 'publish_date'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_PBLDATE_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL)
when 'vendor_name'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_VNDNAME_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM)
when 'vendor_link'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_VNDLINK_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG)
when 'keywords'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_KEYWORDS_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM)
when 'manuscript_citation'
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM)
when 'link'
pio_eval_len(text, ProtocolsIoHelper::PIO_P_EXTLINK_RESERVED_LENGTH)
pio_eval_len(text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG)
else
''
end
@ -191,11 +114,13 @@ module ProtocolsIoHelper
text_end = reserved + @remaining - PIO_STEP_TOOLONG_LEN
if text.length - reserved > @remaining
text =
close_tags(text[0..text_end]) +
close_open_html_tags(text[0..text_end]) +
t('protocols.protocols_io_import.too_long')
@toolong = true
@remaining = 0
else
@remaining -= (text.length - reserved)
end
@remaining -= (text.length - reserved)
text
end
end
@ -210,7 +135,7 @@ module ProtocolsIoHelper
end
end
def close_tags(text)
def close_open_html_tags(text)
Nokogiri::HTML::DocumentFragment.parse(text).to_html
end
end

View file

@ -24,7 +24,7 @@
<strong><%= t('protocols.protocols_io_import.preview.prot_desc') %></strong>
<% description = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['description'])),
ProtocolsIoHelper::PIO_P_DESC_RESERVED_LENGTH) %>
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM) %>
<%= description.html_safe %><br>
<% end %>
<% if json_object['before_start'].present? %>
@ -32,7 +32,7 @@
<strong><%= t('protocols.protocols_io_import.preview.b_s_p') %></strong>
<% before_start = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['before_start'])),
ProtocolsIoHelper::PIO_P_BEFORESTART_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= before_start.html_safe %><br>
<% end %>
@ -41,7 +41,7 @@
<strong><%= t('protocols.protocols_io_import.preview.warn') %></strong>
<% sft_warning = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['warning'])),
ProtocolsIoHelper::PIO_P_SAFETYWARNING_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= sft_warning.html_safe%><br>
<% end %>
@ -50,7 +50,7 @@
<strong><%= t('protocols.protocols_io_import.preview.guideln') %></strong>
<% guidelines = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['guidelines'])),
ProtocolsIoHelper::PIO_P_GUIDELINES_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= guidelines.html_safe %><br>
<% end %>
@ -59,7 +59,7 @@
<strong><%= t('protocols.protocols_io_import.preview.manu_cit') %></strong>
<% manu_cit = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['manuscript_citation'])),
ProtocolsIoHelper::PIO_P_MANUCIT_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= manu_cit.html_safe %><br>
<% end %>
@ -67,7 +67,7 @@
<strong><%= t('protocols.protocols_io_import.preview.pbl_date') %></strong>
<% pbl_date = pio_eval_len(
sanitize_input(json_object['publish_date']),
ProtocolsIoHelper::PIO_P_PBLDATE_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) %>
<%= pbl_date.html_safe %><br>
<% end %>
@ -75,7 +75,7 @@
<strong><%= t('protocols.protocols_io_import.preview.vnd_name') %></strong>
<% vnd_name = pio_eval_len(
sanitize_input(json_object['vendor_name']),
ProtocolsIoHelper::PIO_P_VNDNAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= vnd_name.html_safe %><br>
<% end %>
@ -83,7 +83,7 @@
<strong><%= t('protocols.protocols_io_import.preview.vnd_link') %></strong>
<% vnd_link = pio_eval_len(
sanitize_input(json_object['vendor_link']),
ProtocolsIoHelper::PIO_P_VNDLINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
) %>
<%= vnd_link.html_safe %><br>
<% end %>
@ -91,7 +91,7 @@
<strong><%= t('protocols.protocols_io_import.preview.key_wrd') %></strong>
<% keywords = pio_eval_len(
sanitize_input(json_object['keywords']),
ProtocolsIoHelper::PIO_P_KEYWORDS_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= keywords.html_safe %><br>
<% end %>
@ -103,7 +103,7 @@
<% end %>
<% tags = pio_eval_len(
sanitize_input(string_of_tags),
ProtocolsIoHelper::PIO_P_TAGS_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)%>
<%= tags.html_safe %>
<% end %>
@ -111,7 +111,7 @@
<strong><%= t('protocols.protocols_io_import.preview.p_link') %></strong>
<% link = pio_eval_len(
sanitize_input(json_object['link']).html_safe,
ProtocolsIoHelper::PIO_P_EXTLINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
) %>
<%= link.html_safe %><br>
<% end %>

View file

@ -30,7 +30,7 @@
<label><%= t('protocols.import_export.import_modal.name_label') %></label>
<%= f.text_field :name, :value => @json_object['protocol_name'], class:
<%= f.text_field :name, :value => pio_eval_title_len(sanitize_input(@json_object['protocol_name'])), class:
"form-control" %>
</div>
<div class="form-group">
@ -38,7 +38,7 @@
<span class="glyphicon glyphicon-user">
</span>&nbsp;<%= t('protocols.import_export.import_modal.authors_label') %>
</label>
<%= f.text_field :authors, :value => @json_object['full_name'], class:
<%= f.text_field :authors, :value => pio_eval_title_len(sanitize_input(@json_object['full_name'])), class:
"form-control" %>
</div>

View file

@ -44,7 +44,7 @@
<br><strong><%= t('protocols.protocols_io_import.preview.strng_s_desc') %></strong>
<% s_desc = pio_eval_len(
sanitize_input(string_html_table_remove(key['data'])),
ProtocolsIoHelper::PIO_S_DESC_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)%>
<%= s_desc.html_safe %><br>
<% when '17' %>
@ -52,7 +52,7 @@
<br><strong><%= t('protocols.protocols_io_import.preview.s_exp_res') %></strong>
<% s_exp_res = pio_eval_len(
sanitize_input(string_html_table_remove(key['data'])),
ProtocolsIoHelper::PIO_S_EXPECTEDRESULT_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)%>
<%= s_exp_res.html_safe %>
<br>
@ -65,37 +65,37 @@
<strong><%= not_null(key['name'])+': ' %></strong>
<%= pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['name'])).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.dev') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['developer']).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_DEV_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.vers') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['version']).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_VERSION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['link']).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.repo') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['repository']).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_REPLINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.os') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['os_name']).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_OSNAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe+
' , '+
pio_eval_len(
sanitize_input(not_null(key['source_data']['os_version']).html_safe),
ProtocolsIoHelper::PIO_S_SOFT_OSVERSION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<% when '9'%>
<% step_info_string += not_null(key['source_data']['name']) %>
@ -103,12 +103,12 @@
<strong><%= not_null(key['name'])+': ' %></strong>
<%= pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['name'])).html_safe),
ProtocolsIoHelper::PIO_S_DATA_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['link']).html_safe),
ProtocolsIoHelper::PIO_S_DATA_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
).html_safe %>
<% when '15'%>
<% step_info_string += not_null(key['source_data']['description']) %>
@ -116,42 +116,42 @@
<strong><%= key['name']+': ' %></strong>
<% s_cmd = pio_eval_len(
sanitize_input(not_null(key['source_data']['name'])),
ProtocolsIoHelper::PIO_S_COM_COMMAND_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= s_cmd.html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_desc') %>
<% s_cmd_desc = pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['description']))),
ProtocolsIoHelper::PIO_S_COM_DESCRIPTION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<% s_cmd_desc.html_safe %>
<br><%= t('protocols.protocols_io_import.preview.os') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['os_name']).html_safe),
ProtocolsIoHelper::PIO_S_COM_OSNAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe +
' , '+
pio_eval_len(
sanitize_input(not_null(key['source_data']['os_version']).html_safe),
ProtocolsIoHelper::PIO_S_COM_OSVERSION_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<% when '18'%>
<br><strong><%= t('protocols.protocols_io_import.preview.sub_prot') %></strong>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['protocol_name']).html_safe),
ProtocolsIoHelper::PIO_S_SUBPROT_NAME_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.auth') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['full_name']).html_safe),
ProtocolsIoHelper::PIO_S_SUBPROT_AUTHOR_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe %>
<br>
<% if key['source_data']['link'].present? %>
<%= t('protocols.protocols_io_import.preview.s_nobr_link') %>
<%= pio_eval_len(
sanitize_input(key['source_data']['link'].html_safe),
ProtocolsIoHelper::PIO_S_SUBPROT_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
).html_safe %>
<% end %>
<% when '19'%>
@ -160,13 +160,13 @@
<strong><%= key['name']+': ' %></strong>
<% s_safety = pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['body']))),
ProtocolsIoHelper::PIO_S_SAFETY_INFO_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= s_safety.html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['link']).html_safe),
ProtocolsIoHelper::PIO_S_SAFETY_LINK_RESERVED_LENGTH
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
).html_safe %>
<% when '20'%>
<% else %>

View file

@ -1386,7 +1386,7 @@ en:
edit: "Edit protocol"
protocols_io_import:
title_too_long: "... Text is too long so we had to cut it off."
too_long: "<span class='label label-warning'>... Text is too long so we had to cut it off.</span>"
too_long: "... <span class='label label-warning'>Text is too long so we had to cut it off.</span>"
import_description_notice: "The protocols description is listed below under \"Protocol info\"."
preview:
prot_desc: "Protocol Description: "