#!/usr/bin/env python3
"""
ProxMenux - HTML Description Templates for OCI Containers
==========================================================
Generates beautiful HTML descriptions for the Proxmox Notes panel.
Can be used from both Python (oci_manager.py) and bash scripts.
Usage from bash:
python3 description_templates.py --app-id "secure-gateway" --hostname "my-gateway"
Usage from Python:
from description_templates import generate_description
html = generate_description(app_def, container_def, hostname)
"""
import sys
import json
import argparse
import urllib.parse
from pathlib import Path
from typing import Dict, Optional
# Default paths
CATALOG_PATH = Path(__file__).parent / "catalog.json"
def get_shield_icon_svg(color: str = "#0EA5E9") -> str:
"""Generate a shield icon SVG with checkmark."""
return f""""""
def get_default_icon_svg(color: str = "#0EA5E9") -> str:
"""Generate a default container icon SVG."""
return f""""""
# Pre-defined icon types
ICON_TYPES = {
"shield": get_shield_icon_svg,
"container": get_default_icon_svg,
"default": get_default_icon_svg,
}
def generate_description(
app_def: Dict,
container_def: Optional[Dict] = None,
hostname: str = "",
extra_info: str = ""
) -> str:
"""
Generate HTML description for Proxmox Notes panel.
Args:
app_def: Application definition from catalog
container_def: Container definition (optional)
hostname: Container hostname
extra_info: Additional info to display (e.g., disk info)
Returns:
HTML string for the description
"""
# Extract app info
app_name = app_def.get("name", "ProxMenux App")
app_subtitle = app_def.get("subtitle", "")
app_color = app_def.get("color", "#0EA5E9")
app_icon_type = app_def.get("icon_type", "default")
doc_url = app_def.get("documentation_url", "https://macrimi.github.io/ProxMenux/")
code_url = app_def.get("code_url", "https://github.com/MacRimi/ProxMenux")
installer_url = app_def.get("installer_url", "")
kofi_url = "https://ko-fi.com/macrimi"
# Get the icon SVG
icon_func = ICON_TYPES.get(app_icon_type, ICON_TYPES["default"])
icon_svg = icon_func(app_color)
icon_data = "data:image/svg+xml," + urllib.parse.quote(icon_svg)
# Build badge buttons
badges = []
badges.append(f"")
badges.append(f"
")
if installer_url:
badges.append(f"
")
badges.append(f"
")
badges_html = "\n".join(badges)
# Build footer info
footer_parts = []
if hostname:
footer_parts.append(f"Hostname: {hostname}")
if extra_info:
footer_parts.append(extra_info)
footer_html = "
".join(footer_parts) if footer_parts else ""
# Build the complete HTML
html = f"""
|
{app_name}Created with ProxMenux |
|
|
{app_name} {app_subtitle} |
{badges_html}
""" if footer_html: html += f"""{footer_html}
""" html += "{vm_version}
" if vm_version else "" # Extra info extra_html = f"{extra_info}
" if extra_info else "" html = f"""
|
{vm_name}Created with ProxMenux {version_html} |
{badges_html}
{extra_html}