From 82744075fdd8be41033463d6ee7134b1f63fd7c9 Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 20 Apr 2019 01:50:10 +0200 Subject: Building minimal JSON datafiles + rewrites from ranking page URLs --- bin/datafiles-htaccess.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 bin/datafiles-htaccess.sh (limited to 'bin/datafiles-htaccess.sh') diff --git a/bin/datafiles-htaccess.sh b/bin/datafiles-htaccess.sh new file mode 100755 index 0000000..ab04bb0 --- /dev/null +++ b/bin/datafiles-htaccess.sh @@ -0,0 +1,17 @@ +#!/bin/bash +CONFIG=$1 +HTACCESS_FILE=$2 +cat $HTACCESS_FILE | + sed -e '/^# auto-generated from this point below$/,$d' > $HTACCESS_FILE.tmp +echo '' >> $HTACCESS_FILE.tmp +echo '# auto-generated from this point below' >> $HTACCESS_FILE.tmp +cat $CONFIG | + jq -r '.[] | .date, .url' | xargs -n 2 | + while read DATE URL + do + PREFIX="${URL//.html/}" + echo "RewriteRule $PREFIX.json _data/$DATE.json [L]" >> $HTACCESS_FILE.tmp + echo "RewriteRule $PREFIX.minimal.json _data/$DATE.minimal.json [L]" >> $HTACCESS_FILE.tmp + echo "RewriteRule $PREFIX.csv https://raw.githubusercontent.com/emkael/pzbs-ranking/master/data/rankings/$DATE.csv [R,L]" >> $HTACCESS_FILE.tmp + done +mv $HTACCESS_FILE.tmp $HTACCESS_FILE -- cgit v1.2.3