diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-01 17:41:00 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-01 17:41:00 +0200 |
| commit | e4977b08d55b69e503379cdc2f98a5589e1152e1 (patch) | |
| tree | ddf06debfc5916b58ca09c40b2d92bdeab289293 /lib/atomfeed.source.sh | |
| parent | 6136b8a79a7f0ce5e35dc07cd88965953bd0e1af (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'lib/atomfeed.source.sh')
| -rw-r--r-- | lib/atomfeed.source.sh | 21 |
1 files changed, 21 insertions, 0 deletions
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</id>|.html</id>|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 |
