3 ## pinopress - the simple static blog generator
4 ## dependencies: sponge
7 SITEURL := https://blog.danieliu.xyz
11 .PHONY: help build clean
14 TEMPLATE_DIR := templates
19 ARTICLE_PATH := article
20 ARTICLE_LIST := $(basename $(shell ls $(SRC_DIR)))
22 # some helper functions
24 export SITEURL="$(SITEURL)"
25 export ARTICLE_PATH="$(ARTICLE_PATH)"
26 export USERGLOBAL1="$(USERGLOBAL1)"
27 export USERGLOBAL2="$(USERGLOBAL2)"
30 # usage: loop_article [dest] [template_filename]
32 for article_file in `ls $(SRC_DIR)`; do
33 . ./$(MODULE_DIR)/md-header "$(SRC_DIR)/$$article_file"
34 envsubst < $(TEMPLATE_DIR)/$(2) | sed -i "/<!-- $(shell echo $(addprefix mount_,$(basename $(basename $(2)))) | tr '[:lower:]' '[:upper:]') -->/r /dev/stdin" "$(1)"
39 echo 'pinopress help|build|clean'
41 build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(addprefix $(BUILD_DIR)/$(ARTICLE_PATH)/,$(addsuffix .html,$(ARTICLE_LIST)))
44 $(BUILD_DIR)/rolling.html:
45 echo 'building rolling file'
47 cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/rollingbody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
48 $(call loop_article,"$@",rollingitem.template.html)
49 envsubst < "$@" | sponge "$@"
52 $(BUILD_DIR)/archive.html:
53 echo 'building archive file'
55 cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/archivebody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
56 $(call loop_article,"$@",archiveitem.template.html)
57 envsubst < "$@" | sponge "$@"
60 $(BUILD_DIR)/feed.xml:
61 echo 'building feed file'
63 cat $(TEMPLATE_DIR)/feed.template.xml > "$@"
64 $(call loop_article,"$@",feeditem.template.xml)
65 envsubst < "$@" | sponge "$@"
68 $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md
71 $(call export_article,"$<")
72 cat $(TEMPLATE_DIR)/head.template.html > "$@"
73 # module pipeline starts here
74 ./$(MODULE_DIR)/md "$^" >> "$@"
75 # module pipeline ends here
76 cat $(TEMPLATE_DIR)/foot.template.html >> "$@"
77 envsubst < "$@" | sponge "$@"
81 rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(BUILD_DIR)/$(ARTICLE_PATH)/*