Feature: Map authors as tags in Vorname_Nachname format

- Added format_author_as_tag() function to convert author names to tag format
- Author names automatically added to tags with spaces replaced by underscores
- Example: 'Jörg Lohrer' → 'Jörg_Lohrer' tag
- Enables author filtering via WordPress tag taxonomy
- Updated documentation to reflect new author handling approach
- Version bump to 0.3.0
This commit is contained in:
Jörg Lohrer 2025-11-05 05:32:20 +01:00
parent 141b847e97
commit 85f58e2528
3 changed files with 72 additions and 3 deletions

View file

@ -1,5 +1,36 @@
# Changelog
## Version 0.3.0 (2025-10-01)
### Feature - Autor-zu-Tag-Mapping 🏷️
**Neues Feature:** Autoren werden automatisch als Tags hinzugefügt!
**Funktion:**
- Autor aus Frontmatter wird extrahiert (`author`, `#staticSiteGenerator.author`, `#commonMetadata.creator`)
- Autor-Name wird automatisch als Tag im Format `Vorname_Nachname` hinzugefügt
- Leerzeichen werden durch Unterstriche ersetzt
- Mehrfache Unterstriche werden konsolidiert
**Beispiel:**
```yaml
author: Jörg Lohrer
tags:
- OER
- Community
```
**Ergebnis:**
- Tags in WordPress: `OER`, `Community`, `Jörg_Lohrer`
- Filterung nach Autoren über WordPress-Tag-Taxonomie möglich
**Technische Details:**
- Neue Funktion `format_author_as_tag()` in `markdown_parser.py`
- Autor-Tag wird nur hinzugefügt, wenn Autor vorhanden und noch nicht in Tags
- Integration in `extract_wordpress_metadata()` nach Autor-Extraktion
---
## Version 0.2.2 (2025-10-01)
### Bugfix - Kritisch! 🐛

View file

@ -7,9 +7,10 @@ Automatisierter Workflow zum Erstellen von WordPress-Beiträgen aus Markdown-Dat
## ⚠️ Bekannte Einschränkungen
**Autor-Zuordnung:**
- Beiträge werden aktuell immer dem importierenden WordPress-Benutzer zugeordnet
- Der `author` aus dem Frontmatter wird extrahiert, aber nicht mit WordPress-Benutzern abgeglichen
- **Zu entwickeln:** Automatisches Mapping von Frontmatter-Autoren zu WordPress-User-IDs oder manuelle Zuordnungs-Konfiguration
- Beiträge werden immer dem importierenden WordPress-Benutzer zugeordnet (WordPress REST-API Limitation)
- Der `author` aus dem Frontmatter wird automatisch als **Tag** im Format `Vorname_Nachname` hinzugefügt
- Beispiel: `author: Jörg Lohrer` → Tag: `Jörg_Lohrer`
- Dies ermöglicht die Filterung nach Autoren über die WordPress-Tag-Taxonomie
**Forgejo-Repository-Import:**
- Die Batch-Verarbeitung ganzer Repositories wurde noch nicht ausreichend getestet
@ -21,6 +22,7 @@ Automatisierter Workflow zum Erstellen von WordPress-Beiträgen aus Markdown-Dat
## Features
- ✅ **Automatische Metadaten-Extraktion**: name, description, tags, image, author aus YAML-Frontmatter
- ✅ **Autor-zu-Tag-Mapping**: Autoren werden automatisch als Tags im Format `Vorname_Nachname` hinzugefügt
- ✅ **Drei Verwendungsmodi**: Einzelne URL, YAML-Batch, Forgejo-Repository
- ✅ **Duplikatsprüfung**: Verhindert das doppelte Erstellen von Beiträgen und Medien
- ✅ **Markdown zu HTML**: Automatische Konvertierung von Markdown-Inhalten

View file

@ -39,6 +39,29 @@ def extract_frontmatter(markdown_content: str) -> tuple[Optional[Dict[str, Any]]
return None, markdown_content
def format_author_as_tag(author_name: str) -> str:
"""
Formatiert einen Autornamen als Tag im Format Vorname_Nachname
Args:
author_name: Autorenname (z.B. "Max Mustermann" oder "Max")
Returns:
Tag-formatierter Name (z.B. "Max_Mustermann")
"""
# Entferne führende/nachfolgende Leerzeichen
author_name = author_name.strip()
# Ersetze Leerzeichen durch Unterstriche
tag_name = author_name.replace(' ', '_')
# Entferne mehrfache Unterstriche
while '__' in tag_name:
tag_name = tag_name.replace('__', '_')
return tag_name
def extract_wordpress_metadata(frontmatter: Dict[str, Any],
default_author: str = "admin") -> Dict[str, Any]:
"""
@ -94,6 +117,10 @@ def extract_wordpress_metadata(frontmatter: Dict[str, Any],
elif isinstance(tags, str):
metadata['tags'] = [t.strip() for t in tags.split(',')]
# Initialisiere tags falls nicht vorhanden
if 'tags' not in metadata:
metadata['tags'] = []
# Kategorien extrahieren (falls vorhanden)
if 'categories' in frontmatter:
categories = frontmatter['categories']
@ -134,6 +161,15 @@ def extract_wordpress_metadata(frontmatter: Dict[str, Any],
if 'author' not in metadata:
metadata['author'] = default_author
# Autor als Tag hinzufügen (Format: Vorname_Nachname)
if metadata.get('author'):
author_tag = format_author_as_tag(metadata['author'])
# Füge Autor-Tag zu den Tags hinzu, falls noch nicht vorhanden
if author_tag and author_tag not in metadata.get('tags', []):
if 'tags' not in metadata:
metadata['tags'] = []
metadata['tags'].append(author_tag)
# Status extrahieren (falls vorhanden)
if 'status' in frontmatter:
metadata['status'] = frontmatter['status']