Procházet zdrojové kódy

lighttpd + org-links with lua

webp
Yann Esposito (Yogsototh) před 3 měsíci
rodič
revize
736b8e39b6
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 5
      Makefile
  2. 25
      engine/lighttpd.conf
  3. 5
      engine/links-to-html.lua
  4. 6
      engine/mk-html.sh
  5. 12
      engine/serve.sh
  6. 1
      shell.nix

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

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

5
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

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

12
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

1
shell.nix

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

Načítá se…
Zrušit
Uložit