mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
do not fail pdf export on unpermitted image url
In case the description contains an image, prawn_markup attempts to download the image to embed it in the html turned pdf. But in case of errors, the gem does not seem to them thouroughly. E.g. a 403 when fetching the image, causes the whole export to fail. It might be worthwile to further invest in the area to display certain images, but for the time being, we simply do not fetch the images any longer.
This commit is contained in:
@@ -66,6 +66,19 @@ module WorkPackage::PdfExport::Common
|
||||
@cell_padding ||= [2, 5, 2, 5]
|
||||
end
|
||||
|
||||
def configure_markup
|
||||
# Do not attempt to fetch images.
|
||||
# Fetching images can cause errors e.g. a 403 is returned when attempting to fetch from aws with
|
||||
# a no longer valid token.
|
||||
# Such an error would cause the whole export to error.
|
||||
pdf.markup_options = {
|
||||
image: {
|
||||
loader: ->(_src) { nil },
|
||||
placeholder: "<i>[#{I18n.t('export.image.omitted')}]</i>"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
##
|
||||
# Writes the formatted work package description into the document.
|
||||
#
|
||||
|
||||
@@ -42,6 +42,11 @@ class WorkPackage::PdfExport::WorkPackageListToPdf < WorkPackage::Exporter::Base
|
||||
|
||||
self.pdf = get_pdf(current_language)
|
||||
|
||||
configure_page_size
|
||||
configure_markup
|
||||
end
|
||||
|
||||
def configure_page_size
|
||||
pdf.options[:page_size] = 'EXECUTIVE'
|
||||
pdf.options[:page_layout] = :landscape
|
||||
end
|
||||
@@ -119,7 +124,7 @@ class WorkPackage::PdfExport::WorkPackageListToPdf < WorkPackage::Exporter::Base
|
||||
|
||||
def text_column?(column)
|
||||
column.is_a?(Queries::WorkPackages::Columns::CustomFieldColumn) &&
|
||||
['string', 'text'].include?(column.custom_field.field_format)
|
||||
%w(string text).include?(column.custom_field.field_format)
|
||||
end
|
||||
|
||||
def write_headers!
|
||||
|
||||
@@ -38,6 +38,8 @@ class WorkPackage::PdfExport::WorkPackageToPdf < WorkPackage::Exporter::Base
|
||||
super
|
||||
|
||||
self.pdf = get_pdf(current_language)
|
||||
|
||||
configure_markup
|
||||
end
|
||||
|
||||
def render!
|
||||
|
||||
@@ -1141,6 +1141,8 @@ en:
|
||||
pdf_with_descriptions: "PDF with descriptions"
|
||||
pdf_with_descriptions_and_attachments: "PDF with descriptions and attachments"
|
||||
pdf_with_attachments: "PDF with attachments"
|
||||
image:
|
||||
omitted: "Image not exported."
|
||||
|
||||
extraction:
|
||||
available:
|
||||
|
||||
@@ -107,12 +107,12 @@ module OpenProject::TextFormatting::Matchers
|
||||
anchor = $5
|
||||
link_to h("#{matcher.project_prefix}#{matcher.prefix}:#{oid}"),
|
||||
named_route(:entry_revision_project_repository,
|
||||
action: 'entry',
|
||||
project_id: project.identifier,
|
||||
repo_path: path.to_s,
|
||||
rev: rev,
|
||||
anchor: anchor,
|
||||
format: (matcher.prefix == 'export' ? 'raw' : nil)),
|
||||
action: 'entry',
|
||||
project_id: project.identifier,
|
||||
repo_path: path.to_s,
|
||||
rev: rev,
|
||||
anchor: anchor,
|
||||
format: (matcher.prefix == 'export' ? 'raw' : nil)),
|
||||
class: (matcher.prefix == 'export' ? 'source download' : 'source')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user