From d48ea3fff0f7a08e9acf2be7b11a58e063498bf8 Mon Sep 17 00:00:00 2001 From: hitlerrip Date: Tue, 29 Jul 2025 16:54:52 +0200 Subject: initial sort added a temporary script that sorts articles by date. more information coming when this is fully implemented in build.sh --- sort.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 sort.sh 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 +# 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" + +# ... + -- cgit v1.2.3