diff --git a/Makefile b/Makefile index f0c303f..83d0dca 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,10 @@ DST_PANDOC_FILES ?= $(patsubst %$(EXT),%.html, \ $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%, \ $(SRC_PANDOC_FILES))) PANDOC_TEMPLATE ?= templates/post.html +PANDOC_LUA_FILTER ?= engine/links-to-html.lua MK_HTML := engine/mk-html.sh -PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) -$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(MK_HTML) +PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) +$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(MK_HTML) @mkdir -p "$(dir $@)" $(PANDOC) "$<" "$@.tmp" minify --mime text/html "$@.tmp" > "$@" diff --git a/engine/lighttpd.conf b/engine/lighttpd.conf new file mode 100644 index 0000000..fc111e0 --- /dev/null +++ b/engine/lighttpd.conf @@ -0,0 +1,25 @@ +server.bind = "0.0.0.0" +server.port = 3077 +server.document-root = var.CWD + "/_site/" + +index-file.names = ( "index.html" ) + +mimetype.assign = ( + ".css" => "text/css", + ".gif" => "image/gif", + ".htm" => "text/html", + ".html" => "text/html", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".js" => "text/javascript", + ".png" => "image/png", + ".swf" => "application/x-shockwave-flash", + ".txt" => "text/plain", + ".gmi" => "text/plain" +) + +# Making sure file uploads above 64k always work when using IE or Safari +# For more information, see http://trac.lighttpd.net/trac/ticket/360 +$HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" { + server.max-keep-alive-requests = 0 +} diff --git a/engine/links-to-html.lua b/engine/links-to-html.lua new file mode 100644 index 0000000..da10821 --- /dev/null +++ b/engine/links-to-html.lua @@ -0,0 +1,5 @@ +-- links-to-html.lua +function Link(el) + el.target = string.gsub(string.gsub(el.target, "%.org", ".html"), "%.html::", ".html#" ) + return el +end diff --git a/engine/mk-html.sh b/engine/mk-html.sh index b76355c..5fbce41 100755 --- a/engine/mk-html.sh +++ b/engine/mk-html.sh @@ -3,8 +3,9 @@ set -eu cd "$(git rev-parse --show-toplevel)" || exit 1 template="$1" -orgfile="$2" -htmlfile="$3" +luafilter="$2" +orgfile="$3" +htmlfile="$4" tocoption="" if grep -ie '^#+options:' "$orgfile" | grep 'toc:t'>/dev/null; then @@ -14,6 +15,7 @@ fi set -x pandoc $tocoption \ --template="$template" \ + --lua-filter="$luafilter" \ --mathml \ --from org \ --to html5 \ diff --git a/engine/serve.sh b/engine/serve.sh index 97dfe83..bf6109f 100755 --- a/engine/serve.sh +++ b/engine/serve.sh @@ -2,12 +2,6 @@ cd "$(git rev-parse --show-toplevel)" || exit 1 -if (( $# == 0 )); then - webdir="_site" -else - webdir="$1" -fi - -cd $webdir && \ -echo "Serving: $webdir" && \ -http-server -p 3000 +webdir="_site" +echo "Serving: $webdir on http://localhost:3077" && \ +lighttpd -f ./engine/lighttpd.conf -D diff --git a/shell.nix b/shell.nix index fd21969..ffea5d8 100644 --- a/shell.nix +++ b/shell.nix @@ -27,5 +27,6 @@ pkgs.mkShell { # for emacs dev ripgrep nodePackages.http-server + lighttpd ]; }