feat: add wiki publishing tooling

This commit is contained in:
2026-05-28 11:32:36 +08:00
parent fee9b13ada
commit cda0db06db
10 changed files with 1558 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
import sys
from playwright.sync_api import sync_playwright
BASE_URL = "http://192.168.195.241:38353"
PAGES = [
("zh Vulture", f"{BASE_URL}/zh/home/Space_Shuttles/Vulture_Shuttle"),
("en Vulture", f"{BASE_URL}/en/home/Space_Shuttles/Vulture_Shuttle"),
("zh Echo", f"{BASE_URL}/zh/home/Space_Shuttles/Echo_Shuttle"),
("en Echo", f"{BASE_URL}/en/home/Space_Shuttles/Echo_Shuttle"),
("zh Enterprise", f"{BASE_URL}/zh/home/Space_Shuttles/Enterprise_Shuttle"),
("en Enterprise", f"{BASE_URL}/en/home/Space_Shuttles/Enterprise_Shuttle"),
]
def main():
errors = []
print("lightbox_validation_start", flush=True)
with sync_playwright() as playwright:
print("launching_chromium", flush=True)
browser = playwright.chromium.launch(headless=True, timeout=30000)
for label, url in PAGES:
print(f"checking={label}", flush=True)
page = browser.new_page(viewport={"width": 1366, "height": 900})
page.goto(url, wait_until="commit", timeout=30000)
page.wait_for_timeout(1500)
article = page.locator(".wiki-article, .vulture-article").first
image = page.locator(".wiki-article img[data-wiki-asset], .vulture-article img[data-wiki-asset]").first
image.wait_for(state="visible", timeout=20000)
ready = article.get_attribute("data-lightbox-ready")
print(f"{label}: ready={ready}", flush=True)
if ready != "1":
errors.append(f"{label}: lightbox script not installed, ready={ready!r}")
page.close()
continue
image.click(timeout=10000)
overlay = page.locator(".wiki-image-lightbox:not([hidden])")
try:
overlay.wait_for(state="visible", timeout=5000)
preview_src = overlay.locator("img").first.get_attribute("src") or ""
caption = overlay.locator("figcaption").first.inner_text(timeout=5000).strip()
if not preview_src:
errors.append(f"{label}: empty preview src")
if not caption:
errors.append(f"{label}: empty caption")
print(f"{label}: lightbox_open=True caption_len={len(caption)} preview_src={preview_src[:96]}", flush=True)
page.keyboard.press("Escape")
page.wait_for_function("!document.querySelector('.wiki-image-lightbox:not([hidden])')", timeout=5000)
except Exception as exc:
errors.append(f"{label}: {type(exc).__name__}: {exc}")
page.close()
browser.close()
if errors:
print("ERRORS:")
for error in errors:
print(error)
return 1
print("lightbox_click_validation=ok")
return 0
if __name__ == "__main__":
sys.exit(main())