Browse Source

lighttpd + org-links with lua

webp
parent
commit
736b8e39b6
Signed by: Yann Esposito (Yogsototh) <yann.esposito@gmail.com> GPG Key ID: 7B19A4C650D59646
6 changed files with 41 additions and 13 deletions
  1. 3
    2
      Makefile
  2. 25
    0
      engine/lighttpd.conf
  3. 5
    0
      engine/links-to-html.lua
  4. 4
    2
      engine/mk-html.sh
  5. 3
    9
      engine/serve.sh
  6. 1
    0
      shell.nix

+ 3
- 2
Makefile View 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
- 0
engine/lighttpd.conf View 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
- 0
engine/links-to-html.lua View 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

+ 4
- 2
engine/mk-html.sh View 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 \

+ 3
- 9
engine/serve.sh View 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

+ 1
- 0
shell.nix View File

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

Loading…
Cancel
Save