The source for my password-protected readings site (without the readings, of course)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
1.1 KiB

#!/bin/bash
set -e
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
# Copy in the readings folder
echo "...copying readings"
mkdir -p static/readings
rsync -rc --delete --exclude=".gitkeep" $HOME/Dropbox/Charles/Work/Teaching/Readings\ Site/ static/readings
# Build the output files
rm -rf public
hugo
# Get a list of all the links in the readings folder, check them
echo "...checking all reading links"
declare -A refs
for doc in public/*/index.php
do
while read -r line; do
raw=`echo "$line" | sed 's@href="/\(readings/.*\)"@\1@'`
cooked=$(urldecode $raw)
if [[ ! -e public/$cooked ]]; then
echo ""
echo "ERROR: The file $cooked doesn't exist in the readings folder!"
exit 1
fi
refs[`basename $cooked`]=1
echo -n "."
done < <(grep -oP 'href="/readings/.*?"' $doc)
done
echo ""
# look for extras in the folder
for pdf in public/readings/*.pdf
do
if [[ -n "${refs[`basename $pdf`]}" ]]; then
echo -n "."
else
echo ""
echo "WARNING: The file $pdf is in the readings folder, but not referenced"
fi
done
echo ""