diff --git a/bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_validateImage.py b/bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_validateImage.py index f5df470b6de986370e382449bcc1c3a81d579def..d80f035691c3c9b7ff5370d28f36d3de86f64474 100644 --- a/bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_validateImage.py +++ b/bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_validateImage.py @@ -18,42 +18,69 @@ if img_string is None or img_string == "": return img_string img_src = re.findall("src=['\"](.*?)['\"]", img_string)[0] -img_obj = context.restrictedTraverse(img_src.split("?")[0], None) - -# flag broken link until further notice -if img_obj is None: - raise NotFound('The following image could not be found in erp5: %s' % (img_src.split("?")[0])) - -img_type = img_obj.getContentType() - - -# ensure alt attributes are set -if img_string.find('alt=') == -1: - img_string.replace ("src=", 'alt="%s" src=' % img_caption or img_obj.getTitle()) - -# force svg display as svg or png -if img_type == "image/svg+xml": - if img_svg_format == "png" or img_svg_format is None: - img_string = img_string.replace('type="image/svg+xml"', '') - img_string = img_string.replace("type='image/svg+xml'", '') - img_string = img_string.replace('format=svg', 'format=png') - if img_svg_format == "svg": - img_string = img_string.replace('src=', 'type="image/svg+xml" src=') - img_string = img_string.replace('src=', "type='image/svg+xml' src=") - img_string = img_string.replace('format=png', 'format=svg') - -# wrap image in fullscreen link -if img_fullscreen_link: - img_string = ''.join([ - '<a target="_blank" rel="noopener noreferrer" href="%s" title="%s">%s<a>' % ( - img_src, - img_obj.getTitle(), - img_string - ) - ]) - -# wrap image in <p> tag -if img_wrap: - img_string = '<p class="ci-book-img" style="text-align:center">' + img_string + '</p>' +img_type = None + +# START user ignoring guidelines: +validation_freebie = None +new_src = None + +# Guideline: no relative links. we cover +if img_src.startswith("./"): + new_src = img_src.replace("./", "") + img_string = img_string.replace(img_src, new_src) + +# Guideline: include format. we cover +img_src = new_src or img_src +if img_src.find("format=") == -1: + if img_src.find("?") == -1: + new_src = img_src + "?format=" + else: + new_src = img_src + "&format=" + img_string = img_string.replace(img_src, new_src) + +# Guideline: images must be stored locally, don't complain if your pdf breaks +img_src = new_src or img_src +if img_src.startswith("http"): + validation_freebie = True + +if validation_freebie is None: +#END user ignoring guidelines + + img_obj = context.restrictedTraverse(img_src.split("?")[0], None) + + # flag broken link until further notice + if img_obj is None: + raise NotFound('The following image could not be found in erp5: %s' % (img_src.split("?")[0])) + + img_type = img_obj.getContentType() + + # ensure alt attributes are set + if img_string.find('alt=') == -1: + img_string.replace ("src=", 'alt="%s" src=' % img_caption or img_obj.getTitle()) + + # force svg display as svg or png + if img_type == "image/svg+xml": + if img_svg_format == "png" or img_svg_format is None: + img_string = img_string.replace('type="image/svg+xml"', '') + img_string = img_string.replace("type='image/svg+xml'", '') + img_string = img_string.replace('format=svg', 'format=png') + if img_svg_format == "svg": + img_string = img_string.replace('src=', 'type="image/svg+xml" src=') + img_string = img_string.replace('src=', "type='image/svg+xml' src=") + img_string = img_string.replace('format=png', 'format=svg') + + # wrap image in fullscreen link + if img_fullscreen_link: + img_string = ''.join([ + '<a target="_blank" rel="noopener noreferrer" href="%s" title="%s">%s<a>' % ( + img_src, + img_obj.getTitle(), + img_string + ) + ]) + + # wrap image in <p> tag + if img_wrap: + img_string = '<p class="ci-book-img" style="text-align:center">' + img_string + '</p>' return img_string diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.pdf b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.pdf index db546df98309add694376e47635e48658e6d30ca..5822a96a9140ba72b5416c8e4efea574346cd497 100644 Binary files a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.pdf and b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.pdf differ diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.xml b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.xml index 909311eaa06695c4d1d0744ecc5214685fa023ce..ebff7f700761d90ee2890b642b0e5bd2f5820f21 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.xml +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_001_en_pdf.xml @@ -39,7 +39,7 @@ </item> <item> <key> <string>_EtagSupport__etag</string> </key> - <value> <string>ts36830746.23</string> </value> + <value> <string>ts37191622.9</string> </value> </item> <item> <key> <string>_Modify_portal_content_Permission</string> </key> @@ -83,7 +83,7 @@ </item> <item> <key> <string>content_md5</string> </key> - <value> <string>1347a0ac51a4ccba25cdc2ac1b9ec10e</string> </value> + <value> <string>a6a557994b04da251f3e4294b0b8ff0a</string> </value> </item> <item> <key> <string>content_type</string> </key> diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.pdf b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.pdf index 8d2365a1d8ca747af32dfe0f82da772d38e24df5..8e04df06bac8af308f5b202d72a6db94b5567178 100644 Binary files a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.pdf and b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.pdf differ diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.xml b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.xml index 2d5b67760b5bf6688ccd568d9c7a7b4e0a50bbcf..d4ea6288add625ecab14b1273d2c2bfde72285c8 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.xml +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_002_en_pdf.xml @@ -39,7 +39,7 @@ </item> <item> <key> <string>_EtagSupport__etag</string> </key> - <value> <string>ts36830811.1</string> </value> + <value> <string>ts37191680.59</string> </value> </item> <item> <key> <string>_Modify_portal_content_Permission</string> </key> @@ -83,7 +83,7 @@ </item> <item> <key> <string>content_md5</string> </key> - <value> <string>0f812c098ecdab01bfc987059e4004c8</string> </value> + <value> <string>adc07dd7793551bd8ceba5027eab1738</string> </value> </item> <item> <key> <string>content_type</string> </key> diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.pdf b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.pdf index be06c6f214ea8370f25173684f8b24b378c4d341..f543456445c7584c9be976b77a2d572a905b630c 100644 Binary files a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.pdf and b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.pdf differ diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.xml b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.xml index b016644c3c735423d535fb9d96d4b52f232a1b86..e3d5f13c481c6124d6bf7764caba8ab6177526b3 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.xml +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_003_en_pdf.xml @@ -39,7 +39,7 @@ </item> <item> <key> <string>_EtagSupport__etag</string> </key> - <value> <string>ts36830842.07</string> </value> + <value> <string>ts37191710.15</string> </value> </item> <item> <key> <string>_Modify_portal_content_Permission</string> </key> @@ -83,7 +83,7 @@ </item> <item> <key> <string>content_md5</string> </key> - <value> <string>760600ccb9366e7f4a4b35d10fcb09e9</string> </value> + <value> <string>a9253b04c66ca1ea28fbe89da4ab2dfe</string> </value> </item> <item> <key> <string>content_type</string> </key> diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.pdf b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.pdf index 3fba573e8f376763319e13f97758835040837d53..1ddb82dfdab91f6f2a881220bc1324305cec291d 100644 Binary files a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.pdf and b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.pdf differ diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.xml b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.xml index 2c964ee18790899a24241d22b71d5574703a9c50..d4e4e7fd6b4ea61501ab178bf1a15bddfdaccf2b 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.xml +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_004_en_pdf.xml @@ -39,7 +39,7 @@ </item> <item> <key> <string>_EtagSupport__etag</string> </key> - <value> <string>ts36830779.5</string> </value> + <value> <string>ts37191651.96</string> </value> </item> <item> <key> <string>_Modify_portal_content_Permission</string> </key> @@ -83,7 +83,7 @@ </item> <item> <key> <string>content_md5</string> </key> - <value> <string>99655de2a23499c325e02c5e1f139f83</string> </value> + <value> <string>bcab083b6997eab679dc5ea9182eb5a8</string> </value> </item> <item> <key> <string>content_type</string> </key> diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.pdf b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.pdf index a1bfef82d5ef0d0132ce6d9a72fd201c92b6025d..2478efb68a61ecee1636b1dd6983bf26ba4358a1 100644 Binary files a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.pdf and b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.pdf differ diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.xml b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.xml index e0198002fca3ddc0688f0c36f4689ecf36cbad69..a3809dd5fe5109a52ca519baf4d7d1c7b5fabba7 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.xml +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/document_module/template_test_slideshow_input_005_de_pdf.xml @@ -39,7 +39,7 @@ </item> <item> <key> <string>_EtagSupport__etag</string> </key> - <value> <string>ts36830873.95</string> </value> + <value> <string>ts37191739.69</string> </value> </item> <item> <key> <string>_Modify_portal_content_Permission</string> </key> @@ -83,7 +83,7 @@ </item> <item> <key> <string>content_md5</string> </key> - <value> <string>78b18dfe4630d1460833c1ba7678f8e3</string> </value> + <value> <string>564b35d8806e721a4b44a7644eeccec5</string> </value> </item> <item> <key> <string>content_type</string> </key> @@ -125,7 +125,7 @@ </item> <item> <key> <string>size</string> </key> - <value> <int>381275</int> </value> + <value> <int>680293</int> </value> </item> <item> <key> <string>title</string> </key> diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.bmp b/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.bmp index 5a24c80a84c50b47a95c87f6bec48141386b2509..059464f79ec80603cc06a740eb7137794a970633 100644 Binary files a/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.bmp and b/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.bmp differ diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.xml b/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.xml index 12d85f9f57231a1de0e0f29536ec70848fa62195..ca985f2dc0aae4f12b411fc1d50aed727dcc7d4e 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.xml +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/image_module/template_test_slideshow_input_slide_7_005_de_bmp.xml @@ -79,7 +79,7 @@ </item> <item> <key> <string>content_md5</string> </key> - <value> <string>125dda705d2c7c8942345bf6f5dd3eaa</string> </value> + <value> <string>dfd18344132347b4f1b95bba2f72b781</string> </value> </item> <item> <key> <string>content_type</string> </key> diff --git a/bt5/erp5_corporate_identity_test/PathTemplateItem/web_page_module/template_test_slideshow_input_003_de_html.html b/bt5/erp5_corporate_identity_test/PathTemplateItem/web_page_module/template_test_slideshow_input_003_de_html.html index c36c9e0a420325c3288f810d773abbd6d139d670..96b65a761dcc0238ff2dbc836bdd32aaa1b9501b 100644 --- a/bt5/erp5_corporate_identity_test/PathTemplateItem/web_page_module/template_test_slideshow_input_003_de_html.html +++ b/bt5/erp5_corporate_identity_test/PathTemplateItem/web_page_module/template_test_slideshow_input_003_de_html.html @@ -34,6 +34,22 @@ </details> </section> +<section> + <h1>Test ./Illustration Plain Reference</h1> + <img src="./Template.Test.Illustration.Stack" title="" type="image/svg+xml" alt="" /> + <details open="open"> + <p>svg image with weird reference</p> + </details> +</section> + +<section> + <h1>Test Retrieving PDF page as PNG Image</h1> + <img alt="" src="https://www.nexedi.com/NXD-Gramfort.X.2018.May/index_html?format=png&frame=17" title="" type="image/svg+xml" /> + <details open="open"> + <p>svg image with weird reference</p> + </details> +</section> + <section> <h1>Test SVG as PNG</h1> <img src="Template.Test.Illustration.Stack?format=png" alt="" />