aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhitlerrip <git@hitler.rip>2025-07-28 15:13:16 +0200
committerhitlerrip <git@hitler.rip>2025-07-28 15:13:16 +0200
commit85a3ff98423502e1aeaf5f08868d38090df9fdf1 (patch)
tree1e85fa8d7124ae7d32af1074ef4c1982b7926380
parent74e8e1ad4d02d1c2e39302b5bf2c85ec88c99ad5 (diff)
downloadwebsite-85a3ff98423502e1aeaf5f08868d38090df9fdf1.tar.gz
website-85a3ff98423502e1aeaf5f08868d38090df9fdf1.tar.bz2
website-85a3ff98423502e1aeaf5f08868d38090df9fdf1.zip
metadata handling
adds default values for when an article does not provide any metadata.
-rwxr-xr-xbuild.sh56
1 files 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
<item>
<title>$WEBMETA_TITLE</title>
- <pubDate>$(date -d "$WEBMETA_DATE" +"%a, %d %b %Y %H:%M:%S +0000" )</pubDate>
+ <pubDate>$(date -d "${WEBMETA_DATE:0:10}" +"%a, %d %b %Y %H:%M:%S +0000" )</pubDate>
<author>$WEBMETA_AUTHOR</author>
<description>$WEBMETA_SUMMARY</description>
<link>/$filename</link>