# ==============================================================================
# FAQ Makefile 2021-04-01 09:52:16
# ==============================================================================
#
# Simple Makefile to rebuild the components in this file
#

MDFILE = FAQ.mkd
HTMLFILE = FAQ.html
DEVFILE = FAQ_dev.html
TPLFILE = FAQ.tpl
PHPFILE = FAQ.php

all : markdown php

#
# Rules for converting the Markdown into two files, one for stitching into
# the PHP framework via FAQ.tpl and the other just a stand-alone HTML file for
# development.
#
markdown: $(HTMLFILE) $(DEVFILE)

$(HTMLFILE): $(MDFILE)
	tpage $< | pandoc -f markdown-smart -t html5 \
	--number-sections --table-of-contents --toc-depth=4 -o $@

$(DEVFILE): $(MDFILE)
	tpage $< | pandoc -f markdown-smart -t html5 --standalone \
	--template=hpr.html5 -c http://hackerpublicradio.org/css/hpr.css \
	--number-sections --table-of-contents --toc-depth=4 -o $@

#
# When we generate the file FAQ.html (HTML fragment) we use tpage to make
# a complete standalone PHP page called FAQ.php
#
.PHONY: php upload

php: $(PHPFILE)

$(PHPFILE): $(HTMLFILE)
	tpage $(TPLFILE) > $(PHPFILE)

#
# Upload the FAQ HTML+PHP to the server for development
#
upload: $(PHPFILE)
	scp -P 22074 $(PHPFILE) hpr@hackerpublicradio.org:www/

# ==============================================================================
#
# Use 'make sync' to copy updates to the visible project area
#
# Note that the filter file needs to be edited when new files are to be
# included.
#
sync:   put

fromdir = $(HOME)/HPR/FAQ/
todir   = $(HOME)/HPR/Projects/hpr-tools/FAQ/
filter  = $(fromdir).rsync_export
syncmsg = Updating git directory with updates from development version

put:
	@echo ">> $(basedir)"
	@echo "** $(syncmsg)"
	rsync -vaP --filter=". $(filter)" $(fromdir) $(todir)

.PHONY: sync put

