Refactor PDF generation workflow, integrate YAML-based event config, and simplify Makefile scripts.

- Replace `generate-personalized` with unified `generate` target in Makefile, supporting event config integration.
- Add YAML parsing to `generate_cards.py` for event-level placeholders and back side generation.
- Update templates to include `EVENT_*` placeholders and dynamic content rendering.
- Simplify `build` and `build-personalized` targets; consolidate redundant logic.
- Enhance `make help` documentation for updated workflow.
- Adjust LaTeX formatting for back side templates, removing hardcoded spacing.
This commit is contained in:
Peter Adam
2026-02-28 10:43:57 +01:00
parent f59c52551b
commit 9c4c7c6ccb
4 changed files with 156 additions and 143 deletions

View File

@@ -1,7 +1,6 @@
# Makefile for building Brevet card PDF in Docker
IMAGE_NAME := brevetcard-builder
CONTAINER_NAME := brevetcard-build
TEX_FILE_FRONT := brevetkarte.tex
TEX_FILE_BACK := brevetkarte-rueckseite.tex
TEX_FILE_PERSONALIZED := brevetkarte-personalized.tex
@@ -10,23 +9,20 @@ PDF_FILE_BACK := brevetkarte-rueckseite.pdf
PDF_FILE_PERSONALIZED := brevetkarte-personalized.pdf
CSV_FILE := Export Brevetkarte.csv
.PHONY: all build clean build-image build-pdf build-front build-back generate-personalized build-personalized run shell help
.PHONY: all build clean build-image build-front build-back generate build-personalized run shell help
# Default target
all: build
# Build both PDFs (builds image if needed, then compiles)
build: build-image build-front build-back
# Build static demo front side (builds image if needed)
build: build-image build-front
# Build Docker image
build-image:
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME) .
# Compile both PDFs in Docker container
build-pdf: build-front build-back
# Compile front side PDF
# Compile static demo front side PDF
build-front:
@echo "Compiling front side LaTeX to PDF..."
docker run --rm \
@@ -35,8 +31,8 @@ build-front:
pdflatex -interaction=nonstopmode $(TEX_FILE_FRONT)
@echo "PDF generated: $(PDF_FILE_FRONT)"
# Compile back side PDF
build-back:
# Compile back side PDF (always generated from event.yml via generate)
build-back: build-image
@echo "Compiling back side LaTeX to PDF..."
docker run --rm \
-v $(PWD):/workspace \
@@ -44,24 +40,29 @@ build-back:
pdflatex -interaction=nonstopmode $(TEX_FILE_BACK)
@echo "PDF generated: $(PDF_FILE_BACK)"
# Generate personalized cards from CSV
generate-personalized:
@echo "Generating personalized cards from $(CSV_FILE)..."
# Generate all tex files from CSV + event.yml
generate:
@echo "Generating cards from $(CSV_FILE) + event.yml..."
@if [ ! -f "$(CSV_FILE)" ]; then \
echo "Error: $(CSV_FILE) not found!"; \
exit 1; \
fi
python3 generate_cards.py
@echo "Generated $(TEX_FILE_PERSONALIZED)"
# Build personalized cards PDF
build-personalized: generate-personalized build-image
@echo "Compiling personalized cards to PDF..."
# Build personalized front + event back side PDFs
build-personalized: generate build-image
@echo "Compiling personalized front side to PDF..."
docker run --rm \
-v $(PWD):/workspace \
$(IMAGE_NAME) \
pdflatex -interaction=nonstopmode $(TEX_FILE_PERSONALIZED)
@echo "PDF generated: $(PDF_FILE_PERSONALIZED)"
@echo "Compiling back side to PDF..."
docker run --rm \
-v $(PWD):/workspace \
$(IMAGE_NAME) \
pdflatex -interaction=nonstopmode $(TEX_FILE_BACK)
@echo "PDF generated: $(PDF_FILE_BACK)"
# Run container interactively
run:
@@ -95,15 +96,14 @@ help:
@echo "Brevet Card PDF Builder"
@echo ""
@echo "Available targets:"
@echo " make build - Build Docker image and compile both PDFs (default)"
@echo " make build-image - Build Docker image only"
@echo " make build-pdf - Compile both front and back PDFs"
@echo " make build-front - Compile front side PDF only"
@echo " make build-back - Compile back side PDF only"
@echo " make generate-personalized - Generate personalized cards from CSV"
@echo " make build-personalized - Generate and compile personalized cards"
@echo " make shell - Open interactive shell in container"
@echo " make clean - Remove generated files (aux, log, pdf)"
@echo " make clean-all - Remove all files and Docker image"
@echo " make rebuild - Clean everything and rebuild"
@echo " make help - Show this help message"
@echo " make build - Build Docker image and compile static front side (default)"
@echo " make build-image - Build Docker image only"
@echo " make build-front - Compile static demo front side PDF"
@echo " make generate - Generate tex files from CSV + event.yml"
@echo " make build-personalized - Generate and compile front + back side PDFs"
@echo " make build-back - Compile back side PDF (after generate)"
@echo " make shell - Open interactive shell in container"
@echo " make clean - Remove generated files (aux, log, pdf)"
@echo " make clean-all - Remove all files and Docker image"
@echo " make rebuild - Clean everything and rebuild"
@echo " make help - Show this help message"