1
0
mirror of https://github.com/kmein/niveum synced 2026-03-19 03:21:10 +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]} PATH=$PATH:${lib.makeBinPath [xan curl gnused]}
ROW=$(curl -Ls http://kmein.github.io/logotheca/quotes.csv | shuf -n1) 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 "$QUOTE" | sed 's/^"//;s/"$//;s/\s*||\s*/\n\n/g;s/\s*|\s*/\n/g'
echo echo
AUTHOR="$(echo "$ROW" | xan select 1)" AUTHOR="$(echo "$ROW" | xan select 0)"
# Prepare the output # Prepare the output
ATTRIBUTION="($AUTHOR" ATTRIBUTION="($AUTHOR"
SOURCE="$(echo "$ROW" | xan select 2)" SOURCE="$(echo "$ROW" | xan select 1)"
# Add SOURCE if it's not empty # Add SOURCE if it's not empty
if [ -n "$SOURCE" ]; then if [ -n "$SOURCE" ]; then
ATTRIBUTION="$ATTRIBUTION: $SOURCE" ATTRIBUTION="$ATTRIBUTION: $SOURCE"
fi 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 # Add LOC if it's not empty
if [ -n "$LOC" ]; then if [ -n "$LOC" ]; then
ATTRIBUTION="$ATTRIBUTION, $LOC" ATTRIBUTION="$ATTRIBUTION, $LOC"