Fix: H1+Meta aus Joomla-Body strippen, Bild-Auto-Delete entfernt
- H1 und <p class=meta> werden vor dem Senden an Joomla aus dem Body gefiltert (Daniel 19.06.: Titel+Lesezeit dürfen nicht im Fließtext landen) - os.remove() für Bilder nach erfolgreichem Publish entfernt (Bilder bleiben auf Disk erhalten für spätere Referenz/Live-Schaltung)
This commit is contained in:
+9
-8
@@ -1112,6 +1112,12 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
|||||||
body_match = re.search(r'(?:</header>|</head>)(.*?)(?:<footer|<div class="quellen"|</body)', html_content, re.DOTALL)
|
body_match = re.search(r'(?:</header>|</head>)(.*?)(?:<footer|<div class="quellen"|</body)', html_content, re.DOTALL)
|
||||||
article_body = body_match.group(1) if body_match else html_content
|
article_body = body_match.group(1) if body_match else html_content
|
||||||
|
|
||||||
|
# ── Strip H1 + Meta-Zeile aus dem Body ─────────────────
|
||||||
|
# Daniel 19.06.: Titel und Lesezeit-Zeile dürfen NICHT im
|
||||||
|
# Fließtext landen — sie werden von Joomla separat gerendert.
|
||||||
|
article_body = re.sub(r'<h1[^>]*>.*?</h1>\s*', '', article_body, flags=re.DOTALL)
|
||||||
|
article_body = re.sub(r'<p\s+class="meta"[^>]*>.*?</p>\s*', '', article_body, flags=re.DOTALL)
|
||||||
|
|
||||||
# Extract Joomla ID if present (for updates)
|
# Extract Joomla ID if present (for updates)
|
||||||
jid_match = re.search(r'<meta\s+name="joomla-id"\s+content="(\d+)"', html_content, re.IGNORECASE)
|
jid_match = re.search(r'<meta\s+name="joomla-id"\s+content="(\d+)"', html_content, re.IGNORECASE)
|
||||||
joomla_id = jid_match.group(1) if jid_match else None
|
joomla_id = jid_match.group(1) if jid_match else None
|
||||||
@@ -1297,15 +1303,10 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
|||||||
with open(filepath, "w", encoding="utf-8") as f:
|
with open(filepath, "w", encoding="utf-8") as f:
|
||||||
f.write(html_content)
|
f.write(html_content)
|
||||||
|
|
||||||
# ── Auto-delete associated images ───────────────────────
|
# ── Image mapping cleanup: remove association but keep files ──
|
||||||
|
# Daniel 19.06.: Bilder NICHT löschen — sie werden für
|
||||||
|
# spätere Live-Schaltungen und Referenz benötigt.
|
||||||
if fname in img_map:
|
if fname in img_map:
|
||||||
for img_path in img_map[fname]:
|
|
||||||
if os.path.exists(img_path):
|
|
||||||
try:
|
|
||||||
os.remove(img_path)
|
|
||||||
images_deleted_total += 1
|
|
||||||
except OSError as e:
|
|
||||||
errors.append(f"{fname}: Bild {img_path} konnte nicht gelöscht werden: {e}")
|
|
||||||
del img_map[fname]
|
del img_map[fname]
|
||||||
save_image_map(img_map)
|
save_image_map(img_map)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user