Add header and footer templates for report generation

- Created a footer template with contact information and page number.
- Created a header template displaying patient details including name, age, height, weight, and focus.
This commit is contained in:
bolade
2025-09-26 21:42:02 +01:00
parent 1ae1ec2369
commit 894fbbcee3
40 changed files with 805 additions and 1838 deletions
+57 -10
View File
@@ -7,9 +7,45 @@ env = Environment(loader=FileSystemLoader("report_gen"))
html_pages = []
header_context = {
"patient_name": "Keirstyn Moran",
"age": 34,
"height": "5'4\"",
"weight": "123lbs",
"focus": "Endurance",
}
footer_context = [{
"contact_email": "info@ishplabs.com ",
"website": "www.ishplabs.com",
"social": "@ishplabs",
"page_number": i + 1,
} for i in range(len(context_list))]
header_html = env.get_template("header.html").render(header_context)
footer_html_list = [env.get_template("footer.html").render(context) for context in footer_context]
for i, context in enumerate(context_list):
template = env.get_template(f"page_{i + 1}.html")
html_pages.append(template.render(context))
template = env.get_template(f"page_{i + 1}.html").render(context)
if (i + 1) > 2:
full_html = f"""
<div class="page flex flex-col justify-between">
<div>
{header_html}
</div>
<main class="flex-grow p-4">
{template}
</main>
<div class="border-t text-center text-sm text-gray-600">
{footer_html_list[i]}
</div>
</div>
"""
html_pages.append(full_html)
else:
html_pages.append(template)
# Combine with page breaks
final_html = "<div class='page-break'></div>".join(html_pages)
@@ -28,15 +64,26 @@ html_doc = f"""
}}
.page-break {{ page-break-after: always; }}
.page {{
height: 100%;
height: 100vh;
min-height: 100vh;
display: flex;
flex-direction: column;
}}
.page main {{
flex: 1;
overflow: hidden;
}}
/* Reset margins and padding everywhere */
* {{
margin: 0;
padding: 0;
box-sizing: border-box;
}}
/* Prevent images from being too large */
img {{
max-height: 200px;
object-fit: contain;
}}
/* Reset margins and padding everywhere */
* {{
margin: 0;
padding: 0;
box-sizing: border-box;
}}
</style>
</head>
<body class="m-0 p-0">