Templates + router script + browser constructor that build mihomo profiles (router home/street, mobile) with optional OpenVPN (TOTP) and Tailscale, one-command installer and maintenance commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
880 B
Python
Executable File
22 lines
880 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Build web/index.html: web/index.src.html + web/engine.js + templates/ inlined.
|
|
|
|
The result is one self-contained file: open it from disk or put it on any
|
|
static host. Run after changing templates/ or web/.
|
|
"""
|
|
import json
|
|
import pathlib
|
|
|
|
root = pathlib.Path(__file__).resolve().parent.parent
|
|
templates = {
|
|
f"{p.parent.name}/{p.name}": p.read_text(encoding="utf-8")
|
|
for p in sorted((root / "templates").glob("*/*.yaml"))
|
|
}
|
|
engine = (root / "web" / "engine.js").read_text(encoding="utf-8")
|
|
page = (root / "web" / "index.src.html").read_text(encoding="utf-8")
|
|
|
|
tpl_json = json.dumps(templates, ensure_ascii=False, indent=1).replace("</", "<\\/")
|
|
page = page.replace("/*__ENGINE__*/", engine).replace("/*__TEMPLATES__*/", tpl_json)
|
|
(root / "web" / "index.html").write_text(page, encoding="utf-8")
|
|
print(f"web/index.html: {len(templates)} templates")
|