From 9ee898ef29fb76b04a2236ea8d7749ad6d962229 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sat, 31 Jul 2021 10:30:42 -0400 Subject: [PATCH] mount substitution --- README.md | 16 ++++++++++++++++ build/stylesheets/root.css | 7 ++++++- pinopress | 29 ++++++++++++++++------------- templates/archivepage.template.html | 2 ++ templates/articlepage.template.html | 4 +++- templates/navbar.template.html | 3 +++ templates/rollingpage.template.html | 2 ++ 7 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 templates/navbar.template.html 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

-- 2.20.1