From eaf169045a1106935dd887d8d795d0138ad2b8a5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 9 Jun 2026 05:00:53 -0500 Subject: refactor(theme-studio): extract CSS and JS to files, inline at generate time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit generate.py was 1378 lines, ~1300 of them a single triple-quoted string holding the whole app. Moved the +STYLES_CSS

Untitled: theme

@@ -576,830 +496,22 @@ HTML = """theme-studio
""" -HTML=(HTML.replace("COLORMATH_J",COLORMATH_BODY) - .replace("SAMPLES_J",json.dumps(SAMPLES)) - .replace("PALETTE_J",json.dumps(PALETTE)).replace("CATS_J",json.dumps(CATS)) - .replace("UIFACES_J",json.dumps(UI_FACES)).replace("UIMAP_J",json.dumps(UIMAP)).replace("APPS_J",json.dumps(APPS)) - .replace("BOLD_J",json.dumps(BOLD)).replace("MAP_J",json.dumps(MAP)).replace("LOCKS_J",json.dumps(LOCKS)).replace("ITALIC_J",json.dumps({k:True for k in ITALIC}))) +APP_JS""" +# Fill the data placeholders. str.replace is literal (no backref interpretation), +# so backslashes in the inlined JS survive intact — the escaping-bug class that +# the triple-quoted string used to cause is gone now that app.js is a real file. +def fill_data(s): + return (s.replace("COLORMATH_J",COLORMATH_BODY) + .replace("SAMPLES_J",json.dumps(SAMPLES)) + .replace("PALETTE_J",json.dumps(PALETTE)).replace("CATS_J",json.dumps(CATS)) + .replace("UIFACES_J",json.dumps(UI_FACES)).replace("UIMAP_J",json.dumps(UIMAP)).replace("APPS_J",json.dumps(APPS)) + .replace("BOLD_J",json.dumps(BOLD)).replace("MAP_J",json.dumps(MAP)).replace("LOCKS_J",json.dumps(LOCKS)).replace("ITALIC_J",json.dumps({k:True for k in ITALIC}))) + +# Splice the stylesheet and script in first, then fill the data placeholders they +# carry. The page contains app.js exactly as fill_data(APP_BODY) renders it — +# APP_FILLED is that rendering, the handle the inline-integrity test asserts on. +HTML=fill_data(HTML.replace("STYLES_CSS",STYLES).replace("APP_JS",APP_BODY)) +APP_FILLED=fill_data(APP_BODY) OUT=os.path.join(HERE,'theme-studio.html') if __name__=='__main__': -- cgit v1.2.3