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 | |
| 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>
| -rw-r--r-- | lib/atomfeed.source.sh | 21 | ||||
| -rw-r--r-- | lib/generate.source.sh | 29 |
2 files changed, 23 insertions, 27 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 diff --git a/lib/generate.source.sh b/lib/generate.source.sh index 17322e7..a62db34 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -91,31 +91,6 @@ generate::fromgmi_cleanup_docs () { fi } -# Convert the Gemtext Atom feed to a HTML Atom feed. -generate::convert_gmi_atom_to_html_atom () { - local -r format="$1"; shift - if [[ "$format" != html ]]; then - return - fi - - 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" -} - # Internal helper function for generate::fromgmi generate::_to_output_format () { local -r src="$1"; shift @@ -230,8 +205,8 @@ generate::fromgmi () { # Check if global deps changed (header, footer, CSS, config) generate::_check_global_deps - # Add atom feed for HTML - generate::convert_gmi_atom_to_html_atom 'html' + # Convert Gemtext Atom feed to HTML Atom feed + atomfeed::convert_to_html # Add content while read -r src; do |
