diff --git a/scripts/patch_sidebar_layout.py b/scripts/patch_sidebar_layout.py new file mode 100644 index 0000000..a3fde4c --- /dev/null +++ b/scripts/patch_sidebar_layout.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +from pathlib import Path +import sys + +app_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path('/opt/virtuality/web/app.py') +templates_dir = app_path.parent / 'templates' +if not templates_dir.exists(): + raise SystemExit(f'templates dir not found: {templates_dir}') + +skip = {'login.html', 'console.html', '_sidebar.html'} +changed = [] +skipped = [] + +for path in sorted(templates_dir.glob('*.html')): + if path.name in skip: + skipped.append(f'{path.name}: skipped system/template') + continue + text = path.read_text() + if '{% include "_sidebar.html" %}' in text or "{% include '_sidebar.html' %}" in text: + skipped.append(f'{path.name}: already has sidebar') + continue + if '
' in text: + skipped.append(f'{path.name}: already v-layout') + continue + if '
' not in text: + skipped.append(f'{path.name}: no shell') + continue + + text = text.replace( + '\n
', + '\n
\n {% include "_sidebar.html" %}\n
\n
', + 1, + ) + + # Close shell/main/layout before scripts when page has JS block. + marker = '\n\n