bash cat > /home/claude/build_tilda.py << 'PYEOF' import re CSS = open('/home/claude/site/css/style.scoped.css', encoding='utf-8').read() MAIN_JS = open('/home/claude/site/js/main.js', encoding='utf-8').read() CALC_JS = open('/home/claude/site/js/calculator.js', encoding='utf-8').read() CATALOG_JS = open('/home/claude/site/js/catalog.js', encoding='utf-8').read() # wrap main.js in an IIFE so it doesn't leak globals onto the Tilda page MAIN_JS_WRAPPED = "(function(){\n" + MAIN_JS + "\n})();" def build(page, extra_js_blocks, out_name): html = open(f'/home/claude/site/{page}', encoding='utf-8').read() # extract body inner content body_match = re.search(r'(.*)', html, re.S) body_inner = body_match.group(1) # remove the external stylesheet link and external script tags - # their content will be inlined instead body_inner = re.sub(r'\s*\s*', '\n', body_inner) body_inner = re.sub(r'\s*\s*', '\n', body_inner) body_inner = re.sub(r'\s*\s*', '\n', body_inner) body_inner = re.sub(r'\s*\s*', '\n', body_inner) # the stylesheet link was actually in , not body — handle head too head_match = re.search(r'(.*)', html, re.S) head_inner = head_match.group(1) if head_match else '' fonts_link = '' m = re.search(r'', head_inner) if m: fonts_link = m.group(0) inline_scripts = ''.join(f'\n\n' for js in extra_js_blocks) fragment = f''' {fonts_link}
{body_inner.strip()}
{inline_scripts} ''' open(f'/home/claude/site/{out_name}', 'w', encoding='utf-8').write(fragment) print('built', out_name, len(fragment), 'chars') build('index.html', [MAIN_JS_WRAPPED], 'tilda-index.html') build('catalog.html', [MAIN_JS_WRAPPED, CATALOG_JS], 'tilda-catalog.html') build('calculator.html', [MAIN_JS_WRAPPED, CALC_JS], 'tilda-calculator.html') build('process.html', [MAIN_JS_WRAPPED], 'tilda-process.html') build('contacts.html', [MAIN_JS_WRAPPED], 'tilda-contacts.html') PYEOF python3 /home/claude/build_tilda.py Output built tilda-index.html 44975 chars built tilda-catalog.html 39925 chars built tilda-calculator.html 43754 chars built tilda-process.html 37247 chars built tilda-contacts.html 34309 chars
Made on
Tilda