diff options
| author | Paul Buetow <paul@buetow.org> | 2023-03-27 23:09:31 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-03-27 23:09:31 +0300 |
| commit | 1582c209941bc6cd6aefe507c59fab4a8f99ceb8 (patch) | |
| tree | f2b33e0e61def7cb07c7c3bcd84f43027a4a8f8a /lib | |
| parent | 89eec1f1bacc0b69f454fdea7ffe3387010d6d95 (diff) | |
fix html atom feed
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/atomfeed.source.sh | 8 | ||||
| -rw-r--r-- | 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 <<ATOMFOOTER >> "$atom_file.tmp" </feed> 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</id>|.html</id>|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. |
