From 397e04e67c87cb2a87954d587e2291e973238601 Mon Sep 17 00:00:00 2001 From: ktyl Date: Mon, 13 Mar 2023 22:27:18 +0000 Subject: [PATCH] extract blog build to submodule --- makefile | 61 +++++++++++++--------------------------------- src/root/blog.html | 2 +- 2 files changed, 18 insertions(+), 45 deletions(-) diff --git a/makefile b/makefile index 4454701..274158c 100644 --- a/makefile +++ b/makefile @@ -12,46 +12,34 @@ ROOT_DIR = $(SRC_DIR)/root BLOG_BASE_DIR = blog/ BLOG_BUILD_DIR = $(BLOG_BASE_DIR)out/html/ -BLOG_SRC_DIR = $(BLOG_BASE_DIR)blogs BLOG_OUT_DIR = $(OUT_DIR)/blog -BLOG_TMP_DIR = .blogtmp +BLOG_INDEX = $(BLOG_BUILD_DIR)/index.html PAGES = $(shell find $(ROOT_DIR) -wholename "$(ROOT_DIR)*.html") STYLES = $(shell find $(ROOT_DIR) -wholename "$(ROOT_DIR)*.css") -BLOG_PAGES = $(shell find $(BLOG_SRC_DIR) -wholename "$(BLOG_SRC_DIR)*.md") -BLOG_IMAGES = $(shell find $(BLOG_SRC_DIR) -wholename "$(BLOG_SRC_DIR)*.png" -o -wholename "$(BLOG_SRC_DIR)*.jpg") - IMAGES = $(shell find $(IMG_DIR) -wholename "$(IMG_DIR)/*.png") HTML_INCLUDES = $(shell find $(SRC_DIR)/inc_html -name *.html) CSS_INCLUDES = $(shell find $(SRC_DIR)/inc_css -name *.css) -BLOG_INDEX = $(OUT_DIR)/blog.html -BLOG_RSS = $(BLOG_OUT_DIR)/index.xml -BLOG_INDEX_LINKS = $(BLOG_TMP_DIR)/blogindexlinks.html -BLOG_TARGETS = $(BLOG_PAGES:$(BLOG_SRC_DIR)/%.md=$(BLOG_OUT_DIR)/%.html) -BLOG_PNG_TARGETS = $(BLOG_IMAGES:$(BLOG_SRC_DIR)/%.png=$(BLOG_OUT_DIR)/%.png) -BLOG_JPG_TARGETS = $(BLOG_IMAGES:$(BLOG_SRC_DIR)/%.jpg=$(BLOG_OUT_DIR)/%.jpg) - HTML_TARGETS = $(PAGES:$(ROOT_DIR)/%.html=$(OUT_DIR)/%.html) CSS_TARGETS = $(STYLES:$(ROOT_DIR)/%.css=$(OUT_DIR)/%.css) PNG_TARGETS = $(IMG_DIR)/%.png=$(OUT_DIR)/%.png - all: html blog | $(OUT_DIR) html: $(HTML_TARGETS) $(CSS_TARGETS) | $(OUT_DIR) cp $(IMG_DIR)/*.png $(OUT_DIR)/ cp $(IMG_DIR)/*.jpg $(OUT_DIR)/ -deploy: site +deploy: cp -r $(OUT_DIR) $(SITE_NAME) rsync -rP $(SITE_NAME) $(HOST):~ rm -r $(SITE_NAME) ssh $(HOST) "sudo $(REMOTE_SCRIPT)" -$(OUT_DIR)/%.html: $(ROOT_DIR)/%.html $(HTML_INCLUDES) $(BLOG_INDEX_LINKS) | $(OUT_DIR) - python ppp/ppp.py $< $(HTML_INCLUDES) $(BLOG_INDEX_LINKS) > $@ +$(OUT_DIR)/%.html: $(ROOT_DIR)/%.html $(HTML_INCLUDES) $(BLOG_INDEX) | $(OUT_DIR) + python ppp/ppp.py $< $(HTML_INCLUDES) $(BLOG_INDEX) > $@ $(OUT_DIR)/%.css: $(ROOT_DIR)/%.css $(CSS_INCLUDES) | $(OUT_DIR) python ppp/ppp.py $< $(CSS_INCLUDES) > $@ @@ -59,37 +47,22 @@ $(OUT_DIR)/%.css: $(ROOT_DIR)/%.css $(CSS_INCLUDES) | $(OUT_DIR) $(OUT_DIR): mkdir -p $@ -$(BLOG_OUT_DIR)/%.png: $(BLOG_SRC_DIR)/%.png - cp $< $@ - -$(BLOG_OUT_DIR)/%.jpg: $(BLOG_SRC_DIR)/%.jpg - cp $< $@ - -blog: $(BLOG_TARGETS) $(BLOG_PNG_TARGETS) $(BLOG_JPG_TARGETS) $(BLOG_RSS) | $(BLOG_TMP_DIR) - -$(BLOG_RSS): +$(BLOG_INDEX): + mkdir -p $(BLOG_OUT_DIR) make --directory $(BLOG_BASE_DIR) html - cp $(BLOG_BUILD_DIR)/index.xml $@ -$(BLOG_INDEX_LINKS): $(BLOG_TARGETS) | $(BLOG_TMP_DIR) +# make blog from submodule and apply site templating +blog: $(HTML_INCLUDES) $(CSS_TARGETS) + mkdir -p $(BLOG_OUT_DIR) make --directory $(BLOG_BASE_DIR) html - cp $(BLOG_BUILD_DIR)/index.html $@ - -$(BLOG_OUT_DIR)/%.html: $(BLOG_OUT_DIR)/%.html.tmp $(HTML_INCLUDES) $(CSS_TARGETS) - python ppp/ppp.py $< $(HTML_INCLUDES) > $@ - cp $(CSS_TARGETS) `dirname $@` - rm $< - -$(BLOG_OUT_DIR)/%.html.tmp: $(BLOG_SRC_DIR)/%.md | $(BLOG_TMP_DIR) - pipenv run python scripts/mkblog.py $< $@ - -$(BLOG_OUT_DIR): | $(OUT_DIR) - mkdir -p $@ - -$(BLOG_TMP_DIR): - mkdir -p $@ + cp -r $(BLOG_BUILD_DIR)/* $(BLOG_OUT_DIR) + for page in `find "$(BLOG_OUT_DIR)" -wholename "*.html"`; do \ + pipenv run python ppp/ppp.py $$page $(HTML_INCLUDES) > temp ; \ + mv temp $$page ; \ + cp $(CSS_TARGETS) `dirname $$page` ; \ + done clean: - rm -rf $(OUT_DIR) $(BLOG_TMP_DIR) + rm -rf $(OUT_DIR) -.PHONY: site +.PHONY: blog diff --git a/src/root/blog.html b/src/root/blog.html index eef598a..8d1c77f 100644 --- a/src/root/blog.html +++ b/src/root/blog.html @@ -21,7 +21,7 @@