.PHONY: build deploy sign download-model convert-images pdf-thumbs watch clean dev # Source .env for GITHUB_TOKEN and GITHUB_REPO if it exists. # .env format: KEY=value (one per line, no `export` prefix, no quotes needed). -include .env export build: @git add content/ @git diff --cached --quiet || git commit -m "auto: $$(date -u +%Y-%m-%dT%H:%M:%SZ)" @date +%s > data/build-start.txt @./tools/convert-images.sh @$(MAKE) -s pdf-thumbs cabal run site -- build pagefind --site _site @if [ -d .venv ]; then \ uv run python tools/embed.py || echo "Warning: embedding failed — data/similar-links.json not updated (build continues)"; \ else \ echo "Embedding skipped: run 'uv sync' to enable similar-links (build continues)"; \ fi > IGNORE.txt @BUILD_END=$$(date +%s); \ BUILD_START=$$(cat data/build-start.txt); \ echo $$((BUILD_END - BUILD_START)) > data/last-build-seconds.txt sign: @./tools/sign-site.sh # Download the quantized ONNX model for client-side semantic search. # Run once; files are gitignored. Safe to re-run (skips existing files). download-model: @./tools/download-model.sh # Convert JPEG/PNG images to WebP companions (also runs automatically in build). # Requires cwebp: pacman -S libwebp / apt install webp convert-images: @./tools/convert-images.sh # Generate first-page thumbnails for PDFs in static/papers/ (also runs in build). # Requires pdftoppm: pacman -S poppler / apt install poppler-utils # Thumbnails are written as static/papers/foo.thumb.png alongside each PDF. # Skipped silently when pdftoppm is not installed or static/papers/ is empty. pdf-thumbs: @if command -v pdftoppm >/dev/null 2>&1; then \ find static/papers -name '*.pdf' 2>/dev/null | while read pdf; do \ thumb="$${pdf%.pdf}.thumb"; \ if [ ! -f "$${thumb}.png" ] || [ "$$pdf" -nt "$${thumb}.png" ]; then \ echo " pdf-thumb $$pdf"; \ pdftoppm -r 100 -f 1 -l 1 -png -singlefile "$$pdf" "$$thumb"; \ fi; \ done; \ else \ echo "pdf-thumbs: pdftoppm not found — install poppler (skipping)"; \ fi deploy: build sign git push -u origin main rsync -avz --delete _site/ $(VPS_USER)@$(VPS_HOST):$(VPS_PATH)/ watch: cabal run site -- watch clean: cabal run site -- clean dev: cabal run site -- clean cabal run site -- build python3 -m http.server 8000 --directory _site