This repository has been archived on 2026-10-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
karldns.de/router_dyndns/web/templates_public_sections.py
T

95 lines
4.3 KiB
Python
Raw Normal View History

2026-05-20 23:55:27 +02:00
from __future__ import annotations
from ..ddns_service import DdnsService
2026-05-21 14:18:39 +02:00
from .html_utils import SafeHtml, escape, trusted
2026-05-20 23:55:27 +02:00
from .templates import (
2026-05-21 14:18:39 +02:00
_code_window,
_copy_menu,
2026-05-20 23:55:27 +02:00
_copy_row,
_fritzbox_fields,
_manual_update_commands,
_manual_update_panel,
_one_time_secret_notice,
_secret_notice,
)
def _linux_installer_section() -> SafeHtml:
system_install = "curl -fsSL https://karldns.de/install.sh | sudo sh"
system_uninstall = "curl -fsSL https://karldns.de/uninstall.sh | sudo sh"
user_install = "curl -fsSL https://karldns.de/install.sh | sh -s -- --mode user"
clean_uninstall = "curl -fsSL https://karldns.de/uninstall.sh | sh -s -- --mode user --delete-config"
return trusted(
f"""
<section class="section" id="linux-installer">
<div class="container narrow">
<div class="text-center mb-4">
<p class="eyebrow">Linux cron updater</p>
2026-05-21 10:05:40 +02:00
<h2>Linux updater.</h2>
<p class="section-copy mx-auto">Run this on a Linux box that is always on. It creates a hostname, installs the updater, schedules it, and prints your private dashboard link.</p>
2026-05-20 23:55:27 +02:00
</div>
<div class="card card-body gap-3">
2026-05-21 14:18:39 +02:00
<div>
<h3>Install</h3>
<p class="section-copy">System install for most Linux servers.</p>
2026-05-20 23:55:27 +02:00
</div>
2026-05-21 14:18:39 +02:00
{_code_window(system_install, copy_label="install command")}
<div>
<h3>Uninstall</h3>
<p class="section-copy">Stops the updater and leaves your private URLs on disk.</p>
2026-05-20 23:55:27 +02:00
</div>
2026-05-21 14:18:39 +02:00
{_code_window(system_uninstall, copy_label="uninstall command")}
2026-05-20 23:55:27 +02:00
<div class="alert alert-info my-0 py-2 small" role="note">
2026-05-21 10:05:40 +02:00
Uninstall keeps your private URLs by default. Use <code>--delete-config</code> only when you want to remove everything.
2026-05-20 23:55:27 +02:00
</div>
<div>
2026-05-21 10:05:40 +02:00
<h3>User install</h3>
<p class="section-copy">Use this when you do not want a system-wide install.</p>
2026-05-20 23:55:27 +02:00
</div>
2026-05-21 14:18:39 +02:00
{_code_window(user_install, copy_label="user install command")}
{_copy_menu("More copy options", [("Clean user uninstall", clean_uninstall)])}
2026-05-20 23:55:27 +02:00
</div>
</div>
</section>
"""
)
def _credentials_panel(service: DdnsService, created_account: dict[str, str] | None) -> SafeHtml:
if not created_account:
return trusted("")
hostname = created_account["hostname"]
username = created_account["username"]
password = created_account["password"]
update_url = service.fritz_update_url(created_account)
credentialed_update_url = service.credentialed_update_url(created_account)
management_url = service.magic_management_url(created_account)
cname_record = f"your-subdomain.example.com. CNAME {hostname}."
fritzbox_fields = _fritzbox_fields(update_url, hostname, username, password, management_url)
manual_commands = _manual_update_commands(update_url)
return trusted(
f"""
<section class="section success-section">
<div class="container">
2026-05-21 10:05:40 +02:00
<p class="eyebrow">Hostname ready</p>
2026-05-20 23:55:27 +02:00
<h2>{escape(hostname)}</h2>
2026-05-21 10:05:40 +02:00
<p class="section-copy">Use the Update-URL directly. Username and password are only for routers that require separate fields.</p>
2026-05-20 23:55:27 +02:00
{_one_time_secret_notice()}
{_secret_notice()}
2026-05-21 14:18:39 +02:00
<div class="copy-actions my-3">
{_copy_menu("Copy setup values", [("Router fields", fritzbox_fields), ("Full update URL", credentialed_update_url), ("CNAME", cname_record)])}
2026-05-20 23:55:27 +02:00
</div>
<div class="d-grid gap-2">
{_copy_row("Update-URL:", update_url, "Secret")}
2026-05-21 10:05:40 +02:00
{_copy_row("Full update URL:", credentialed_update_url, "Secret")}
2026-05-20 23:55:27 +02:00
{_copy_row("Domainnamen:", hostname, "Public")}
{_copy_row("CNAME target:", hostname, "Public")}
{_copy_row("Benutzername (optional):", username, "Public")}
{_copy_row("Kennwort (optional):", password, "Secret")}
2026-05-21 10:05:40 +02:00
{_copy_row("Private dashboard:", management_url, "Secret")}
2026-05-20 23:55:27 +02:00
</div>
{_manual_update_panel(manual_commands)}
</div>
</section>
"""
)