#!/usr/bin/make -f

URL=http://anarchism.pageabode.com/afaq/index.html
TARFILE=anarchism_15.0.orig.tar
CLEAN_HTML=sh -c "$(CURDIR)/debian/clean_html.py {} > ../html/{}"
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1


%:
	dh $@

get-orig-source:
	wget -r  -A '*.html' -A '*.gif' --no-parent --no-host-directories -e robots=off $(URL) || [[ $? == 8 ]]
	mkdir -p html/
	cd afaq && find . -name '*.html' -type f -exec $(CLEAN_HTML) \;
	cd .. && tar cvf anarchism-15.0/$(TARFILE) anarchism-15.0/html/ && cd $(CURDIR)
	gzip $(TARFILE)
	rm -rf afaq/

override_dh_auto_clean:
	$(CURDIR)/debian/html2txt clean $(CURDIR)/html/*.txt $(CURDIR)/txt
	dh_auto_clean

override_dh_auto_build:
	$(CURDIR)/debian/html2txt build $(CURDIR)/html
	dh_auto_build

override_dh_auto_install:
	dh_installchangelogs html/new.html
	dh_auto_install
