61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
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>
|
|
<a class="brand" href="/portal" aria-label="AppFactory Portal">
|
|
<img src="{PORTAL_PREFIX}/static/csbot-logo.svg" alt="CSBOT">
|
|
<span>AppFactory</span>
|
|
</a>
|
|
<nav>
|
|
<a href="/portal">Aplikace</a>
|
|
<a href="/portal/new-app">Nová aplikace</a>
|
|
<a href="/portal/deployments">Nasazení</a>
|
|
<a href="/portal/backups">Zálohy</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}">← Zpět</a></p>
|
|
</div>
|
|
<div class="card">
|
|
{rendered_sections}
|
|
</div>
|
|
""",
|
|
)
|