website/Makefile

122 lines
3.2 KiB
Makefile

WWW = ${PWD}/www
SITE = ${PWD}/site
SCRIPTS = ${PWD}/scripts
LOCAL = /var/www/htdocs
REMOTE = sdk@codevoid.de:/home/www/htdocs/shagen
# do everything by default
all: build-and-upload-all
@echo "done."
# Create the photo galleries and create the index and preview html pages.
PHOTODIRS != find photos/* -maxdepth 0 -mindepth 0 -type d
get-photos:
[ ! -d "photos" ] \
&& git clone sdk@home.codevoid.de:.photos.git photos \
|| cd photos && git pull
photos: ${PHOTODIRS}
mkdir -p ${SITE}/photos
cd photos && sh ${SCRIPTS}/mkphotoindex.sh > index.html
find photos -type f \( -not -name "*.html" \
-not -name "*.txt" \
-not -name "*.meta" \
\) -exec install -D {} www/{} \;
find photos -type f \( -name "*.html" \
-o -name "*.meta" \
\) -exec install -D {} site/{} \;
${PHOTODIRS}: get-photos
cd "$@" && sh ${SCRIPTS}/mkphotos.sh > index.html
# (manual step) - it takes some time to optimize all images and it's not really necessary.
optimize:
find photos -name "*.jpg" -type f -exec jpegoptim -w 12 --all-progressive --strip-all "{}" +
# create the uugrn test calendar
calendar:
mkdir -p ${SITE}/uugcal
cd ${SITE}/uugcal && sh ${SCRIPTS}/mkuugcalendar.sh > index.html
# invoke zod and compile the website into the www/ dir
compile:
mkdir -p ${WWW}
zod ${SITE} ${WWW}
# after mixing different generators in the compile step, let's tidy and
# indent the output properly. XXX is there a tool that does _only_
# indent? We don't need all the other tidy magic here...
tidy:
find ${WWW} -type f -name "*.html" \
-exec tidy -q -i -m -c -w 120 -f /dev/null {} \;
find ${WWW} -type f -name "*.html" \
-exec sed -i '/.*meta name="generator".*/d' {} \;
# create gzip variants of text files, so they can be served by httpds
# gzip-static extension
gzip:
find ${WWW} -type f \
\( -name "*.html" -o -name "*.css" \) \
-exec gzip -kf9 {} \;
# set permissions so the web server can read the file
fixperms:
doas chown -R sdk:www ${WWW}
doas chmod -R ugo+wrX,go-w ${WWW}
# we can upload to the local and the remote webserver at the same time
upload-local:
doas rsync -a --delete ${WWW}/ ${LOCAL}/
upload-remote:
doas rsync -a --delete -e ssh ${WWW}/ ${REMOTE}/
upload-all: upload-local upload-remote
build: photos calendar
make compile; \
make fixperms;
build-and-upload-all:
make build; \
make upload-all;
# deploy to the local webserver for preview
local:
make build; \
make upload-local;
remote:
make build; \
make upload-remote
# clean up temporary files and everything that can be regenerated very fast
clean:
rm -rf ${WWW}/photos
rm -rf ${SITE}/photos
rm -f photos/index.html
rm -f photos/*/*.html
rm -rf ${SITE}/uugcal
rm -rf ${WWW}
# clean and also delete all generated images
realclean: clean
rm -rf photos/*/{thm,mid}
### TARGETS BELOW ARE ONLY FOR CONVENIENCE
git-add:
find site/photos -type f \
-not -name "*.html" \
-not -path "*/thm/*" \
-not -path "*/mid/*" \
-exec git add "{}" +
# watch files and rebuild automatically
notify:
ulimit -n 1024; \
find ${SITE} ${SCRIPTS} -not -path "*/photos/*" -type f \
| inotifywait -m -e modify --fromfile - \
| while read line; \
do \
make; \
done
.PHONY: ${PHOTODIRS} ${REPOS}