Remove deprecated HTML files and scripts, refactor API to support asynchronous requests, and improve WebSocket handling for scale actions.
This commit is contained in:
1 parent
823d1f8c7e
commit
13a0acf2ac
20 files changed
+260
-2147
No files matched your search
@@ -1,34 +0,0 @@
|
||||
Import("env")
|
||||
import os
|
||||
import re
|
||||
|
||||
def combine_html_files(source, target, env):
|
||||
print("COMBINE HTML FILES")
|
||||
|
||||
html_dir = "./html"
|
||||
header_file = os.path.join(html_dir, "header.html")
|
||||
|
||||
# Read header content
|
||||
with open(header_file, 'r') as f:
|
||||
header_content = f.read()
|
||||
|
||||
# Process all HTML files except header.html
|
||||
for filename in os.listdir(html_dir):
|
||||
if filename.endswith('.html') and filename != 'header.html':
|
||||
file_path = os.path.join(html_dir, filename)
|
||||
|
||||
# Read content
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Replace content between head comments with header content
|
||||
pattern = r'(<!-- head -->).*?(<!-- head -->)'
|
||||
new_content = re.sub(pattern, r'\1' + header_content + r'\2', content, flags=re.DOTALL)
|
||||
|
||||
# Write back combined content
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(new_content)
|
||||
print(f"Combined header with {filename}")
|
||||
|
||||
# Register the script to run before building SPIFFS
|
||||
env.AddPreAction("buildfs", combine_html_files)
|
||||
@@ -1,48 +0,0 @@
|
||||
import gzip
|
||||
import os
|
||||
import shutil
|
||||
|
||||
## gzip files
|
||||
|
||||
def compress_file(input_file, output_file):
|
||||
with open(input_file, 'rb') as f_in:
|
||||
with gzip.open(output_file, 'wb') as f_out:
|
||||
f_out.writelines(f_in)
|
||||
|
||||
def copy_file(input_file, output_file):
|
||||
shutil.copy2(input_file, output_file)
|
||||
|
||||
def should_compress(file):
|
||||
# Skip compression for spoolman.html
|
||||
if file == 'spoolman.html' or file == 'waage.html':
|
||||
return False
|
||||
# Komprimiere nur bestimmte Dateitypen
|
||||
return file.endswith(('.js', '.png', '.css', '.html'))
|
||||
|
||||
def main(source_dir, target_dir):
|
||||
for root, dirs, files in os.walk(source_dir):
|
||||
rel_path = os.path.relpath(root, source_dir)
|
||||
for file in files:
|
||||
input_file = os.path.join(root, file)
|
||||
output_file_compressed = os.path.join(target_dir, rel_path, file + '.gz')
|
||||
output_file_original = os.path.join(target_dir, rel_path, file)
|
||||
|
||||
os.makedirs(os.path.dirname(output_file_compressed), exist_ok=True)
|
||||
|
||||
if should_compress(file):
|
||||
compress_file(input_file, output_file_compressed)
|
||||
print(f'Compressed {input_file} to {output_file_compressed}')
|
||||
else:
|
||||
copy_file(input_file, output_file_original)
|
||||
print(f'Copied {input_file} to {output_file_original}')
|
||||
|
||||
def init():
|
||||
source_dir = 'html'
|
||||
target_dir = 'data'
|
||||
|
||||
if os.path.exists(target_dir):
|
||||
shutil.rmtree(target_dir)
|
||||
|
||||
main(source_dir, target_dir)
|
||||
|
||||
init()
|
||||
Reference in new issue
Block a user