feat: update version to v1.2.0 and add upgrade link in HTML files

This commit is contained in:
2025-02-17 10:46:56 +01:00
parent 03cbf82275
commit 4e384d777e
11 changed files with 89 additions and 70 deletions

View File

@ -1,7 +1,10 @@
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")
@ -18,14 +21,14 @@ def combine_html_files(source, target, env):
with open(file_path, 'r') as f:
content = f.read()
# Replace placeholder with header content
if '{{header}}' in content:
new_content = content.replace('{{header}}', header_content)
# Write back combined content
with open(file_path, 'w') as f:
f.write(new_content)
print(f"Combined header with {filename}")
# 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)

View File

@ -22,4 +22,4 @@ def replace_version(source, target, env):
with open(header_file, 'w') as file:
file.write(content)
env.AddPreAction("buildfs", replace_version)
env.AddPreAction("buildfs", replace_version)