Commit 3a22b69d authored by Jérome Perrin's avatar Jérome Perrin

corporate_identity: py3

parent f876f537
......@@ -266,8 +266,8 @@ if letter_format == "pdf":
margin_left=0,
margin_right=0,
header_spacing=1,
header_html_data=b64encode(header_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data),
header_html_data=b64encode(header_embedded_html_data).decode(),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
)
)
......
......@@ -269,10 +269,10 @@ if doc_format == "pdf":
margin_bottom=20,
toc=False,
before_toc_data_list=before_toc_data_list,
xsl_style_sheet_data=b64encode(xsl_style_sheet_data),
header_html_data=b64encode(header_embedded_html_data),
xsl_style_sheet_data=b64encode(xsl_style_sheet_data).decode(),
header_html_data=b64encode(header_embedded_html_data).decode(),
header_spacing=10,
footer_html_data=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
footer_spacing=3,
)
default_conversion_kw.update(conversion_dict)
......
......@@ -33,6 +33,7 @@ MAIN FILE: generate book in different output formats
# display_svg format for svg images (svg, png*)
import re
import six
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
......@@ -83,8 +84,7 @@ book_version = html_quote(override_document_version) if override_document_versio
book_description = html_quote(override_document_description) if override_document_description else book.getDescription()
book_title = html_quote(override_document_title) if override_document_title else book.getTitle()
# unicode
if isinstance(book_content, unicode):
if six.PY2 and isinstance(book_content, unicode):
book_content = book_content.encode("UTF-8")
# backcompat
......@@ -359,16 +359,16 @@ elif book_format == "pdf":
# ================ encode and build cloudoo elements =========================
header_embedded_html_data = book.Base_convertHtmlToSingleFile(book_head, allow_script=True)
before_toc_data_list = [
b64encode(book.Base_convertHtmlToSingleFile(book_cover, allow_script=True)),
b64encode(book.Base_convertHtmlToSingleFile(book_cover, allow_script=True)).decode(),
]
after_toc_data_list = []
if book_include_history_table:
before_toc_data_list.append(
b64encode(book.Base_convertHtmlToSingleFile(book_history, allow_script=True))
b64encode(book.Base_convertHtmlToSingleFile(book_history, allow_script=True)).decode()
)
#if book_include_reference_table:
# after_toc_data_list.append(
# b64encode(book.Base_convertHtmlToSingleFile(book_references, allow_script=True))
# b64encode(book.Base_convertHtmlToSingleFile(book_references, allow_script=True)).decode()
# )
xsl_style_sheet_data = book_table_of_content
embedded_html_data = book.Base_convertHtmlToSingleFile(book_content, allow_script=True)
......@@ -385,11 +385,11 @@ elif book_format == "pdf":
margin_bottom=margin_bottom,
toc=True if book_include_content_table else False,
before_toc_data_list=before_toc_data_list,
xsl_style_sheet_data=b64encode(xsl_style_sheet_data),
xsl_style_sheet_data=b64encode(xsl_style_sheet_data).decode(),
after_toc_data_list=after_toc_data_list,
header_html_data=b64encode(header_embedded_html_data),
header_html_data=b64encode(header_embedded_html_data).decode(),
header_spacing=10,
footer_html_data=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
footer_spacing=3,
)
)
......
import re
import six
from base64 import b64encode
......@@ -35,7 +36,7 @@ contract_version = context.getVersion() or "001"
contract_description = context.getDescription()
contract_title = context.getTitle()
if isinstance(contract_content, unicode):
if six.PY2 and isinstance(contract_content, unicode):
contract_content = contract_content.encode("UTF-8")
contract_history_section_list = re.findall('<section.+?>.+?</section>', contract_content, re.S)
......@@ -291,16 +292,16 @@ elif contract_format == "pdf":
# ================ encode and build cloudoo elements =========================
header_embedded_html_data = context.Base_convertHtmlToSingleFile(contract_head, allow_script=True)
before_toc_data_list = [
b64encode(context.Base_convertHtmlToSingleFile(contract_cover, allow_script=True)),
b64encode(context.Base_convertHtmlToSingleFile(contract_cover, allow_script=True)).decode(),
]
after_toc_data_list = []
if contract_include_history_table:
before_toc_data_list.append(
b64encode(context.Base_convertHtmlToSingleFile(contract_history, allow_script=True))
b64encode(context.Base_convertHtmlToSingleFile(contract_history, allow_script=True)).decode()
)
#if contract_include_reference_table:
# after_toc_data_list.append(
# b64encode(context.Base_convertHtmlToSingleFile(contract_references, allow_script=True))
# b64encode(context.Base_convertHtmlToSingleFile(contract_references, allow_script=True)).decode()
# )
xsl_style_sheet_data = contract_table_of_content
embedded_html_data = context.Base_convertHtmlToSingleFile(contract_content, allow_script=True)
......@@ -313,11 +314,11 @@ elif contract_format == "pdf":
margin_bottom=margin_bottom,
toc=True if contract_include_content_table else False,
before_toc_data_list=before_toc_data_list,
xsl_style_sheet_data=b64encode(xsl_style_sheet_data),
xsl_style_sheet_data=b64encode(xsl_style_sheet_data).decode(),
after_toc_data_list=after_toc_data_list,
header_html_data=b64encode(header_embedded_html_data),
header_html_data=b64encode(header_embedded_html_data).decode(),
header_spacing=10,
footer_html_data=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
footer_spacing=3,
)
)
......
......@@ -22,6 +22,7 @@ MAIN FILE: render two pager in different output formats
# document_save: save file in document module (default None)
import re
import six
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
......@@ -146,10 +147,11 @@ if leaflet_display_side:
)
#leaflet_content = leaflet_legalese.decode() + leaflet_content.decode()
if isinstance(leaflet_legalese, unicode):
leaflet_legalese = leaflet_legalese.encode("UTF-8")
if isinstance(leaflet_content, unicode):
leaflet_content = leaflet_content.encode("UTF-8")
if six.PY2:
if isinstance(leaflet_legalese, unicode):
leaflet_legalese = leaflet_legalese.encode("UTF-8")
if isinstance(leaflet_content, unicode):
leaflet_content = leaflet_content.encode("UTF-8")
leaflet_content = leaflet_legalese + leaflet_content
......@@ -265,9 +267,9 @@ if leaflet_format == "pdf":
margin_bottom=20,
margin_left=0,
margin_right=0,
header_html_data=b64encode(header_embedded_html_data),
header_html_data=b64encode(header_embedded_html_data).decode(),
header_spacing=10,
footer_html_data=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
footer_spacing=3
)
)
......
......@@ -21,6 +21,7 @@ MAIN FILE: render press release in different output formats
# document_save: save file in document module (default None)
import re
import six
from base64 import b64encode
blank = ''
......@@ -137,10 +138,11 @@ if release_display_about:
release_relative_url=release_relative_url,
)
#release_content = release_content.decode() + release_about.decode()
if isinstance(release_content, unicode):
release_content = release_content.encode("UTF-8")
if isinstance(release_about, unicode):
release_about = release_about.encode("UTF-8")
if six.PY2:
if isinstance(release_content, unicode):
release_content = release_content.encode("UTF-8")
if isinstance(release_about, unicode):
release_about = release_about.encode("UTF-8")
release_content = release_content + release_about
......@@ -236,9 +238,9 @@ if release_format == "pdf":
margin_bottom=20,
margin_left=0,
margin_right=0,
header_html_data=b64encode(header_embedded_html_data),
header_html_data=b64encode(header_embedded_html_data).decode(),
header_spacing=10,
footer_html_data=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
footer_spacing=3
)
)
......
......@@ -422,15 +422,18 @@ if doc_format == "pdf" or doc_format == "mhtml":
# ================ encode and build cloudoo elements =========================
footer_embedded_html_data = doc.Base_convertHtmlToSingleFile(doc_slideshow_footer, allow_script=True)
#embedded_html_data = doc.Base_convertHtmlToSingleFile(doc_slideshow_content, allow_script=True)
cover = doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)
if six.PY3:
cover = cover.encode()
before_body_data_list = [
b64encode(doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)),
b64encode(cover).decode(),
]
if doc_format == "mhtml":
context.REQUEST.RESPONSE.setHeader("Content-Type", "text/html;")
return doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)
if doc_display_notes:
#after_body_data_list = [
# b64encode(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)),
# b64encode(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)).decode(),
#]
embedded_html_data = doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)
after_body_data_list = []
......@@ -447,7 +450,7 @@ if doc_format == "pdf" or doc_format == "mhtml":
before_body_data_list=before_body_data_list,
after_body_data_list=after_body_data_list,
header_spacing=10,
footer_html_data=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data).decode(),
footer_spacing=3
)
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment