#!/usr/bin/make -f
%:
	dh $@

override_dh_auto_build:
	uglifyjs -o knowl.min.js knowl.js
	cleancss -o knowlstyle.min.css knowlstyle.css

# Upstream doesn't ship a tarball, so we create our own.  The version number
# comes from the most recent timestamp of the two files.
get-date = $(shell date -d @$(shell stat -c %Y $(1)) +%Y%m%d)
get-orig-source: tmp/knowl.js tmp/knowlstyle.css
	$(eval DATE := $(lastword $(sort $(foreach file, $^, \
		$(call get-date, $(file))))))
	cd tmp && tar -cf knowl.js_0~$(DATE).orig.tar $(subst tmp/,, $^)
	gzip -n tmp/knowl.js_0~$(DATE).orig.tar
	mv -v tmp/knowl.js_0~$(DATE).orig.tar.gz ..
	rm -rf tmp

tmp/%:
	wget -P tmp $(patsubst tmp/%, https://aimath.org/%, $@)
