-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-html.py
More file actions
111 lines (93 loc) Β· 3.24 KB
/
build-html.py
File metadata and controls
111 lines (93 loc) Β· 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python3
"""
Build script for EDOG Log Viewer.
Assembles modular CSS and JS files into a single self-contained edog-logs.html.
Source: src/edog-logs/ (index.html shell + css/ + js/)
Output: src/edog-logs.html (single file served by EdogLogServer)
Usage:
python build-html.py
python build-html.py --watch # Rebuild on file changes (future)
"""
import os
import sys
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SRC_DIR = os.path.join(SCRIPT_DIR, "src", "edog-logs")
OUTPUT_FILE = os.path.join(SCRIPT_DIR, "src", "edog-logs.html")
# CSS modules β order matters (variables first, then layout, then components)
CSS_MODULES = [
"css/variables.css",
"css/layout.css",
"css/filters.css",
"css/logs.css",
"css/telemetry.css",
"css/detail.css",
"css/summary.css",
"css/smart.css",
"css/control.css",
]
# JS modules β order matters (dependencies first, then features, then main)
JS_MODULES = [
"js/state.js",
"js/websocket.js",
"js/renderer.js",
"js/filters.js",
"js/detail-panel.js",
"js/summary.js",
"js/auto-detect.js",
"js/smart-context.js",
"js/error-intel.js",
"js/anomaly.js",
"js/control-panel.js",
"js/main.js",
]
def read_file(path):
"""Read a file and return its contents."""
full_path = os.path.join(SRC_DIR, path)
if not os.path.exists(full_path):
print(f" WARNING: Missing module: {path}")
return f"/* MODULE NOT FOUND: {path} */\n"
with open(full_path, "r", encoding="utf-8") as f:
return f.read()
def build():
"""Assemble all modules into a single HTML file."""
print("Building EDOG Log Viewer...")
print(f" Source: {SRC_DIR}")
print(f" Output: {OUTPUT_FILE}")
# Read the HTML shell
shell = read_file("index.html")
if "/* __CSS_MODULES__ */" not in shell:
print("ERROR: index.html missing /* __CSS_MODULES__ */ placeholder")
sys.exit(1)
if "/* __JS_MODULES__ */" not in shell:
print("ERROR: index.html missing /* __JS_MODULES__ */ placeholder")
sys.exit(1)
# Assemble CSS
css_parts = []
for module in CSS_MODULES:
content = read_file(module)
css_parts.append(f" /* === {module} === */")
css_parts.append(content)
print(f" CSS: {module} ({len(content)} bytes)")
all_css = "\n".join(css_parts)
# Assemble JS
js_parts = []
for module in JS_MODULES:
content = read_file(module)
js_parts.append(f"// === {module} ===")
js_parts.append(content)
print(f" JS: {module} ({len(content)} bytes)")
all_js = "\n".join(js_parts)
# Replace placeholders
output = shell.replace("/* __CSS_MODULES__ */", all_css)
output = output.replace("/* __JS_MODULES__ */", all_js)
# Write output
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
f.write(output)
total_css = sum(len(read_file(m)) for m in CSS_MODULES)
total_js = sum(len(read_file(m)) for m in JS_MODULES)
print(f"\n Total CSS: {total_css:,} bytes ({len(CSS_MODULES)} modules)")
print(f" Total JS: {total_js:,} bytes ({len(JS_MODULES)} modules)")
print(f" Output: {os.path.getsize(OUTPUT_FILE):,} bytes")
print(" Done!")
if __name__ == "__main__":
build()