# SPDX-FileCopyrightText: 2026 Dennis Fink # # SPDX-License-Identifier: BSD-3-Clause from pathlib import Path from bs4 import BeautifulSoup from flask import Flask BASE_URL = "https://dennisfink.me/blog/" SOURCE_URL = f"{BASE_URL}example/" def parse_html(html: str) -> BeautifulSoup: return BeautifulSoup(html, "html5lib") def write_post( root: Path, slug: str, content: str, *, canonical: str | None = None, entry_url: str | None = None, ) -> Path: directory = root / slug directory.mkdir(parents=True, exist_ok=True) source_url = f"{BASE_URL}{slug}/" if canonical is None: canonical = source_url if entry_url is None: entry_url = source_url path = directory / "index.html" path.write_text( f"""
Permalink
{content}
""", encoding="utf-8", ) return path def configure_scanner(app: Flask, root: Path, *, base_url: str | None = None) -> None: app.config["SOURCE_DIRECTORY"] = str(root) app.config["SOURCE_BASE_URL"] = base_url