From 1582c209941bc6cd6aefe507c59fab4a8f99ceb8 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 27 Mar 2023 23:09:31 +0300 Subject: fix html atom feed --- lib/atomfeed.source.sh | 8 +++++--- lib/generate.source.sh | 13 ++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh index 059bdda..cc810d1 100644 --- a/lib/atomfeed.source.sh +++ b/lib/atomfeed.source.sh @@ -79,7 +79,7 @@ ATOMHEADER cat <> "$atom_file.tmp" ATOMFOOTER - atomfeed::_xmllint "$atom_file.tmp" + atomfeed::xmllint "$atom_file.tmp" # Delete the 3rd line of the atom feeds (global feed update timestamp) if ! diff -u <($SED 3d "$atom_file") <($SED 3d "$atom_file.tmp"); then @@ -147,13 +147,15 @@ atomfeed::_entry () { ATOMENTRY } -atomfeed::_xmllint () { +atomfeed::xmllint () { local -r atom_feed="$1" if [ -n "$XMLLINT" ]; then log INFO 'XMLLinting Atom feed' - $XMLLINT "$atom_feed" >/dev/null || + if ! $XMLLINT "$atom_feed" >/dev/null; then log PANIC "Atom feed $atom_feed isn't valid XML, please re-try" + return 2 + fi log INFO 'Atom feed is OK' else log WARN 'Skipping XMLLinting Atom feed as "xmllint" command is no installed!' diff --git a/lib/generate.source.sh b/lib/generate.source.sh index 7c6d49d..51da3ce 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -69,9 +69,12 @@ generate::convert_gmi_atom_to_html_atom () { log INFO 'Converting Gemtext Atom feed to HTML Atom feed' - $SED 's|.gmi|.html|g; s|gemini://|https://|g' \ + $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 + > $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 @@ -126,6 +129,9 @@ generate::fromgmi () { log INFO "Generating $* from Gemtext" + # Add atom feed for HTML + generate::convert_gmi_atom_to_html_atom 'html' + # Add content while read -r src; do if test -n "$CONTENT_FILTER" && ! $GREP -q "$CONTENT_FILTER" <<< "$src"; then @@ -155,9 +161,6 @@ generate::fromgmi () { log INFO "Added $num_doc_files other documents to each of $*" - # Add atom feed for HTML - generate::convert_gmi_atom_to_html_atom 'html' & - # Remove obsolete files from ./html/. # Note: The _config.yml is the config file for GitHub pages (md format). # Anoter note: The CNAME file is required by GitHub pages as well for custom domains. -- cgit v1.2.3