aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhitlerrip <git@hitler.rip>2025-07-29 16:54:52 +0200
committerhitlerrip <git@hitler.rip>2025-07-29 16:54:52 +0200
commitd48ea3fff0f7a08e9acf2be7b11a58e063498bf8 (patch)
tree52c24750c429d2d8dbd689f4f950cc23373d544c
parent50d40eba7b3a56b82154b9b0d162d46cb1e8d3cb (diff)
downloadwebsite-d48ea3fff0f7a08e9acf2be7b11a58e063498bf8.tar.gz
website-d48ea3fff0f7a08e9acf2be7b11a58e063498bf8.tar.bz2
website-d48ea3fff0f7a08e9acf2be7b11a58e063498bf8.zip
initial sort
added a temporary script that sorts articles by date. more information coming when this is fully implemented in build.sh
-rwxr-xr-xsort.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/sort.sh b/sort.sh
new file mode 100755
index 0000000..10d64a1
--- /dev/null
+++ b/sort.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+# hitler.rip
+# temporary script that implements sorting articles by date
+# © 2025 hitler.rip <git@hitler.rip>
+# licensed under AGPLv3-or-later; see licenses/code.md for more information
+
+declare -A articlearr
+declare -a workingarr
+declare -A thebestarr
+
+cd ./src/articles/
+
+echo "[test] SECTION - DETERMINE DATE"
+
+for i in *.md; do
+
+ echo "[test] reading: $i"
+
+ filename=$( echo "$i" | rev | cut -c4- | rev )
+
+ if [ "$filename" != "index" ]; then
+
+ export WEBMETA_DATE=""
+
+ if [ -e "$filename.meta" ]; then
+ echo "[test] running script: $filename.meta"
+ source ./"$filename".meta
+ fi
+
+ if [ "$WEBMETA_DATE" == "" ]; then
+ export WEBMETA_DATE="2001-09-11*"
+ fi
+
+ articlearr["$filename"]="$WEBMETA_DATE"
+
+ fi
+
+done
+
+echo "[test] SECTION - SORT"
+
+workingarr=($( sort -nr < <(printf '%s\n' "${articlearr[@]}") ))
+
+for date in "${workingarr[@]}"; do
+
+ for key in "${!articlearr[@]}"; do
+ if [ "${articlearr[$key]}" == "$date" ]; then
+ echo "$date matches $key"
+ thebestarr["$date"]="$key"
+ fi
+ done
+
+done
+
+echo "[test] SECTION - GENERATE"
+
+# ...
+