From 85a3ff98423502e1aeaf5f08868d38090df9fdf1 Mon Sep 17 00:00:00 2001 From: hitlerrip Date: Mon, 28 Jul 2025 15:13:16 +0200 Subject: metadata handling adds default values for when an article does not provide any metadata. --- build.sh | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/build.sh b/build.sh index 906167f..19653ff 100755 --- a/build.sh +++ b/build.sh @@ -84,6 +84,9 @@ for i in *.md; do if [ "$filename" == "index" ]; then echo "[build] skipping index file for later..." + + cp "$i" ../../web/articles/ + else mkdir -p ../../web/articles/"$filename"/ @@ -95,26 +98,37 @@ for i in *.md; do cp "$i" ../../web/articles/"$filename"/index.md - fi - - cp "$i" ../../web/articles/ - - # sort this by date - - if [ -e "$filename".meta ]; then - source ./"$filename".meta - # `.meta` is a simple shell script that uses `export` to - # set some variables, notably: - # WEBMETA_TITLE (title string) - # WEBMETA_DATE (date string YYYY-MM-DD) - # WEBMETA_AUTH (author string) - # WEBMETA_SUMMARY (summary string) - # please note that you have to actually check if this data is correct - # and you should not just import random `.meta` files as they can arbitrarily - # execute code on your system and are directly injected into the HTML. - export WEBMETA_BASELINK="https://hitler.rip/articles/" - # you will also have to manually change this link to the final destination - # of your articles so that the RSS feed can successfully link there. + export WEBMETA_TITLE="" + export WEBMETA_DATE="" + export WEBMETA_AUTH="" + export WEBMETA_SUMMARY="" + + if [ -e "$filename".meta ]; then + echo "[build] running script: $filename.meta" + source ./"$filename".meta + # `.meta` is a simple shell script that uses `export` to + # set some variables, notably: + # WEBMETA_TITLE (title string) + # WEBMETA_DATE (date string YYYY-MM-DD) + # WEBMETA_AUTH (author string) + # WEBMETA_SUMMARY (summary string) + # please note that you have to actually check if this data is correct + # and you should not just import random `.meta` files as they can arbitrarily + # execute code on your system and are directly injected into the HTML. + fi + + if [ "$WEBMETA_DATE" == "" ]; then + export WEBMETA_DATE="2001-09-11*REDACTED!*" + fi + if [ "$WEBMETA_AUTH" == "" ]; then + export WEBMETA_AUTH="Anonymous" + fi + if [ "$WEBMETA_SUMMARY" == "" ]; then + export WEBMETA_SUMMARY="redacted" + fi + if [ "$WEBMETA_TITLE" == "" ]; then + export WEBMETA_TITLE="$filename" + fi touch ../../tmp/articles/gen-articles-tmp-list.html tee -a ../../tmp/articles/gen-articles-tmp-list.html > /dev/null << EOF @@ -129,7 +143,7 @@ EOF tee -a ../../tmp/articles/gen-articles-tmp-rss.xml > /dev/null << EOF $WEBMETA_TITLE - $(date -d "$WEBMETA_DATE" +"%a, %d %b %Y %H:%M:%S +0000" ) + $(date -d "${WEBMETA_DATE:0:10}" +"%a, %d %b %Y %H:%M:%S +0000" ) $WEBMETA_AUTHOR $WEBMETA_SUMMARY /$filename -- cgit v1.2.3