Files

69 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
CONFIG_FILE="/opt/appfactory/config/appfactory.env"
source "$CONFIG_FILE"
CATALOG_FILE="$APPFACTORY_DIR/apps/catalog.yml"
OUTPUT_DIR="$APPFACTORY_DIR/gateway/static"
OUTPUT_FILE="$OUTPUT_DIR/apps.html"
mkdir -p "$OUTPUT_DIR"
cat > "$OUTPUT_FILE" <<'EOF_HTML'
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AppFactory Apps</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px; border-bottom: 1px solid #ddd; text-align: left; }
th { background: #f5f5f5; }
a { color: #0066cc; }
</style>
</head>
<body>
<h1>AppFactory Apps</h1>
<table>
<tr>
<th>ID</th>
<th>Status</th>
<th>Docs</th>
<th>Health</th>
</tr>
EOF_HTML
awk '
function print_row() {
if (id != "") {
print "<tr><td>" id "</td><td>" status "</td><td><a href=\"" docs "\">docs</a></td><td><a href=\"" health "\">health</a></td></tr>"
}
}
/- id:/ {
print_row()
id=$3
status=""
docs=""
health=""
}
/^[[:space:]]+status:/ { status=$2 }
/^[[:space:]]+docs:/ { docs=$2 }
/^[[:space:]]+health:/ { health=$2 }
END {
print_row()
}
' "$CATALOG_FILE" >> "$OUTPUT_FILE"
cat >> "$OUTPUT_FILE" <<'EOF_HTML'
</table>
</body>
</html>
EOF_HTML
echo "Generated: $OUTPUT_FILE"