#!/usr/bin/env python3 """Static export of the TYPO3 sites running in DDEV. Crawls each site (sitemap + internal links), pre-fetches the AJAX dates and price tables of product pages, rewrites *.ddev.site hosts to the production domains and copies every referenced static asset. The result is a set of plain document roots that run without PHP. With --hybrid the document roots sit in front of TYPO3 13 instead: product pages and the search are left out (TYPO3 13 serves them through index.php), the search UI stays (the search bar is refreshed from TYPO3 13), and the API is answered live. Usage: export.py [--site ep-reisen] [--url URL ...] [--no-follow] [--out DIR] [--hybrid --typo3-current PATH [--live-ajax]] """ import argparse import collections import concurrent.futures import hashlib import html import http.client import os import re import shutil import subprocess import sys import threading import urllib.error import urllib.parse import urllib.request APP_ROOT = os.environ.get('DDEV_APPROOT', '/var/www/html') PUBLIC = os.path.join(APP_ROOT, 'public') SITES_DIR = os.path.join(APP_ROOT, 'config', 'sites') # Hosts that pull from the production origin; their paths must exist in the export CDN_HOSTS = {'cdn.ep-reisen.de'} # Any attribute pointing at TYPO3's AJAX page type (product tables, HTMX teaser # popups, ...) is pre-fetched; JS may append "&pa=..." to these URLs AJAX_PATH = '/ajax/' # Forms posting to these TYPO3 plugins (contact, enquiry, application, booking, newsletter) # cannot work statically and are replaced by a contact notice CONTACT_FORM_RE = re.compile(r'