]> git.mdlowis.com Git - projs/mikedlowis.github.io/commitdiff
Add support for multi section pages
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 20 Aug 2015 01:37:29 +0000 (21:37 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 20 Aug 2015 01:37:29 +0000 (21:37 -0400)
12 files changed:
Makefile
pages/articles.md
pages/projects.md
pages/prototypes.md
site/articles.html
site/projects.html
site/prototypes.html
site/style.css
templates/article.html [new file with mode: 0644]
templates/page.html
tools/genpage
tools/sections.awk [new file with mode: 0755]

index 171bdddfafb9efd8e4a6292925c9a55fe5a913e2..2878de19b300f9e5afee6874c64ed4056094f894 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ PAGES = $(addprefix site/,$(addsuffix .html,$(basename $(notdir $(wildcard pages
 all: $(PAGES)
 
 serve:
-       serve
+       tools/serve
 
 site/%.html : pages/%.md
        genpage $< > $@
index 76fa1430e757c634b10c3e155f0ed00b517a6332..998a635febb5c64a87457d39d559d1533cfedf53 100644 (file)
@@ -1,4 +1,8 @@
 TYPE page
 MENUID 1
 ---
+# Articles
 
+articles
+---
+foo
index 5428d35eb87ac9b9b3b153b904956c6d02bf6c42..0439d65953e15eea8ef614b71ff7a83f4d35c430 100644 (file)
@@ -1,4 +1,6 @@
 TYPE page
 MENUID 2
 ---
+# Projects
 
+projects
index 7f406b12cd2a76953c7ef3514ec1049b57491596..49d20d8302b81a3dbeb8f85259ad27b970869eb3 100644 (file)
@@ -1,4 +1,7 @@
 TYPE page
 MENUID 3
 ---
+# Prototypes
+
+prototypes
 
index 32a6729f7b58e006e43d62af7321c3d5632b684e..ff442188ab49b46e37e028a8f98565df65c74963 100644 (file)
@@ -35,7 +35,8 @@
         </div>
 
         <div class="main">
-            
+            <h1>Articles</h1>
+<p>articles</p>
         </div>
     </div>
 
index 2545fb917d3320f1fe9d74c253a0ba93d7cb3c2b..051853c66cf26d46229c443ed1d40da9188e892c 100644 (file)
@@ -35,7 +35,8 @@
         </div>
 
         <div class="main">
-            
+            <h1>Projects</h1>
+<p>projects</p>
         </div>
     </div>
 
index fa0a90a71fa35c0bea866a145b36d8a26a23fcbd..1fa2443660b1cb17bae96775def4a49e8435029d 100644 (file)
@@ -35,7 +35,8 @@
         </div>
 
         <div class="main">
-            
+            <h1>Prototypes</h1>
+<p>prototypes</p>
         </div>
     </div>
 
index dc8352866c550dc8981bc669acfa2d23b4f31a34..ad20ea2546ed8b252e0188639d03bc10209acc2c 100644 (file)
@@ -114,4 +114,3 @@ a {
     margin: 0 0 1.5em 0;
     border-top: 1px solid #cccccc;
 }
-
diff --git a/templates/article.html b/templates/article.html
new file mode 100644 (file)
index 0000000..f41fa0f
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<!-- Site design *heavily* based on the excellent design of http://suckless.org/ -->
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>{{TITLE}}</title>
+    <link rel="shortcut icon" type="image/x-icon" href="{{LOGO}}" />
+    <link rel="stylesheet" type="text/css" href="{{STYLE}}">
+    <meta charset="utf-8">
+    <style>
+    #menuitem{{MENUID}} { font-weight: bold; }
+    </style>
+</head>
+<body>
+    <div class="header">
+        <a href="index.html"><img src="{{LOGO}}"></a>
+        <a class="headerLink" href="index.html">mdlowis</a>
+        <span class="headerSubtitle">{{SUBTITLE}}</span>
+    </div>
+
+    <div class="menu">
+        {{MENUTEXT}}
+    </div>
+
+    <div class="content">
+        <div class="nav">
+            {{SECTION1}}
+        </div>
+        <div class="main">
+            {{SECTION2}}
+        </div>
+    </div>
+
+    <div class="footer">
+        <span class="right">{{COPYRIGHT}}</span>
+    </div>
+</body><div></div></html>
index 4e66a660effe307da1349782d8fb4d777fdd9be9..37bce8926e80d61ea16fdeceb6903d35ca6f5a13 100644 (file)
@@ -30,7 +30,7 @@
         </div>
 
         <div class="main">
-            {{CONTENT}}
+            {{SECTION1}}
         </div>
     </div>
 
index 0bee9cf9d16ea393cd6e44d9ca427dd22ad2b2b2..14af1646e5f60c120fc23c278b4e4056d39346a0 100755 (executable)
@@ -1,30 +1,44 @@
 #!/bin/sh
-awk_script='
-BEGIN {
-    file = OFILE
-    mode = 0
-}
 
-mode == 1 { print $0 > file }
+#awk_script='
+#BEGIN {
+#    file = OFILE
+#    mode = 0
+#}
+#
+#mode == 1 { print $0 > file }
+#
+#mode == 0 {
+#    if (($0 != "") && ($1 != "#")) {
+#        if ($0 != "---") {
+#            first = $1
+#            $1 = ""
+#            print "export " first "=\"" substr($0, 2) "\""
+#        } else {
+#            mode = 1
+#        }
+#    }
+#}'
 
-mode == 0 {
-    if (($0 != "") && ($1 != "#")) {
-        if ($0 != "---") {
-            first = $1
-            $1 = ""
-            print "export " first "=\"" substr($0, 2) "\""
-        } else {
-            mode = 1
-        }
-    }
-}'
 ifile=${1:?"missing filename"}
-ofile="contents.${0##*/}-$$"
-touch $ofile
-eval `awk -v OFILE="$ofile" "$awk_script" $ifile`
-export CONTENT="`md2html.awk $ofile`"
+sections=(`awk -v PID="$$" -f ./tools/sections.awk $ifile`)
+
+for i in "${!sections[@]}"; do
+    if [[ "$i" -eq "0" ]]; then
+        source "${sections[$i]}"
+    else
+        eval "export SECTION$i=\"`./tools/md2html.awk ${sections[$i]}`\""
+    fi
+    rm "${sections[$i]}"
+done
+
+#ifile=${1:?"missing filename"}
+#ofile="contents.${0##*/}-$$"
+#touch $ofile
+#eval `awk -v OFILE="$ofile" "$awk_script" $ifile`
+#export CONTENT="`md2html.awk $ofile`"
 . ./config.sh
 if [ -f "templates/$TYPE.html" ]; then
     mo "templates/$TYPE.html"
 fi
-rm $ofile
+#rm $ofile
diff --git a/tools/sections.awk b/tools/sections.awk
new file mode 100755 (executable)
index 0000000..ecc46b9
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/env awk -f
+
+BEGIN {
+    mode = 0
+    pid = PID
+    sectid = 0
+    newfile = "section-" sectid "-" pid
+    ofile = ""
+}
+
+ofile == "" {
+    ofile = newfile
+    print ofile
+}
+
+mode == 0 {
+    if (($0 != "") && ($1 != "#")) {
+        if ($0 != "---") {
+            first = $1
+            $1 = ""
+            print "export " first "=\"" substr($0, 2) "\"" > ofile
+        } else {
+            mode = 1
+            sectid = sectid + 1
+            newfile = "section-" sectid "-" pid
+            ofile = ""
+        }
+    }
+}
+
+mode == 1 {
+    if ($0 != "---") {
+        print $0 > ofile
+    } else {
+        sectid = sectid + 1
+        newfile = "section-" sectid "-" pid
+        ofile = ""
+    }
+}
+