Merge pull request #1077 from ZmagoD/zd_SCI_2279

fixes tiny_mce pdf report in filesystem storage mode [fixes SCI-2279]
This commit is contained in:
Zmago Devetak 2018-04-05 16:52:16 +02:00 committed by GitHub
commit e30b2261a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 9 deletions

View file

@ -2207,3 +2207,7 @@ th.custom-field .modal-tooltiptext {
.linkedin-signin-button { .linkedin-signin-button {
margin: 15px 0; margin: 15px 0;
} }
.tiny-mce-pdf-ready {
max-width: 100%;
}

View file

@ -56,7 +56,7 @@ module ReportsHelper
end end
# "Hack" to omit file preview URL because of WKHTML issues # "Hack" to omit file preview URL because of WKHTML issues
def report_image_asset_url(asset) def report_image_asset_url(asset, type = :asset, klass = nil)
prefix = '' prefix = ''
if ENV['PAPERCLIP_STORAGE'].present? && if ENV['PAPERCLIP_STORAGE'].present? &&
ENV['MAIL_SERVER_URL'].present? && ENV['MAIL_SERVER_URL'].present? &&
@ -68,8 +68,9 @@ module ReportsHelper
!prefix.include?('https://') !prefix.include?('https://')
prefix = "http://#{prefix}" prefix = "http://#{prefix}"
end end
url = prefix + asset.url(:medium, timeout: Constants::URL_LONG_EXPIRE_TIME) size = type == :tiny_mce_asset ? :large : :medium
image_tag(url) url = prefix + asset.url(size, timeout: Constants::URL_LONG_EXPIRE_TIME)
image_tag(url, class: klass)
end end
# "Hack" to load Glyphicons css directly from the CDN # "Hack" to load Glyphicons css directly from the CDN

View file

@ -17,7 +17,8 @@ module TinyMceHelper
html html
end end
def generate_image_tag_from_token(text, obj) # @param pdf_export_ready is needed for wicked_pdf in export report action
def generate_image_tag_from_token(text, obj, pdf_export_ready = false)
return unless text return unless text
regex = Constants::TINY_MCE_ASSET_REGEX regex = Constants::TINY_MCE_ASSET_REGEX
text.gsub(regex) do |el| text.gsub(regex) do |el|
@ -25,9 +26,13 @@ module TinyMceHelper
img = TinyMceAsset.find_by_id(match[1]) img = TinyMceAsset.find_by_id(match[1])
next unless img && img.team == current_team next unless img && img.team == current_team
next unless check_image_permissions(obj, img) next unless check_image_permissions(obj, img)
image_tag img.url, if pdf_export_ready
class: 'img-responsive', report_image_asset_url(img, :tiny_mce_asset, 'tiny-mce-pdf-ready')
data: { token: Base62.encode(img.id) } else
image_tag(img.url,
class: 'img-responsive',
data: { token: Base62.encode(img.id) })
end
end end
end end

View file

@ -23,7 +23,7 @@
<div class="report-element-body"> <div class="report-element-body">
<div class="row"> <div class="row">
<div class="col-xs-12 text-container ql-editor"> <div class="col-xs-12 text-container ql-editor">
<%= custom_auto_link(generate_image_tag_from_token(result_text.text, result_text), <%= custom_auto_link(generate_image_tag_from_token(result_text.text, result_text, true),
simple_format: false, simple_format: false,
tags: %w(img)) %> tags: %w(img)) %>
</div> </div>

View file

@ -30,7 +30,7 @@
<div class="row"> <div class="row">
<div class="col-xs-12 ql-editor"> <div class="col-xs-12 ql-editor">
<% if strip_tags(step.description).present? %> <% if strip_tags(step.description).present? %>
<%= custom_auto_link(generate_image_tag_from_token(step.description, step), <%= custom_auto_link(generate_image_tag_from_token(step.description, step, true),
simple_format: false, simple_format: false,
tags: %w(img)) %> tags: %w(img)) %>
<% else %> <% else %>