From 15fe3864574d0a92f8d9612f0ab1da976ffc3ee0 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 Jul 2022 11:13:17 -0700 Subject: [PATCH] Fix build and minify html and js --- docs/library/hashlib.rst | 1 + requirements-dev.txt | 4 ++++ supervisor/shared/web_workflow/websocket.c | 3 +++ tools/gen_web_workflow_static.py | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/docs/library/hashlib.rst b/docs/library/hashlib.rst index 8e5ebc2d1a..061f9fd1e0 100644 --- a/docs/library/hashlib.rst +++ b/docs/library/hashlib.rst @@ -5,6 +5,7 @@ .. module:: hashlib :synopsis: hashing algorithms + :noindex: |see_cpython_module| :mod:`cpython:hashlib`. diff --git a/requirements-dev.txt b/requirements-dev.txt index 0b2e08163a..3b4411bd3a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -26,3 +26,7 @@ pyelftools # for stubs and annotations adafruit-circuitpython-typing + +# for web workflow minify +minify_html +jsmin diff --git a/supervisor/shared/web_workflow/websocket.c b/supervisor/shared/web_workflow/websocket.c index 8d3941b434..313e18a86d 100644 --- a/supervisor/shared/web_workflow/websocket.c +++ b/supervisor/shared/web_workflow/websocket.c @@ -26,6 +26,9 @@ #include "supervisor/shared/web_workflow/websocket.h" +// TODO: Remove ESP specific stuff. For now, it is useful as we refine the server. +#include "esp_log.h" + typedef struct { socketpool_socket_obj_t socket; uint8_t opcode; diff --git a/tools/gen_web_workflow_static.py b/tools/gen_web_workflow_static.py index 5f0febd084..b8c5baf619 100644 --- a/tools/gen_web_workflow_static.py +++ b/tools/gen_web_workflow_static.py @@ -4,6 +4,8 @@ import argparse import gzip +import minify_html +import jsmin import mimetypes import pathlib @@ -24,6 +26,10 @@ for f in args.files: variable = path.name.replace(".", "_") uncompressed = f.read() ulen = len(uncompressed) + if f.name.endswith(".html"): + uncompressed = minify_html.minify(uncompressed.decode("utf-8")).encode("utf-8") + elif f.name.endswith(".js"): + uncompressed = jsmin.jsmin(uncompressed.decode("utf-8")).encode("utf-8") compressed = gzip.compress(uncompressed) clen = len(compressed) compressed = ", ".join([hex(x) for x in compressed])