vigia/bin/build-web.bash
Rénich Bon Ćirić 0fb167171f
feat(branding): add multi-resolution favicons and direct organization links
- Generate and embed favicon.ico and favicon.svg into web dist and server routes
- Support direct organization URL in table and map popups linking to hobops.io
- Update CHANGELOG.rst and ensure clean specs pass

Signed-off-by: Rénich Bon Ćirić <renich@evalinux.com>
Co-authored-by: Antigravity <antigravity@google.com>
2026-10-09 04:24:03 -06:00

89 lines
3.1 KiB
Shell
Executable file

#!/usr/bin/bash
set -euo pipefail
IFS=$'\n\t'
readonly ScriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly RepoRoot="$(cd "${ScriptDir}/.." && pwd)"
readonly WebSrc="${RepoRoot}/web/src"
readonly WebVendor="${RepoRoot}/web/vendor"
readonly WebDist="${RepoRoot}/web/dist"
main() {
echo "==> [1/3] Preparando directorio de distribución en ${WebDist}..."
mkdir -p "${WebDist}"
rm -f "${WebDist}/vigia.html" "${WebDist}/app.js" "${WebDist}/app.css"
echo "==> [2/3] Ensamblando archivo único autocontenido (vigia.html)..."
local output_html="${WebDist}/vigia.html"
if [[ ! -f "${WebVendor}/leaflet/leaflet.css" ]] || [[ ! -f "${WebVendor}/leaflet/leaflet.js" ]]; then
echo "Error: Dependencias de Leaflet no encontradas en ${WebVendor}/leaflet" >&2
exit 1
fi
if [[ ! -f "${WebSrc}/app.js" ]] || [[ ! -f "${WebSrc}/style.css" ]]; then
echo "Error: Fuentes web (app.js o style.css) no encontrados en ${WebSrc}" >&2
exit 1
fi
cat > "${output_html}" << 'HTML_HEADER'
<!DOCTYPE html>
<html lang="es" data-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Vigía | Observabilidad de Espejos IPFS</title>
<meta name="description" content="Telemetría en tiempo real y cartografía del enjambre P2P de espejos sobre IPFS de Fundación MxOS.">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="alternate icon" type="image/x-icon" href="favicon.ico">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://tile.openstreetmap.org; connect-src 'self' https://tile.openstreetmap.org;">
<style>
HTML_HEADER
cat "${WebVendor}/leaflet/leaflet.css" >> "${output_html}"
echo "" >> "${output_html}"
cat "${WebSrc}/style.css" >> "${output_html}"
cat >> "${output_html}" << 'HTML_MIDDLE'
</style>
</head>
<body>
<div id="vigia-root"></div>
<script>
HTML_MIDDLE
cat "${WebVendor}/leaflet/leaflet.js" >> "${output_html}"
echo "" >> "${output_html}"
cat "${WebSrc}/app.js" >> "${output_html}"
cat >> "${output_html}" << 'HTML_FOOTER'
</script>
</body>
</html>
HTML_FOOTER
local total_size
total_size="$(du -h "${output_html}" | cut -f1)"
echo " Generado exitosamente: ${output_html} (${total_size})"
echo "==> [3/3] Copiando guardianes.json y metadatos complementarios a ${WebDist}..."
if [[ -f "${RepoRoot}/guardianes.json" ]]; then
cp -f "${RepoRoot}/guardianes.json" "${WebDist}/guardianes.json"
fi
if [[ -f "${WebSrc}/logo.svg" ]]; then
cp -f "${WebSrc}/logo.svg" "${WebDist}/logo.svg"
fi
if [[ -f "${WebSrc}/favicon.ico" ]]; then
cp -f "${WebSrc}/favicon.ico" "${WebDist}/favicon.ico"
fi
if [[ -f "${WebSrc}/favicon.svg" ]]; then
cp -f "${WebSrc}/favicon.svg" "${WebDist}/favicon.svg"
fi
if [[ -f "${RepoRoot}/data/telemetry.json" ]]; then
cp -f "${RepoRoot}/data/telemetry.json" "${WebDist}/telemetry.json"
fi
echo "==> Proceso de compilación web completado con éxito."
}
main "$@"