X-Git-Url: https://git.danieliu.xyz/?p=pinopress.git;a=blobdiff_plain;f=pinopress;h=58b826a16f442d9a239ce446dc3cf67879cea845;hp=3623b2f65d0921eacf2586a169bb608c8434633b;hb=2c2e491fc65d159d57de6121776b2b0424588a29;hpb=394bc43d24de087865fa4eed1920411c1a6d7ebd diff --git a/pinopress b/pinopress index 3623b2f..58b826a 100755 --- a/pinopress +++ b/pinopress @@ -8,6 +8,8 @@ SITEURL := https://blog.danieliu.xyz USERGLOBAL1 := USERGLOBAL2 := +include config.mk + .PHONY: help build clean # internal variables @@ -31,7 +33,7 @@ endef define loop_article for article_file in `ls $(SRC_DIR)`; do . ./$(MODULE_DIR)/md-header "$(SRC_DIR)/$$article_file" - envsubst < $(TEMPLATE_DIR)/$(2) | sed -i "//r /dev/stdin" "$(1)" + envsubst < $(TEMPLATE_DIR)/$(2) | sed -i "//r /dev/stdin" "$(1)" done endef @@ -40,41 +42,38 @@ help: build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(addprefix $(BUILD_DIR)/$(ARTICLE_PATH)/,$(addsuffix .html,$(ARTICLE_LIST))) -.ONESHELL: -$(BUILD_DIR)/rolling.html: - echo 'building rolling file' +# usage: build_page [page_template] [item_template] [display_message] +define build_page + echo "$(3)" $(export_common) - cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/rollingbody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@" - $(call loop_article,"$@",rollingitem.template.html) + cat $(TEMPLATE_DIR)/$(1) > "$@" + $(call loop_article,"$@",$(2)) envsubst < "$@" | sponge "$@" +endef + +.ONESHELL: +$(BUILD_DIR)/rolling.html: + $(call build_page,rollingpage.template.html,rollingitem.template.html,building rolling file) .ONESHELL: $(BUILD_DIR)/archive.html: - echo 'building archive file' - $(export_common) - cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/archivebody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@" - $(call loop_article,"$@",archiveitem.template.html) - envsubst < "$@" | sponge "$@" + $(call build_page,archivepage.template.html,archiveitem.template.html,building archive file) .ONESHELL: $(BUILD_DIR)/feed.xml: - echo 'building feed file' - $(export_common) - cat $(TEMPLATE_DIR)/feed.template.xml > "$@" - $(call loop_article,"$@",feeditem.template.xml) - envsubst < "$@" | sponge "$@" + $(call build_page,feed.template.xml,feeditem.template.xml,building feed file) .ONESHELL: $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md echo "parsing $<" $(export_common) $(call export_article,"$<") - . ./$(MODULE_DIR)/md-header "$<" - cat $(TEMPLATE_DIR)/head.template.html > "$@" + cat $(TEMPLATE_DIR)/articlepage.template.html > "$@" # module pipeline starts here - ./$(MODULE_DIR)/md "$^" >> "$@" + ./$(MODULE_DIR)/md "$<" | sed -i "//r /dev/stdin" "$@" + . ./$(MODULE_DIR)/md-header "$<" + . ./$(MODULE_DIR)/readingtime "$<" # module pipeline ends here - cat $(TEMPLATE_DIR)/foot.template.html >> "$@" envsubst < "$@" | sponge "$@" clean: