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