diff options
| -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 |
