about summary refs log tree commit diff
path: root/webp.sh
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-03-24 09:08:18 -0400
committerZach DeCook <zachdecook@librem.one>2021-03-24 09:08:18 -0400
commita1528e4ff26a09f85cde37884e1d9794aad5222d (patch)
tree49f456368697c129fd16931ba4562c63b971a380 /webp.sh
parent11651a67149dbb038d7492364a234c35d90449e7 (diff)
downloadcgi-bin-a1528e4ff26a09f85cde37884e1d9794aad5222d.tar.gz
webp: make script by copying from oeb
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 ''