lighttpd + org-links with lua

This commit is contained in:
Yann Esposito (Yogsototh) 2021-09-20 14:09:52 +02:00
parent 2acd6effce
commit 736b8e39b6
Firmato da un utente non attendibile che non corrisponde al committer: yogsototh
ID Chiave GPG: 7B19A4C650D59646
6 ha cambiato i file con 41 aggiunte e 13 eliminazioni

Vedi File

@ -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" > "$@"

25
engine/lighttpd.conf Normal file
Vedi File

@ -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
}

5
engine/links-to-html.lua Normal file
Vedi File

@ -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

Vedi File

@ -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 \

Vedi File

@ -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

Vedi File

@ -27,5 +27,6 @@ pkgs.mkShell {
# for emacs dev
ripgrep
nodePackages.http-server
lighttpd
];
}