From e4977b08d55b69e503379cdc2f98a5589e1152e1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 1 Mar 2026 17:41:00 +0200 Subject: Move atom-to-HTML conversion from generate to atomfeed module generate::convert_gmi_atom_to_html_atom was atom feed logic that belonged in the atomfeed module. Renamed to atomfeed::convert_to_html and simplified by removing the format parameter (always HTML). Co-Authored-By: Claude Opus 4.6 --- lib/atomfeed.source.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/atomfeed.source.sh') diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh index 20a87d0..1e39db7 100644 --- a/lib/atomfeed.source.sh +++ b/lib/atomfeed.source.sh @@ -180,6 +180,27 @@ atomfeed::xmllint () { fi } +# Convert the Gemtext Atom feed to a HTML Atom feed by replacing .gmi +# extensions with .html and gemini:// with https:// protocol. +atomfeed::convert_to_html () { + if [ ! -f "$CONTENT_BASE_DIR/gemtext/gemfeed/atom.xml" ]; then + return + fi + + log INFO 'Converting Gemtext Atom feed to HTML Atom feed' + + if [ ! -d "$CONTENT_BASE_DIR/html/gemfeed" ]; then + mkdir -p "$CONTENT_BASE_DIR/html/gemfeed" + fi + + $SED 's|.gmi |.html |g; s|.gmi"|.html"|g; s|.gmi|.html|g; s|gemini://|https://|g' \ + < "$CONTENT_BASE_DIR/gemtext/gemfeed/atom.xml" \ + > "$CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp" + + atomfeed::xmllint "$CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp" && + mv "$CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp" "$CONTENT_BASE_DIR/html/gemfeed/atom.xml" +} + atomfeed::_insert_date () { local -r date="$1"; shift local -r gmi_file_path="$1"; shift -- cgit v1.2.3