TEMPDIR=/tmp/openbsd-webzine

generate-site: clean
	ls | grep issue- | sort -V | xargs -n 1 tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=cs tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=de tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=es tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=fr tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=it tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=se tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=ru tools/make_issue.sh
	-ls | grep issue- | sort -V | xargs -n 1 env LN=pt-br tools/make_issue.sh
	tools/make_issue.sh _index ../public/index.html
	cp -fr _static/* ../public/
	tools/sitemap.sh webzine.puffy.cafe ../public/ > ../public/sitemap.xml
	gzip -9 -c ../public/sitemap.xml > ../public/sitemap.gz
	tools/atom.sh webzine.puffy.cafe > ../public/atom.xml
	xmllint -format ../public/atom.xml
	find ../public/ -name '*.xml'  -exec gzip -9 -k {} \;
	find ../public/ -name '*.html' -exec gzip -9 -k {} \;

puffy: clean
	tools/make_issue.sh _puffy.cafe ../public/index.html

all: generate-site

clean:
	rm -fr ../dev/*html ../public/*

test:
	mkdir -p ${TEMPDIR}
	tools/make_issue.sh current ${TEMPDIR}/current-issue.html
	xdg-open ${TEMPDIR}/current-issue.html

# only difference with generate-site is make_issue.sh -t
testsite: clean
	ls | grep issue- | sort -V | xargs -n 1 tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=cs tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=de tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=es tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=fr tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=it tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=se tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=ru tools/make_issue.sh -t
	-ls | grep issue- | sort -V | xargs -n 1 env LN=pt-br tools/make_issue.sh -t
	tools/make_issue.sh _index ../public/index.html
	cp -fr _static/* ../public/
	tools/sitemap.sh webzine.puffy.cafe ../public/ > ../public/sitemap.xml
	gzip -9 -c ../public/sitemap.xml > ../public/sitemap.gz
	tools/atom.sh webzine.puffy.cafe > ../public/atom.xml
	xmllint -format ../public/atom.xml
	mkdir -p ${TEMPDIR}
	cp -fr ../public ${TEMPDIR}/
	xdg-open ${TEMPDIR}/public/index.html
