scripts for my gemini capsule
Diffstat (limited to 'webp.sh')
-rwxr-xr-xwebp.sh33
1 files changed, 33 insertions, 0 deletions
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 ''