reorganized templates
authorDaniel Liu <mr.picklepinosaur@gmail.com>
Sat, 31 Jul 2021 13:21:04 +0000 (09:21 -0400)
committerDaniel Liu <mr.picklepinosaur@gmail.com>
Sat, 31 Jul 2021 13:21:04 +0000 (09:21 -0400)
README.md
build/stylesheets/root.css
pinopress
templates/archivebody.template.html [deleted file]
templates/archivepage.template.html [moved from templates/head.template.html with 60% similarity]
templates/articlepage.template.html [new file with mode: 0644]
templates/feed.template.xml
templates/foot.template.html [deleted file]
templates/rollingbody.template.html [deleted file]
templates/rollingpage.template.html [new file with mode: 0644]

index 5b725d6..7ed0e9b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -54,7 +54,3 @@ pinopress articles are written in an enhanced version of markdown. specification
 
 `$USERLOCAL2` - another user local variable
 
-## mounts
-
-many times, you would like to display a list of html elements somewhere in the page. **pinopress** solves this using mounts. mounts are simply comments that tell pinopress where to append template items.
-
index 67f9a26..18ad2b0 100644 (file)
@@ -69,3 +69,19 @@ a:hover {
 strong {
     color: var(--text-light);
 }
+
+pre {
+
+    background-color: var(--bg-light);
+
+    padding: 0.75rem;
+
+    /* border: 1px solid var(--text-light); */
+    /* border-radius: 0.5rem; */
+}
+
+code {
+    color: var(--text-light);
+    background-color: var(--bg-light);
+}
+
index b47d785..58b826a 100755 (executable)
--- a/pinopress
+++ b/pinopress
@@ -33,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 "/<!-- $(shell echo $(addprefix mount_,$(basename $(basename $(2)))) | tr '[:lower:]' '[:upper:]') -->/r /dev/stdin" "$(1)"
+               envsubst < $(TEMPLATE_DIR)/$(2) | sed -i "/<!-- $(shell echo $(addprefix _mount_,$(basename $(basename $(2)))) | tr '[:lower:]' '[:upper:]') -->/r /dev/stdin" "$(1)"
        done
 endef
 
@@ -42,42 +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,"$<")
-       cat $(TEMPLATE_DIR)/head.template.html > "$@"
+       cat $(TEMPLATE_DIR)/articlepage.template.html > "$@"
        # module pipeline starts here
-       ./$(MODULE_DIR)/md "$<" >> "$@"
+       ./$(MODULE_DIR)/md "$<" | sed -i "/<!-- _MOUNT_ARTICLECONTENT -->/r /dev/stdin" "$@"
        . ./$(MODULE_DIR)/md-header "$<"
        . ./$(MODULE_DIR)/readingtime "$<"
        # module pipeline ends here
-       cat $(TEMPLATE_DIR)/foot.template.html >> "$@"
        envsubst < "$@" | sponge "$@"
 
 clean:
diff --git a/templates/archivebody.template.html b/templates/archivebody.template.html
deleted file mode 100644 (file)
index c7c6bef..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<h1>Archive</h1>
-
-<!-- MOUNT_ARCHIVEITEM -->
similarity index 60%
rename from templates/head.template.html
rename to templates/archivepage.template.html
index ee53597..2dc1b7f 100644 (file)
@@ -2,10 +2,18 @@
 <html>
 <head>
     <meta charset="utf-8">
-    <link rel="stylesheet" href="#"> 
     <link rel="shortcut icon" href="#">
-    <title></title>
+    <title>Archive</title>
 
     <link rel="stylesheet" href="$SITEURL/stylesheets/root.css">
 </head>
 <body>
+
+    <h1>Archive</h1>
+
+    <!-- _MOUNT_ARCHIVEITEM -->
+
+</body>
+<footer>
+</footer>
+</html>
diff --git a/templates/articlepage.template.html b/templates/articlepage.template.html
new file mode 100644 (file)
index 0000000..e0d94db
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <link rel="shortcut icon" href="#">
+    <title>$ARTICLE_TITLE</title>
+
+    <link rel="stylesheet" href="$SITEURL/stylesheets/root.css">
+</head>
+<body>
+
+    <div>
+
+        <!-- _MOUNT_ARTICLECONTENT -->
+
+    </div>
+
+</body>
+<footer>
+</footer>
+</html>
index 30759b4..80d5e47 100644 (file)
@@ -6,7 +6,7 @@
 <link>$SITEURL</link>
 <description></description>
 
-<!-- MOUNT_FEEDITEM -->
+<!-- _MOUNT_FEEDITEM -->
 
 </channel>
 </rss>
diff --git a/templates/foot.template.html b/templates/foot.template.html
deleted file mode 100644 (file)
index 7320ede..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-</body>
-<footer>
-</footer>
-</html>
diff --git a/templates/rollingbody.template.html b/templates/rollingbody.template.html
deleted file mode 100644 (file)
index fd68895..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<h1>Rolling</h1>
-
-<!-- MOUNT_ROLLINGITEM -->
-
diff --git a/templates/rollingpage.template.html b/templates/rollingpage.template.html
new file mode 100644 (file)
index 0000000..e953cca
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <link rel="shortcut icon" href="#">
+    <title>Rolling</title>
+
+    <link rel="stylesheet" href="$SITEURL/stylesheets/root.css">
+</head>
+<body>
+
+    <h1>Rolling</h1>
+
+    <!-- _MOUNT_ROLLINGITEM -->
+
+</body>
+<footer>
+</footer>
+</html>