From 72ae647d039dcd6c74b7a01a05fff91114571832 Mon Sep 17 00:00:00 2001 From: Laurier Loiselle Date: Mon, 23 Jan 2023 18:43:45 -0500 Subject: [PATCH] output: update titleblock with template --- src/wireviz/templates/din-6771.html | 8 +- src/wireviz/templates/titleblock.html | 111 ++++++++++++-------------- src/wireviz/wv_cli.py | 2 +- src/wireviz/wv_output.py | 51 +++++++++--- 4 files changed, 94 insertions(+), 78 deletions(-) diff --git a/src/wireviz/templates/din-6771.html b/src/wireviz/templates/din-6771.html index 2859471..1e5d17a 100644 --- a/src/wireviz/templates/din-6771.html +++ b/src/wireviz/templates/din-6771.html @@ -79,7 +79,7 @@ right: -0mm; } - #titleblock table { + #titleblock { width: 180mm; height: 38.25mm; } @@ -149,7 +149,7 @@ } .company { - font-size: 4mm; + font-size: 3mm; text-align: center; white-space: normal; } @@ -203,9 +203,7 @@ {{ bom_reversed }} -
- {{ titleblock }} -
+ {{ titleblock }} diff --git a/src/wireviz/templates/titleblock.html b/src/wireviz/templates/titleblock.html index 936e27d..826412c 100644 --- a/src/wireviz/templates/titleblock.html +++ b/src/wireviz/templates/titleblock.html @@ -1,78 +1,67 @@ - +
+ +
+ {% for revision in revisions %} + + {% for key in ['rev', 'changelog', 'date', 'name'] %} + + {% endfor %} + + {% endfor %} + + + + + + +
{{ revision.get(key, '') }}
RevDateNameChangelog
+ + + - - - - - - - + + + {% for author in authors %} - - - - - - - + + + + {% endfor %} - - - - - - - + + + + +
{{ revisions_8 }} {{ revisions_8_changelog }} {{ revisions_8_date }} {{ revisions_8_name }} DateName {{ title }}DateName
{{ revisions_7 }} {{ revisions_7_changelog }} {{ revisions_7_date }} {{ revisions_7_name }} {{ authors_1 }} {{ authors_1_date }} {{ authors_1_name }}{{ author['row'] }} {{ author['date'] }} {{ author['name'] }}
{{ revisions_6 }} {{ revisions_6_changelog }} {{ revisions_6_date }} {{ revisions_6_name }} {{ authors_2 }} {{ authors_2_date }} {{ authors_2_name }}
+ + + - - - - - - - + + - - - - - - + + - - - - - - - + + - - - - + + + - - - - - + - - - - - - - - - -
{{ revisions_5 }} {{ revisions_5_changelog }} {{ revisions_5_date }} {{ revisions_5_name }} {{ authors_3 }} {{ authors_3_date }} {{ authors_3_name }} {{ company }}
{{ revisions_4 }} {{ revisions_4_changelog }} {{ revisions_4_date }} {{ revisions_4_name }} {{ address }}
{{ revisions_3 }} {{ revisions_3_changelog }} {{ revisions_3_date }} {{ revisions_3_name }} {{ company }} {{ pn }}Sheet
{{ sheet_current }}
{{ title }}
{{ revisions_2 }} {{ revisions_2_changelog }} {{ revisions_2_date }} {{ revisions_2_name }} {{ pn }} {{ revision }}
{{ revisions_1 }} {{ revisions_1_changelog }} {{ revisions_1_date }} {{ revisions_1_name }}of {{ sheet_total }}Sheet {{ sheet_current }} of {{ sheet_total }}
RevChangelogDateName
+ + + diff --git a/src/wireviz/wv_cli.py b/src/wireviz/wv_cli.py index 23255bc..bdba966 100644 --- a/src/wireviz/wv_cli.py +++ b/src/wireviz/wv_cli.py @@ -129,7 +129,7 @@ def cli(file, format, prepend, output_dir, output_name, version): raise Exception(f"Path is not a file:\n{file}") extra_metadata = {} - extra_metadata["name"] = file.stem + extra_metadata["sheet_name"] = file.stem extra_metadata["sheet_total"] = len(filepaths) extra_metadata["sheet_current"] = sheet_current sheet_current += 1 diff --git a/src/wireviz/wv_output.py b/src/wireviz/wv_output.py index 1fd1423..21f9922 100644 --- a/src/wireviz/wv_output.py +++ b/src/wireviz/wv_output.py @@ -123,7 +123,6 @@ def generate_html_output( sheet_total = 1 replacements = { - "title": "pizza", "generator": f"{APP_NAME} {__version__} - {APP_URL}", "fontname": options.fontname, "bgcolor": options.bgcolor.html, @@ -132,27 +131,57 @@ def generate_html_output( "bom_reversed": bom_html_reversed, "sheet_current": sheet_current, "sheet_total": sheet_total, + "titleblock_rows": 9 } # prepare metadata replacements + added_metadata = { + 'revisions': [], + 'authors': [], + } if metadata: for item, contents in metadata.items(): - if isinstance(contents, (str, int, float)): - replacements[str(item)] = html_line_breaks(str(contents)) - elif isinstance(contents, Dict): # useful for authors, revisions - for index, (category, entry) in enumerate(contents.items()): - if isinstance(entry, Dict): - replacements[f"{item}_{index+1}"] = str(category) - for entry_key, entry_value in entry.items(): - replacements[ - f"{item}_{index+1}_{entry_key}" - ] = html_line_breaks(str(entry_value)) + if item == 'revisions': + added_metadata['revisions'] = [{'rev': rev, **v} for rev, v in contents.items()] + continue + if item == 'authors': + added_metadata['authors'] = [{'row': row, **v} for row, v in contents.items()] + continue + if item == 'pn': + added_metadata[item] = f'{contents}-{metadata.get("sheet_name")}' + continue + + added_metadata[item] = contents + #if isinstance(contents, (str, int, float)): + # replacements[str(item)] = html_line_breaks(str(contents)) + #elif isinstance(contents, Dict): # useful for authors, revisions + # for index, (category, entry) in enumerate(contents.items()): + # if isinstance(entry, Dict): + # replacements[f"{item}_{index+1}"] = str(category) + # for entry_key, entry_value in entry.items(): + # replacements[ + # f"{item}_{index+1}_{entry_key}" + # ] = html_line_breaks(str(entry_value)) + replacements[ "sheetsize_default" ] = f'{metadata.get("template", {}).get("sheetsize", "sheetsize_default")}' # include quotes so no replacement happens within