1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

literature-quote: fix selection with xan

This commit is contained in:
2025-06-09 11:34:19 +02:00
parent 03c0e49572
commit 0025d82cd8

View File

@@ -9,23 +9,23 @@ writers.writeDashBin "literature-quote" ''
PATH=$PATH:${lib.makeBinPath [xan curl gnused]}
ROW=$(curl -Ls http://kmein.github.io/logotheca/quotes.csv | shuf -n1)
(
QUOTE="$(echo "$ROW" | xan select 4)"
QUOTE="$(echo "$ROW" | xan select 3)"
echo "$QUOTE" | sed 's/^"//;s/"$//;s/\s*||\s*/\n\n/g;s/\s*|\s*/\n/g'
echo
AUTHOR="$(echo "$ROW" | xan select 1)"
AUTHOR="$(echo "$ROW" | xan select 0)"
# Prepare the output
ATTRIBUTION="($AUTHOR"
SOURCE="$(echo "$ROW" | xan select 2)"
SOURCE="$(echo "$ROW" | xan select 1)"
# Add SOURCE if it's not empty
if [ -n "$SOURCE" ]; then
ATTRIBUTION="$ATTRIBUTION: $SOURCE"
fi
LOC="$(echo "$ROW" | xan select 3 | sed 's/""//;s/-//g')"
LOC="$(echo "$ROW" | xan select 2 | sed 's/""//;s/-//g')"
# Add LOC if it's not empty
if [ -n "$LOC" ]; then
ATTRIBUTION="$ATTRIBUTION, $LOC"