landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Integrera infographic-komponenter på alla quiXzoom landningssidor.
|
||||
Användning: python3 integrate.py [--dry-run]
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).parent.parent
|
||||
COMPONENTS = ROOT / "se" / "_components"
|
||||
|
||||
def read_component(name):
|
||||
"""Läs en komponentfil och returnera innehållet."""
|
||||
path = COMPONENTS / name
|
||||
if not path.exists():
|
||||
print(f"❌ Komponent saknas: {path}")
|
||||
sys.exit(1)
|
||||
return path.read_text(encoding='utf-8')
|
||||
|
||||
def inject_before_body_end(html_path, content_to_inject, wrapper_class="section"):
|
||||
"""Injicera innehåll före </body>."""
|
||||
content = html_path.read_text(encoding='utf-8')
|
||||
|
||||
# Kolla om redan injicerad
|
||||
if 'infographic' in content and 'lv-infographic' in content_to_inject:
|
||||
return False, "Redan integrerad"
|
||||
if 'infographic' in content and 'qz-infographic' in content_to_inject:
|
||||
return False, "Redan integrerad"
|
||||
if 'infographic' in content and 'lb-infographic' in content_to_inject:
|
||||
return False, "Redan integrerad"
|
||||
|
||||
# Hitta </body> och injicera före
|
||||
body_end = content.rfind('</body>')
|
||||
if body_end == -1:
|
||||
return False, "Ingen </body> hittad"
|
||||
|
||||
# Bygg injektion
|
||||
injection = f'''
|
||||
<!-- === INFOGRAPHIC INJECTED === -->
|
||||
<div class="{wrapper_class}">
|
||||
<div class="container">
|
||||
{content_to_inject}
|
||||
</div>
|
||||
</div>
|
||||
<!-- === END INFOGRAPHIC === -->
|
||||
'''
|
||||
|
||||
new_content = content[:body_end] + injection + '\n' + content[body_end:]
|
||||
html_path.write_text(new_content, encoding='utf-8')
|
||||
return True, "Integrerad"
|
||||
|
||||
def process_main_page(dry_run=False):
|
||||
"""Uppdatera huvudsida med combined flow."""
|
||||
path = ROOT / "se" / "index.html"
|
||||
infographic = read_component("infographic-flow.html")
|
||||
|
||||
if dry_run:
|
||||
print(f" [DRY-RUN] Skulle integrera combined flow på: {path}")
|
||||
return
|
||||
|
||||
success, msg = inject_before_body_end(path, infographic, "section")
|
||||
status = "✅" if success else "⚠️"
|
||||
print(f" {status} {path.name}: {msg}")
|
||||
|
||||
def process_industry_pages(dry_run=False):
|
||||
"""Uppdatera alla branschsidor med zoomer-journey."""
|
||||
infographic = read_component("infographic-zoomer.html")
|
||||
se_dir = ROOT / "se"
|
||||
|
||||
count = 0
|
||||
for subdir in sorted(se_dir.iterdir()):
|
||||
if not subdir.is_dir():
|
||||
continue
|
||||
if subdir.name.startswith('_'):
|
||||
continue
|
||||
if subdir.name == 'index.html':
|
||||
continue
|
||||
|
||||
html_file = subdir / "index.html"
|
||||
if not html_file.exists():
|
||||
continue
|
||||
|
||||
if dry_run:
|
||||
print(f" [DRY-RUN] Skulle integrera zoomer-journey på: {subdir.name}/index.html")
|
||||
count += 1
|
||||
continue
|
||||
|
||||
success, msg = inject_before_body_end(html_file, infographic, "section section-gray")
|
||||
status = "✅" if success else "⚠️"
|
||||
print(f" {status} {subdir.name}/index.html: {msg}")
|
||||
if success:
|
||||
count += 1
|
||||
|
||||
return count
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Integrera infographics på quiXzoom landningssidor")
|
||||
parser.add_argument('--dry-run', action='store_true', help='Simulera utan att ändra filer')
|
||||
args = parser.parse_args()
|
||||
|
||||
print("=== quiXzoom Infographic Integration ===\n")
|
||||
|
||||
# Verifiera komponenter finns
|
||||
for comp in ['infographic-flow.html', 'infographic-zoomer.html', 'infographic-business.html']:
|
||||
path = COMPONENTS / comp
|
||||
if not path.exists():
|
||||
print(f"❌ Komponent saknas: {comp}")
|
||||
sys.exit(1)
|
||||
print(f" 📦 {comp} ({path.stat().st_size:,} bytes)")
|
||||
|
||||
print()
|
||||
|
||||
# 1. Huvudsida
|
||||
print("1. Uppdaterar huvudsida (se/index.html)...")
|
||||
process_main_page(dry_run=args.dry_run)
|
||||
|
||||
# 2. Branschsidor
|
||||
print("\n2. Uppdaterar branschsidor...")
|
||||
count = process_industry_pages(dry_run=args.dry_run)
|
||||
|
||||
print(f"\n=== Sammanfattning ===")
|
||||
if args.dry_run:
|
||||
print(f"[DRY-RUN] Skulle uppdatera {count} filer")
|
||||
else:
|
||||
print(f"Uppdaterade {count} filer")
|
||||
|
||||
print("\nNästa steg:")
|
||||
print(" 1. Testa lokalt: öppna filerna i webbläsare")
|
||||
print(" 2. aws s3 sync se/ s3://quixzoom-landing-prod/markets/se/")
|
||||
print(" 3. CloudFront invalidation")
|
||||
print(" 4. Verifiera på https://quixzoom.se")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user