.PHONY: build events dev stop help prep lint format

requirements += python3
requirements += nginx

help:
	@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort | column -s ':' -t

.PHONY: check
check: ## Check you have the required dependencies
	@$(foreach dep, $(requirements), type $(dep) >/dev/null || echo "Install $(dep)." ; )

prep: ## Create venv and install requirements
	python3 -m venv .venv
	./.venv/bin/pip install --upgrade pip
	./.venv/bin/pip install -r requirements.txt

build: ## Full website build sequence
	./.venv/bin/python atom_gen.py
	./.venv/bin/python prep.py
	./.venv/bin/python build_pages.py

events: ## Update site from CSV (build pages + images)
	./.venv/bin/python build_pages.py
	./.venv/bin/python image_poster.py

dev: ## Start development server
	nginx -p . -c nginx.dev.conf

stop:
	nginx -p . -c nginx.dev.conf -s stop

lint: ## Check syntax
	./.venv/bin/flake8 . --config .flake8 --exclude .venv

format:
	./.venv/bin/black .

.PHONY: clean
clean: ## Remove generated files.
	$(RM) $(defaults)

