AI Implementation feature(1087): Mastodon Post Composition and Publishing (#6)

This commit was merged in pull request #6.
This commit is contained in:
2026-08-04 18:57:46 +00:00
parent 7d39f3a339
commit e30fa78019
17 changed files with 680 additions and 69 deletions
+19 -2
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import calendar
import logging
import re
import unicodedata
from dataclasses import dataclass
from datetime import date, datetime
from pathlib import Path
@@ -15,6 +16,8 @@ _LOGGER = logging.getLogger("tenbackward.matching")
_FILENAME_PATTERN = re.compile(r"^(\d{4})-(\d{2})-(\d{2})-(.+)$")
_NON_ALNUM_RE = re.compile(r"[^a-z0-9]+")
_DEFAULT_TZ = "Europe/Berlin"
@@ -26,6 +29,19 @@ class MatchedPost:
url: str
def slugify_title(title: str) -> str:
"""Return a URL-safe slug derived from ``title``.
Used by the matcher to derive the slug component of
:attr:`MatchedPost.url` from the resolved post title.
"""
normalized = unicodedata.normalize("NFKD", title)
ascii_only = normalized.encode("ascii", "ignore").decode("ascii")
lowered = ascii_only.lower()
dashed = _NON_ALNUM_RE.sub("-", lowered)
return dashed.strip("-")
def _today_in_berlin(tz_name: str = _DEFAULT_TZ) -> date:
return datetime.now(ZoneInfo(tz_name)).date()
@@ -152,7 +168,7 @@ def _process_file(
path=rel,
title=title,
date=post_date,
url=_build_url(site_url, post_date, fn_slug),
url=_build_url(site_url, post_date, slugify_title(title)),
)
@@ -206,4 +222,5 @@ __all__ = [
"MatchedPost",
"find_anniversary_matches",
"iter_anniversary_paths",
]
"slugify_title",
]