shithub: ugh

Download patch

ref: 50d1e1e5c145616520252b13a8fb52c5500c8403
parent: 97ea5f9d36a15496ab4d58eb9d9a325d9dbc446d
author: kvik <kvik@a-b.xyz>
date: Tue Jul 28 14:23:06 EDT 2020

Add the programs

diff: cannot open b/bin//null: 'b/bin//null' does not exist
--- /dev/null
+++ b/bin/filter-markdown
@@ -1,0 +1,2 @@
+#!/bin/rc
+exec markdown -T -f toc $*
--- /dev/null
+++ b/bin/md2html
@@ -1,0 +1,27 @@
+#!/bin/rc -e
+rfork e
+flagfmt = ''; args = 'a.md a.html'
+eval `''{aux/getflags $*} || exec aux/usage
+if(! ~ $#* 2) exec aux/usage
+
+md = $1
+html = $2
+
+fn expand {
+	template = $1
+	eval 'cat <<ENDOFTEMPLATE
+' ^ `''{cat $template} ^ '
+ENDOFTEMPLATE'
+}
+
+# Template variables
+# TODO: Source these from templates/env or something.
+language = 'en'
+
+stub = `{echo $md | sed 's@\..*$@@'}
+title = `{sed 's@^# @@; 1q' $stub.md}
+head = `''{expand templates/head.html}
+body = `''{bin/filter-markdown $stub.md}
+body = `''{expand templates/body.html}
+expand templates/page.html >$html.tmp
+mv $html.tmp $html
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,25 @@
+articles = `{walk -f data/}
+articles = ${articles:data/%=public/%}
+md =    `{{for(i in $articles) echo $i}| grep '\.md$'}
+txt =   `{{for(i in $articles) echo $i}| grep '\.txt$'}
+shtml = `{{for(i in $articles) echo $i}| grep '\.shtml$'}
+articles = ${md:   public/%.md=   public/%.html} \
+           ${shtml:public/%.shtml=public/%.html} \
+           $md $txt
+
+all:V: $articles
+
+clean:V:
+	rm -rf $articles
+
+public/%.html: data/%.md
+	bin/md2html data/$stem.md $target
+
+public/%.html: data/%.shtml
+	cp data/$stem.shtml $target
+
+public/%.md: data/%.md
+	cp data/$stem.md $target
+
+public/%.txt: data/%.txt
+	cp data/$stem.txt $target