#!/usr/bin/env python3 """ Final cleanup pass: 1. Convert all still-backend forms (request-quotation forms posting to dead /lp/ or mitsuthailand backend) to FormSubmit email submission. 2. Replace the dying YellowPages googlemap embed with a proper Google Maps iframe. 3. Neutralize dead /lp/www.mitsuthailand.com/... back-links to the local page (or home). """ import os, re, sys, urllib.parse sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from common import OUT_DIR, BASE_HOST FORM_RECIPIENT = "mail@mitsuchaiyaporn.com" # keep in sync with rewrite.py MAP_COORDS = "13.557229094780995,100.28916297408983" def convert_forms(html): """Rewrite any
whose action points at a dead backend (not local search, not already-formsubmit, not empty) to FormSubmit.""" def repl(m): open_tag, inner, close = m.group(1), m.group(2), m.group(3) am = re.search(r'action="([^"]*)"', open_tag) if not am: return m.group(0) action = am.group(1) low = action.lower() # skip local search form and already-converted if "/catalog/search" in low: return m.group(0) if "formsubmit" in low or low.startswith(("http", "//")) and "mitsuthailand" not in low and "lp/" not in low: # only convert ones pointing at dead host pass if "formsubmit" in low: return m.group(0) # Anything still pointing at mitsuthailand backend or /lp/ -> email form new_open = '' hidden = ('' '' '') # ensure a submit button exists (append one if the form has none) if "