ITSA Workflow
This commit is contained in:
@@ -15,6 +15,8 @@ from trytond.transaction import Transaction
|
||||
|
||||
DOCUMENTATION_ROOT = Path(__file__).with_name('process_documentation')
|
||||
MARKDOWN_LINK = re.compile(r'(!?)\[([^\]]*)\]\(([^)]+)\)')
|
||||
HTML_IMAGE_SOURCE = re.compile(
|
||||
r'(<img\b[^>]*\bsrc=)(["\'])([^"\']+)(\2)', re.IGNORECASE)
|
||||
|
||||
|
||||
class ProcessDocumentation(ModelSingleton, ModelSQL, ModelView):
|
||||
@@ -50,13 +52,30 @@ def _html_file_content(filename):
|
||||
common_path = os.path.commonpath([str(root), str(path)])
|
||||
if path != root and common_path == str(root):
|
||||
if path.exists() and path.is_file() and path.suffix.lower() == '.html':
|
||||
document = path.read_text(encoding='utf-8')
|
||||
document = _inline_html_assets(document, _relative_name(path))
|
||||
return IFRAME_TEMPLATE % {
|
||||
'document': html.escape(path.read_text(encoding='utf-8'),
|
||||
quote=True),
|
||||
'document': html.escape(document, quote=True),
|
||||
}
|
||||
return _html_error('Documentation page not found: %s' % filename)
|
||||
|
||||
|
||||
def _inline_html_assets(document, current_file):
|
||||
def replace(match):
|
||||
prefix, quote, source, suffix = match.groups()
|
||||
resolved = _resolve_link(current_file, source)
|
||||
if resolved.startswith(('http://', 'https://', 'data:', 'mailto:')):
|
||||
return match.group(0)
|
||||
|
||||
data_uri = _asset_data_uri(resolved)
|
||||
if not data_uri:
|
||||
return match.group(0)
|
||||
return '%s%s%s%s' % (prefix, quote, html.escape(data_uri, quote=True),
|
||||
suffix)
|
||||
|
||||
return HTML_IMAGE_SOURCE.sub(replace, document)
|
||||
|
||||
|
||||
def _html_error(message):
|
||||
document = HTML_TEMPLATE % {
|
||||
'content': '<p>%s</p>' % html.escape(message),
|
||||
|
||||
@@ -382,7 +382,7 @@
|
||||
<li>Contract lines: product, quantity, unit, tolerance, price formula, Mtm.</li>
|
||||
</ul>
|
||||
<div class="screenshot-placeholder">
|
||||
<img src="../assets/purchase_contract_header.png" alt="Purchase contract header">
|
||||
<img src="assets/purchase_contract_header.png" alt="Purchase contract header">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user