From: Daniel Liu Date: Sat, 31 Jul 2021 14:30:42 +0000 (-0400) Subject: mount substitution X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=9ee898ef29fb76b04a2236ea8d7749ad6d962229;p=pinopress.git mount substitution --- diff --git a/README.md b/README.md index 7ed0e9b..2a202a7 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,19 @@ pinopress articles are written in an enhanced version of markdown. specification `$USERLOCAL2` - another user local variable +## mounts + +mounts are the **pinopress** solution to html includes. to include any file from the template directory, use the following syntax: +``` + +``` +note that the name of file is without any extensions and in all caps. also, mounts are **not** expanded recursively. + +**pinopress** also has the following builtin mounts that are used internally, prefixed by an underscore: +``` + + + + +``` + diff --git a/build/stylesheets/root.css b/build/stylesheets/root.css index 18ad2b0..cca2a04 100644 --- a/build/stylesheets/root.css +++ b/build/stylesheets/root.css @@ -51,7 +51,7 @@ body { height: 100%; margin: 0; - padding: 2rem; + padding: 0; } h1, h2, h3, h4, h5, h6 { @@ -85,3 +85,8 @@ code { background-color: var(--bg-light); } +.article-container { + margin: 0 auto; + width: clamp(40ch, 50%, 80ch); +} + diff --git a/pinopress b/pinopress index 58b826a..5fe147c 100755 --- a/pinopress +++ b/pinopress @@ -29,11 +29,23 @@ define export_common export USERGLOBAL2="$(USERGLOBAL2)" endef -# usage: loop_article [dest] [template_filename] -define loop_article +# usage: build_page [page_template] [item_template] [display_message] +define build_page + echo "$(3)" + $(export_common) + cat $(TEMPLATE_DIR)/$(1) > "$@" 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" "$(@)" + done + $(call expand_mount,$@) + envsubst < "$@" | sponge "$@" +endef + +# usage: expand_mount [filename] +define expand_mount + for mount in `sed -En 's//\1/p' "$(1)"`; do + sed -i "//r $(TEMPLATE_DIR)/`echo $$mount | tr '[:upper:]' '[:lower:]'`.template.html" "$(1)" done endef @@ -42,15 +54,6 @@ help: build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(addprefix $(BUILD_DIR)/$(ARTICLE_PATH)/,$(addsuffix .html,$(ARTICLE_LIST))) -# usage: build_page [page_template] [item_template] [display_message] -define build_page - echo "$(3)" - $(export_common) - 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) @@ -67,13 +70,13 @@ $(BUILD_DIR)/feed.xml: $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md echo "parsing $<" $(export_common) - $(call export_article,"$<") cat $(TEMPLATE_DIR)/articlepage.template.html > "$@" # module pipeline starts here ./$(MODULE_DIR)/md "$<" | sed -i "//r /dev/stdin" "$@" . ./$(MODULE_DIR)/md-header "$<" . ./$(MODULE_DIR)/readingtime "$<" # module pipeline ends here + $(call expand_mount,$@) envsubst < "$@" | sponge "$@" clean: diff --git a/templates/archivepage.template.html b/templates/archivepage.template.html index 2dc1b7f..98e9c87 100644 --- a/templates/archivepage.template.html +++ b/templates/archivepage.template.html @@ -9,6 +9,8 @@ + +

Archive

diff --git a/templates/articlepage.template.html b/templates/articlepage.template.html index e0d94db..d6f8029 100644 --- a/templates/articlepage.template.html +++ b/templates/articlepage.template.html @@ -9,7 +9,9 @@ -
+ + +
diff --git a/templates/navbar.template.html b/templates/navbar.template.html new file mode 100644 index 0000000..fba26d0 --- /dev/null +++ b/templates/navbar.template.html @@ -0,0 +1,3 @@ +
+

navbar

+
diff --git a/templates/rollingpage.template.html b/templates/rollingpage.template.html index e953cca..da61156 100644 --- a/templates/rollingpage.template.html +++ b/templates/rollingpage.template.html @@ -9,6 +9,8 @@ + +

Rolling