upload.sh 893 Bytes
#!/bin/zsh

if [ ! -d "$1" -o "$2" ]; then
	echo "Syntax: $0 <folder>"
	exit
fi

IN=$(realpath $1)
REMOTE=korektor:/var/www/korektor/doc
CORRECTIONS=~/Programowanie/clarin/korekta
TEI=output/_export

# Compress files if needed
if [ -e "$IN/**/*.xml" ]; then
	echo -n "Compressing files..."
	gzip "$IN/**/*.xml"
	echo "OK"
fi

# Recreate structure
echo -n "Renaming folders..."
rm -rf $TEI
mkdir -p $TEI
for folder in $1/*/; do
	OUT="$TEI/$(python odt2tei/kdppath.py $folder)"
	mkdir -p $(dirname "$OUT")
	cp -R $folder "$OUT"
done
echo "OK"
echo -n "Compressing..."
gzip $TEI/**/*.xml
echo "OK"
echo -n "Uploading files..."
rsync -a --delete $TEI/ korektor:export
echo "OK"

# Find corrections
TEI_ABSOLUTE=$(realpath $TEI)
echo -n "Finding corrections..."
cd $CORRECTIONS
python korekta.py -o bugs.json $TEI_ABSOLUTE
scp -q bugs.json $REMOTE
echo "$(rg -cw 'id":' bugs.json) corrections"
cd -