+++ /dev/null
-
-PATH := $(PWD)/tools:$(PATH)
-PAGES = $(addprefix site/,$(addsuffix .html,$(basename $(notdir $(wildcard pages/*.md)))))
-
-.PHONY: serve
-all: $(PAGES) site/index.html
-
-serve:
- tools/serve
-
-site/index.html: index.html
- cp $^ $@
-
-site/%.html : pages/%.md
- genpage $< > $@
-
-clean:
- rm site/*.html
+++ /dev/null
-#!/bin/sh
-
-export TITLE="Simplicity is the ultimate sophistication"
-export SUBTITLE="$TITLE"
-export COPYRIGHT="© 2015 Michael D. Lowis"
-export STYLE="/site/style.css"
-export LOGO="/site/logo.png"
-export MENUTEXT="`genmenu.sh`"
-
--- /dev/null
+#!/bin/env ruby
+require 'fileutils'
+require 'erb'
+
+SRCDIR="src/"
+DESTDIR="foo/"
+TEMPLATE = IO.read("page.html.erb")
+
+class Page
+ attr_accessor :year, :navigation, :markdown
+
+ def initialize(src)
+ @year = Time.new.year
+ @markdown = `tools/md2html.awk #{src}`
+ end
+
+ def render
+ ERB.new(TEMPLATE).result(binding)
+ end
+end
+
+def generate(p)
+ op = p.gsub(/^#{SRCDIR}/,'')
+ FileUtils.mkdir_p(File.join(DESTDIR, op))
+ op = File.join(DESTDIR, op)
+ if p.end_with? ".md" then
+ op = File.join(File.dirname(op), "#{File.basename(op,'.*')}.html")
+ File.open(op, 'w') { |file| file.write(Page.new(p).render) }
+ else
+ FileUtils.copy(p, op)
+ end
+end
+
+Dir.glob("#{SRCDIR}/**/*").each do |f|
+ generate(f) if File.file?(f)
+end
+++ /dev/null
-#!/bin/bash
-
-pages=(`ls pages/*.md | sed -e 's/\.md$//'`)
-
-echo ${pages[@]}
+++ /dev/null
-#!/bin/sh
-
-SRCDIR="$1"
-DESTDIR="$2"
-
-genpage(){
- src="$1"
- dest="$2"
-
- if [[ -d "$src" ]]; then
- echo "dir: '$src'"
- else
- ofile="$dest/${src#src/}"
- ofile="${ofile%.*}.html"
- dest="${ofile%/*}"
- echo "page: $src -> $ofile"
- mkdir -p "$dest"
- tools/md2html.awk "$src" > "$ofile"
- fi
-}
-
-for p in $(find "$SRCDIR" -mindepth 1 -maxdepth 1); do
- genpage "$p" "$DESTDIR"
-done
-