rozdeleni do struktury

This commit is contained in:
JiriUhlir
2026-05-27 12:15:11 +02:00
parent 12f6323185
commit 2b20444324
14 changed files with 749 additions and 661 deletions
+1
View File
@@ -0,0 +1 @@
+56
View File
@@ -0,0 +1,56 @@
import html
from ..config import PORTAL_PREFIX
def page(title: str, body: str) -> str:
return f"""
<html>
<head>
<title>{html.escape(title)}</title>
<link rel="stylesheet" href="{PORTAL_PREFIX}/static/styles.css">
<script src="{PORTAL_PREFIX}/static/portal.js"></script>
</head>
<body>
<header>
<h1>AppFactory</h1>
<nav>
<a href="/portal">Apps</a>
<a href="/portal/new-app">New App</a>
<a href="/portal/backups">Backups</a>
</nav>
</header>
<main>
{body}
</main>
</body>
</html>
"""
def render_result(title, back_url, sections, extra_link=None, extra_label=None):
rendered_sections = ""
for section_title, content in sections:
rendered_sections += f"""
<h2>{html.escape(section_title)}</h2>
<pre>{html.escape(content)}</pre>
"""
extra = ""
if extra_link and extra_label:
extra = f'<p><a class="btn" href="{extra_link}">{html.escape(extra_label)}</a></p>'
return page(
title,
f"""
<div class="card">
<h2>{html.escape(title)}</h2>
{extra}
<p><a href="{back_url}">&larr; Back</a></p>
</div>
<div class="card">
{rendered_sections}
</div>
""",
)