web: build_standalone.py — self-contained calc-standalone.html (fallback when no server); standalone html is generated, gitignored

This commit is contained in:
OpenClaw Coder committed 2026-11-05 10:33:34 +10:00
1 parent 8848ed45d5
commit a4d902dafa
2 files changed
+15

No files matched your search

+1
View File
@@ -11,3 +11,4 @@ venv/
*.spec
.coverage
web/node_modules/
web/calc-standalone.html
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
"""Собирает web/calc-standalone.html — один self-contained файл (inline CSS+JS)."""
import pathlib
web = pathlib.Path(__file__).parent
html = (web / "index.html").read_text(encoding="utf-8")
css = (web / "style.css").read_text(encoding="utf-8")
js = (web / "engine.js").read_text(encoding="utf-8") + "\n" + (web / "app.js").read_text(encoding="utf-8")
html = html.replace('<link rel="stylesheet" href="style.css">', f"<style>\n{css}</style>")
html = html.replace('<script src="engine.js"></script>\n<script src="app.js"></script>',
f"<script>\n{js}\n</script>")
assert "href=\"style.css\"" not in html and "src=\"app.js\"" not in html and "src=\"engine.js\"" not in html
out = web / "calc-standalone.html"
out.write_text(html, encoding="utf-8")
print(out, out.stat().st_size, "bytes")