summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-08-24 19:41:47 +0300
committerPaul Buetow <paul@buetow.org>2024-08-24 19:41:47 +0300
commita7370ba21f9b4be497dcb10f47265d6eb9532819 (patch)
tree3dad476456beb8867a5d889d0f8aac30100b086d
parentbcdc16d4e59af05a07846ed704e3f75a122cd643 (diff)
check atomfeed before publishing
-rwxr-xr-xgemtexter4
-rw-r--r--lib/atomfeed.source.sh14
2 files changed, 17 insertions, 1 deletions
diff --git a/gemtexter b/gemtexter
index 8e4030d..fed77e6 100755
--- a/gemtexter
+++ b/gemtexter
@@ -145,6 +145,9 @@ main () {
gemfeed::generate
atomfeed::generate
;;
+ --verify)
+ atomfeed::verify
+ ;;
--generate)
if [ -x "$PRE_GENERATE_HOOK" ]; then
$PRE_GENERATE_HOOK
@@ -179,6 +182,7 @@ main () {
;;
--publish)
$0 --generate
+ $0 --verify
$0 --git
if [ -x "$POST_PUBLISH_HOOK" ]; then
$POST_PUBLISH_HOOK
diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh
index 079c2fb..53e54d5 100644
--- a/lib/atomfeed.source.sh
+++ b/lib/atomfeed.source.sh
@@ -91,6 +91,18 @@ ATOMFOOTER
fi
}
+atomfeed::verify () {
+ if [ $(find $CONTENT_BASE_DIR -name \*.xml.tmp | wc -l) -ge 1 ]; then
+ find $CONTENT_BASE_DIR -name \*.xml.tmp
+ log PANIC "Found incomplete Atom feed files with the suffix .xml.tmp"
+ fi
+ find $CONTENT_BASE_DIR -name atom.xml | while read -r atom_xml; do
+ atomfeed::xmllint "$atom_xml"
+ done
+
+ log INFO "Atom feed/s seem fine"
+}
+
atomfeed::_entry () {
local -r gemfeed_dir="$1"; shift
local -r gmi_file="$1"; shift
@@ -151,7 +163,7 @@ atomfeed::xmllint () {
local -r atom_feed="$1"
if [ -n "$XMLLINT" ]; then
- log INFO 'XMLLinting Atom feed'
+ log INFO "XMLLinting Atom feed $atom_feed"
if ! $XMLLINT "$atom_feed" >/dev/null; then
log PANIC "Atom feed $atom_feed isn't valid XML, please re-try"
return 2