Files
nixie-clock/firmware/uniclock/web/gzip_web.py
T
mangavalkandClaude Opus 5.5 b40b5f680c Replace the web UI with a single-file page
The upstream jQuery page (147 KB, 3-column grid, slider values hidden,
help behind label clicks, no save feedback) is replaced by
firmware/uniclock/web/index.html: one file, no jQuery, gzipped by
web/gzip_web.py to data/index.html.gz (12 KB) before every build.

- Tabs Home / Tubes / Light / Network / System, rows with label, help
  line and control; sliders always show their value
- "Saved" / "Not saved" after each change, reverted on failure; offline
  indicator with automatic retry (the old poll stopped after one error)
- WiFi and MQTT settings only save with a Save button, then offer a
  restart; password fields are write-only
- Controls for hardware this clock lacks (alarm, radar, sensors) hidden
- Runs on sample data when opened from disk

Firmware: one serveStatic route (gzip, no-cache + ETag) replaces the
per-file routes; /getConfiguration no longer returns passwords and adds
ip, hasAlarm, hasRadar and the real cathProtMin; /getCurrentInfos adds
currentSec and mqtt state and sends "lux" instead of "lx" when there is
no sensor; /cathodeProtect and /firmwareupdate now answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:06:35 +01:00

24 lines
968 B
Python

# Gzips web/index.html into the SPIFFS data folder (ESP32_UniClock2/data/index.html.gz).
# Runs before every PlatformIO build/uploadfs (extra_scripts in platformio.ini); also runs on its own:
# python web/gzip_web.py
# The web server sends the .gz file with Content-Encoding: gzip (serveStatic in ESP32_UniClock2.ino).
import gzip
import os
try:
Import("env") # noqa: F821 (PlatformIO/SCons)
root = env["PROJECT_DIR"] # noqa: F821
except NameError:
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
src = os.path.join(root, "web", "index.html")
dst = os.path.join(root, "ESP32_UniClock2", "data", "index.html.gz")
with open(src, "rb") as f:
packed = gzip.compress(f.read(), 9, mtime=0) # mtime=0: same input, same bytes (no git noise)
old = open(dst, "rb").read() if os.path.exists(dst) else b""
if packed != old:
with open(dst, "wb") as f:
f.write(packed)
print("gzip_web: %s (%d bytes)" % (dst, len(packed)))