scripts for my gemini capsule
webp: make script by copying from oeb
Zach DeCook 2021-03-24
parent 11651a6 · commit a1528e4
-rwxr-xr-xindex.gmi19
-rw-r--r--makeplan.sh2
-rwxr-xr-xwebp.sh33
3 files changed, 53 insertions, 1 deletions
diff --git a/index.gmi b/index.gmi
new file mode 100755
index 0000000..66b694b
--- /dev/null
+++ b/index.gmi
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+printf '20 text/gemini \r\n
+
+#All Services
+## Experimental bible reading scripts
+=> /cgi-bin/esv.sh Wrapper for the English Standard Version API.
+=> /cgi-bin/net.sh Wrapper for New English Translation API.
+=> /cgi-bin/oeb.sh Open English Bible (WIP) rough script for reading.
+=> /cgi-bin/lsv.py Literal Standard Version script for reading.
+=> /cgi-bin/webp.sh World English Bible rough script for reading.
+
+## misc
+=> /cgi-bin/ccel.sh ccel.org frontend
+=> /cgi-bin/gcc.sh gccsatx.com/hymns frontend (with mp3s!)
+
+# source code for all this
+=> https://git.sr.ht/~earboxer/cgi-bin
+'
diff --git a/makeplan.sh b/makeplan.sh
index 2a02d03..4bb53e0 100644
--- a/makeplan.sh
+++ b/makeplan.sh
@@ -8,7 +8,7 @@ ps="$(grep "^$day" "$1" | cut -f4)"
pr="$(grep "^$day" "$1" | cut -f5)"
echo "# Old Testament Reading"
-gmni "gemini://gemini.zachdecook.com/cgi-bin/lsv.py?$ot"
+gmni "gemini://gemini.zachdecook.com/cgi-bin/webp.sh?$ot"
echo "# New Testament Reading"
gmni "gemini://gemini.zachdecook.com/cgi-bin/net.sh?$nt"
diff --git a/webp.sh b/webp.sh
new file mode 100755
index 0000000..fd87004
--- /dev/null
+++ b/webp.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+test "$QUERY_STRING" || QUERY_STRING="$1"
+if [ "$QUERY_STRING" = "" ]
+then
+ printf "10 Enter a scripture reference\r\n"
+ return
+fi
+
+# parse query
+book=$(echo $QUERY_STRING|cut -d' ' -f1)
+chstart=$(echo $QUERY_STRING|tr ':' ' ' |cut -d' ' -f2)
+vstart=$(echo $QUERY_STRING|tr '-' ':' | cut -d: -f2)
+# vend is always the last number
+vend=$(echo $QUERY_STRING |tr - : |rev|cut -d: -f1|rev)
+# chend is the last leftover
+chend=$(echo $QUERY_STRING|sed "s/$book//"| sed "s/:$vstart-/ /"|sed "s/ \?:\?$vend$//"|rev|cut -d' ' -f1|rev)
+#echo $chstart "\t" $vstart "\t" $chend "\t"$vend && exit
+
+bookabbrev=$(python3 -c "import bible; print(bible.parse_string('$book $chstart:$vstart-$chend:$vend')[0].start.format('a').upper())")
+file=$(find webp/ -name '*'-$bookabbrev'*')
+if ! test "$file"; then
+ printf "51 that book ($bookabbrev) not found.\r\n"
+ exit 1
+fi
+printf "20 text/gemini\r\n"
+echo '=>https://ebible.org/find/details.php?id=engwebp&all=1 This content from World English Bible (public domain)'
+echo '=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi'
+echo "# $book $chstart:$vstart - $chend:$vend"
+grep '\c '"$chstart " $file -A5000 | grep '\v '"$vstart " -A5000 \
+| tac|grep '\c '$(($chend + 1))' ' -A5000 | grep '\v '$vend' ' -A5000 | tac\
+| usfm2gmi/usfm2gmi.py
+# end in newline
+echo ''