#! /bin/sh # Make folder if it doesn't exist if [ ! -d "/var/www/synd" ]; then # User should be www-data (like in generate.sh), but I use Fedora and root is the default one mkdir /var/www/synd fi # Remove record of previously generated files rm -f /var/www/synd/.files # Generate files ssg src /var/www/synd/ "Syndamia" "https://syndamia.com" > /dev/null dur=0 startTimer () { dur="$(date +%s%N)" } endTimer () { dur="$(echo "scale=4 ; ($(date +%s%N) - $dur) / 1000000000" | bc -l)" printf "%.3fs $1\n" $dur } combine() { startTimer find './awk-edits' -type f -name "#*.awk" -exec cat {} + > /tmp/syndamiadotcom-awk find './awk-edits' -type f -name "[A-Z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk find './awk-edits' -type f -name "_*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk find './awk-edits' -type f -name "[a-z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk endTimer "generation of /tmp/syndamiadotcom-awk" startTimer for file in $(find '/var/www/synd' -type f -name "*.html"); do awk -f '/tmp/syndamiadotcom-awk' "$file" > tmp && mv -f tmp "$file" done endTimer "/tmp/syndamiadotcom-awk" } separated() { libs="" for l in $(find './awk-edits' -type f -name "#*.awk"); do libs+=" -f $l " done for i in $(find './awk-edits' -type f -name "[A-Z]*.awk") $(find './awk-edits' -type f -name "[a-z]*.awk"); do startTimer for file in $(find '/var/www/synd/' -type f -name "*.html"); do awk $libs -f "$i" -f './awk-edits/_print.awk' "$file" > tmp && mv -f tmp "$file" done endTimer "$i" done } [ -n "$1" ] && separated || combine # # Tiny version # if [ ! -d "/var/www/tiny.synd" ]; then # User should be www-data (like in generate.sh), but I use Fedora and root is the default one mkdir /var/www/tiny.synd fi # Just take what is already made, no need to regenerate everything cp -r /var/www/synd/* /var/www/tiny.synd/ # Remove unnecessary files rm -f /var/www/tiny.synd/*.css rm -rf /var/www/tiny.synd/fonts/ rm -f /var/www/tiny.synd/.files # Remove references to stylesheets in all files for file in $(find "/var/www/tiny.synd" -type f -name "*.html"); do sed -i -E 's/^.*(rel="stylesheet|\Content/
Content/g' $file sed -i 's/<\/head>/\t