commit: 9e6f1aa8edf7d326cbf9fd38c9a9137aaaa5e5c5
parent 73328e74d5eea487070e8ee5dcfab1841c9134f5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 19 Nov 2024 11:48:37 +0100
new_article.sh: append to home.shtml as well
Diffstat:
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/new_article.sh b/new_article.sh
@@ -9,7 +9,7 @@ case $# in
file="${1}"
;;
*)
- echo 'Usage: articles/new.sh [filename] <title>'
+ echo 'Usage: new_article.sh [filename] <title>'
exit 1
;;
esac
@@ -19,9 +19,9 @@ timestamp="$(date -u +%FT%TZ)"
ht=" "
WORKDIR="$(dirname $0)"
-if grep -q "/articles/${file}" 'feed.atom.in'
+if grep -q -F "/articles/${file}" "${WORKDIR}/feed.atom.in"
then
- echo 'Error: article already in feed.atom.in'
+ echo 'new_article: error: article already in feed.atom.in'
exit 1
else
ed "${WORKDIR}/feed.atom.in" <<-EOF
@@ -34,6 +34,21 @@ q
EOF
fi
+if grep -q -F "/articles/${file}" "${WORKDIR}/home.shtml"
+then
+ echo 'new_article: error: article already in home.shtml'
+ exit 1
+else
+ ed "${WORKDIR}/home.shtml" <<-EOF
+/new.sh: new articles here/
+a
+ <li>$(date -u +%F): <a href="/${file_url}">${title}</a></li>
+.
+w
+q
+EOF
+fi
+
cat >"${WORKDIR}/articles/${file}.xml" <<-EOF
<entry>
<title>${title}</title>