remove unneeded comment and add tiny_mce_asset regex in a constant

This commit is contained in:
zmagod 2017-11-24 17:04:01 +01:00
parent 066c782cd2
commit e69e9f6794
4 changed files with 6 additions and 5 deletions

View file

@ -10,7 +10,6 @@ module TinyMceHelper
img.replace(token)
next unless obj
tiny_img = TinyMceAsset.find_by_id(img_id)
# next if check_parse_token_permissions(obj, tiny_img)
tiny_img.reference = obj unless tiny_img.step || tiny_img.result_text
tiny_img.save
end
@ -20,7 +19,7 @@ module TinyMceHelper
def generate_image_tag_from_token(text, obj)
return unless text
regex = /\[~tiny_mce_id:([0-9a-zA-Z]+)\]/
regex = Constants::TINY_MCE_ASSET_REGEX
text.gsub(regex) do |el|
match = el.match(regex)
img = TinyMceAsset.find_by_id(match[1])
@ -34,7 +33,7 @@ module TinyMceHelper
def link_tiny_mce_assets(text, ref)
ids = []
regex = /\[~tiny_mce_id:([0-9a-zA-Z]+)\]/
regex = Constants::TINY_MCE_ASSET_REGEX
text.gsub(regex) do |img|
match = img.match(regex)
tiny_img = TinyMceAsset.find_by_id(match[1])

View file

@ -41,7 +41,7 @@ module ProtocolsExporter
def get_tiny_mce_assets(text)
return unless text
regex = /\[~tiny_mce_id:([0-9a-zA-Z]+)\]/
regex = Constants::TINY_MCE_ASSET_REGEX
tiny_assets_xml = "<descriptionAssets>\n"
text.gsub(regex) do |el|
match = el.match(regex)

View file

@ -170,6 +170,6 @@ module ProtocolsImporter
# handle import from legacy exports
def populate_rte_legacy(step_json)
return unless step_json['description'] && step_json['description'].present?
step_json['description'].gsub(/\[~tiny_mce_id:([0-9a-zA-Z]+)\]/, '')
step_json['description'].gsub(Constants::TINY_MCE_ASSET_REGEX, '')
end
end

View file

@ -864,6 +864,8 @@ class Constants
# Very basic regex to check for validity of emails
BASIC_EMAIL_REGEX = URI::MailTo::EMAIL_REGEXP
TINY_MCE_ASSET_REGEX = /\[~tiny_mce_id:([0-9a-zA-Z]+)\]/
# Team name for default admin user
DEFAULT_PRIVATE_TEAM_NAME = 'My projects'.freeze