rozdeleni do struktury
This commit is contained in:
@@ -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}">← Back</a></p>
|
||||
</div>
|
||||
<div class="card">
|
||||
{rendered_sections}
|
||||
</div>
|
||||
""",
|
||||
)
|
||||
Reference in New Issue
Block a user