fix: ignore _* files and dirs & manage image subfolders

This commit is contained in:
Glenn Y. Rolland 2024-02-16 23:57:43 +01:00
parent 8c259145ef
commit bc3f0f911f

View file

@ -29,12 +29,12 @@ DOCS_PORT=5100
SLIDES_PORT=5200 SLIDES_PORT=5200
## Find .md slides ## Find .md slides
SLIDES_MDPP=$(shell find $(SLIDES_DIR) \( -name '*.mdpp' ! -name '_*' \)) SLIDES_MDPP=$(shell find -L $(SLIDES_DIR) -regextype sed \( -name '*.mdpp' ! -regex '.*/_.*' \))
SLIDES_MDPP_MD=$(patsubst $(SLIDES_DIR)/%.mdpp,$(CACHE_SLIDES_DIR)/%.mdpp.md,$(SLIDES_MDPP)) SLIDES_MDPP_MD=$(patsubst $(SLIDES_DIR)/%.mdpp,$(CACHE_SLIDES_DIR)/%.mdpp.md,$(SLIDES_MDPP))
SLIDES_MDPP_MD_PDF=$(patsubst $(CACHE_SLIDES_DIR)/%.mdpp.md,$(BUILD_SLIDES_DIR)/%.pdf,$(SLIDES_MDPP_MD)) SLIDES_MDPP_MD_PDF=$(patsubst $(CACHE_SLIDES_DIR)/%.mdpp.md,$(BUILD_SLIDES_DIR)/%.pdf,$(SLIDES_MDPP_MD))
SLIDES_MDPP_MD_PPTX=$(patsubst $(CACHE_SLIDES_DIR)/%.mdpp.md,$(BUILD_SLIDES_DIR)/%.pptx,$(SLIDES_MDPP_MD)) SLIDES_MDPP_MD_PPTX=$(patsubst $(CACHE_SLIDES_DIR)/%.mdpp.md,$(BUILD_SLIDES_DIR)/%.pptx,$(SLIDES_MDPP_MD))
SLIDES_MD=$(shell find $(SLIDES_DIR) \( -name '*.md' ! -name '_*' \)) $(SLIDES_MDPP_MD) SLIDES_MD=$(shell find -L $(SLIDES_DIR) -regextype sed \( -name '*.md' ! -regex '.*/_.*' \)) $(SLIDES_MDPP_MD)
SLIDES_MD_PDF=$(patsubst $(SLIDES_DIR)/%.md,$(BUILD_SLIDES_DIR)/%.pdf,$(SLIDES_MD)) SLIDES_MD_PDF=$(patsubst $(SLIDES_DIR)/%.md,$(BUILD_SLIDES_DIR)/%.pdf,$(SLIDES_MD))
SLIDES_MD_PPTX=$(patsubst $(SLIDES_DIR)/%.md,$(BUILD_SLIDES_DIR)/%.pptx,$(SLIDES_MD)) SLIDES_MD_PPTX=$(patsubst $(SLIDES_DIR)/%.md,$(BUILD_SLIDES_DIR)/%.pptx,$(SLIDES_MD))
@ -42,22 +42,22 @@ SLIDES_MD_ALL=$(SLIDES_MDPP_MD) $(SLIDES_MD) $(SLIDES_DIR)/autoslide.md
SLIDES_PDF_ALL=$(SLIDES_MDPP_MD_PDF) $(SLIDES_MD_PDF) $(BUILD_SLIDES_DIR)/autoslide.pdf SLIDES_PDF_ALL=$(SLIDES_MDPP_MD_PDF) $(SLIDES_MD_PDF) $(BUILD_SLIDES_DIR)/autoslide.pdf
SLIDES_PPTX_ALL=$(SLIDES_MDPP_MD_PPTX) $(SLIDES_MD_PPTX) $(BUILD_SLIDES_DIR)/autoslide.pptx SLIDES_PPTX_ALL=$(SLIDES_MDPP_MD_PPTX) $(SLIDES_MD_PPTX) $(BUILD_SLIDES_DIR)/autoslide.pptx
DOCS_MD=$(shell find $(DOCS_DIR) \( -name '*.md' ! -name '_*' \)) DOCS_MD=$(shell find -L $(DOCS_DIR) -regextype sed \( -name '*.md' ! -regex '.*/_.*' \))
## Find .uml graphs ## Find .uml graphs
DOCS_IMAGES_UML=$(shell find $(IMAGES_DIR) \( -name '*.uml' ! -name '_*' \)) DOCS_IMAGES_UML=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.uml' ! -regex '.*/_.*' \))
DOCS_IMAGES_UML_SVG=$(patsubst $(IMAGES_DIR)/%.uml,$(BUILD_IMAGES_DIR)/%.uml.svg,$(DOCS_IMAGES_UML)) DOCS_IMAGES_UML_SVG=$(patsubst $(IMAGES_DIR)/%.uml,$(BUILD_IMAGES_DIR)/%.uml.svg,$(DOCS_IMAGES_UML))
## Find .dot graphs ## Find .dot graphs
DOCS_IMAGES_DOT=$(shell find $(IMAGES_DIR) \( -name '*.dot' ! -name '_*' \)) DOCS_IMAGES_DOT=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.dot' ! -regex '.*/_.*' \))
DOCS_IMAGES_DOT_SVG=$(patsubst $(IMAGES_DIR)/%.dot,$(BUILD_IMAGES_DIR)/%.dot.svg,$(DOCS_IMAGES_DOT)) DOCS_IMAGES_DOT_SVG=$(patsubst $(IMAGES_DIR)/%.dot,$(BUILD_IMAGES_DIR)/%.dot.svg,$(DOCS_IMAGES_DOT))
## Find .circo graphs ## Find .circo graphs
DOCS_IMAGES_CIRCO=$(shell find $(IMAGES_DIR) \( -name '*.circo' ! -name '_*' \)) DOCS_IMAGES_CIRCO=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.circo' ! -regex '.*/_.*' \))
DOCS_IMAGES_CIRCO_SVG=$(patsubst $(IMAGES_DIR)/%.circo,$(BUILD_IMAGES_DIR)/%.circo.svg,$(DOCS_IMAGES_CIRCO)) DOCS_IMAGES_CIRCO_SVG=$(patsubst $(IMAGES_DIR)/%.circo,$(BUILD_IMAGES_DIR)/%.circo.svg,$(DOCS_IMAGES_CIRCO))
## Find .ora images ## Find .ora images
DOCS_IMAGES_ORA=$(shell find $(IMAGES_DIR) \( -name '*.ora' ! -name '_*' \)) DOCS_IMAGES_ORA=$(shell find -L $(IMAGES_DIR) -regextype sed \( -name '*.ora' ! -regex '.*/_.*' \))
DOCS_IMAGES_ORA_PNG=$(patsubst $(IMAGES_DIR)/%.ora,$(BUILD_IMAGES_DIR)/%.ora.png,$(DOCS_IMAGES_ORA)) DOCS_IMAGES_ORA_PNG=$(patsubst $(IMAGES_DIR)/%.ora,$(BUILD_IMAGES_DIR)/%.ora.png,$(DOCS_IMAGES_ORA))
## Merge all lists ## Merge all lists
@ -74,15 +74,11 @@ prepare: prepare-slides prepare-docs ## install prerequisites
prepare-slides: ## install prerequisites for PDF slides only prepare-slides: ## install prerequisites for PDF slides only
npm install npm install
npm rebuild node-sass
npx browserslist@latest --update-db npx browserslist@latest --update-db
prepare-docs: ## install prerequisites for static docs site only prepare-docs: ## install prerequisites for static docs site only
pipenv install pipenv install
# if [ "$(SYSTEM_INSTALL)" -eq 1 ]; then \
# pipenv install --deploy --system ; \
#else \
# pipenv install ; \
#fi
.PHONY: prepare prepare-slides prepare-docs .PHONY: prepare prepare-slides prepare-docs
@ -93,6 +89,9 @@ images: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG) ## build images
@echo " dot: $(DOCS_IMAGES_DOT)" @echo " dot: $(DOCS_IMAGES_DOT)"
@echo " circo: $(DOCS_IMAGES_CIRCO)" @echo " circo: $(DOCS_IMAGES_CIRCO)"
@echo "Built: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG)" @echo "Built: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG)"
for dir in $$(find -L $(DOCS_DIR) -type d -regextype sed -regex '.*/[0-9][^/]*/images$$') $(DOCS_DIR)/images ; do \
rsync -av $$dir/ $(SLIDES_DIR)/images/ || exit 1 ; \
done
.PHONY: images .PHONY: images
@ -126,17 +125,19 @@ watch: ## run development server
autoslide: $(SLIDES_DIR)/autoslide.md | $(BUILD_SLIDES_DIR) autoslide: $(SLIDES_DIR)/autoslide.md | $(BUILD_SLIDES_DIR)
$(SLIDES_DIR)/autoslide.md: $(DOCS_MD) $(SLIDES_DIR)/autoslide.md: $(DOCS_MD)
find $(DOCS_DIR) -regextype sed -regex '.*/[0-9][^/]*\.md' -print0 \ find -L $(DOCS_DIR) -regextype sed \( -regex '.*/[0-9][^/]*\.md' ! -regex '.*/_.*' \) -print0 \
| sort -z |xargs -0 cat \ | sort -z |xargs -0 cat \
> $(SLIDES_DIR)/autoslide.md > $(SLIDES_DIR)/autoslide.md
watch-autoslide-internal: watch-autoslide-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \ while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 0.25 ; \ sleep 0.25 ; \
$(MAKE) autoslide ; \ $(MAKE) autoslide ; \
done done
watch-tocupdate-internal: watch-tocupdate-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \ while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 2 ; \ sleep 2 ; \
$(MAKE) images ; \ $(MAKE) images ; \
@ -148,6 +149,7 @@ watch-docs-internal:
watch-slides-internal: .marp/theme.css watch-slides-internal: .marp/theme.css
PORT=$(SLIDES_PORT) \ PORT=$(SLIDES_PORT) \
npx marp \ npx marp \
--allow-local-files \
--engine $$(pwd)/.marp/engine.js \ --engine $$(pwd)/.marp/engine.js \
--html \ --html \
--theme $$(pwd)/.marp/theme.css \ --theme $$(pwd)/.marp/theme.css \
@ -229,7 +231,7 @@ build-docs-pdf: ## build pdf docs only
pipenv run mkdocs build \ pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR) --site-dir $(BUILD_DOCS_DIR)
pdftk \ pdftk \
$$(find $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \ $$(find -L $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \
cat output $(BUILD_DOCS_DIR)/docs.pdf cat output $(BUILD_DOCS_DIR)/docs.pdf
build-docs-html: ## build static docs site only build-docs-html: ## build static docs site only
@ -282,14 +284,14 @@ fixme:
docker-build: ## build docker image docker-build: ## build docker image
docker build \ docker build \
--file docker/Dockerfile \ --file docker/Dockerfile \
--tag glenux/teaching-boilerplate:$(BUILD_VERSION) \ --tag glenux/docmachine:$(BUILD_VERSION) \
. .
docker tag \ docker tag \
glenux/teaching-boilerplate:$(BUILD_VERSION) \ glenux/docmachine:$(BUILD_VERSION) \
glenux/teaching-boilerplate:latest glenux/docmachine:latest
docker-push: ## push docker image docker-push: ## push docker image
env docker push glenux/teaching-boilerplate:latest env docker push glenux/docmachine:latest
docker-pull: ## download docker image docker-pull: ## download docker image
env docker pull glenux/teaching-boilerplate:latest env docker pull glenux/docmachine:latest