Browse Source

webp

todo: fix gif
parent
commit
829ab57233
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 5
      Makefile
  2. 5
      engine/img-to-webp.lua
  3. 6
      engine/mk-html.sh
  4. 5
      engine/optim-img.sh
  5. 1
      shell.nix

5
Makefile

@ -47,9 +47,10 @@ DST_PANDOC_FILES ?= $(patsubst %$(EXT),%.html, \
$(SRC_PANDOC_FILES)))
PANDOC_TEMPLATE ?= templates/post.html
PANDOC_LUA_FILTER ?= engine/links-to-html.lua
PANDOC_LUA_FILTER_IMG ?= engine/img-to-webp.lua
MK_HTML := engine/mk-html.sh
PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER)
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(MK_HTML) $(ENV_VARS)
PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG)
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG) $(MK_HTML) $(ENV_VARS)
@mkdir -p "$(dir $@)"
$(PANDOC) "$<" "$@.tmp"
minify --mime text/html "$@.tmp" > "$@"

5
engine/img-to-webp.lua

@ -0,0 +1,5 @@
-- img-to-webp.lua
function Image(el)
el.src = el.src .. ".webp"
return el
end

6
engine/mk-html.sh

@ -4,8 +4,9 @@ set -eu
cd "$(git rev-parse --show-toplevel)" || exit 1
template="$1"
luafilter="$2"
orgfile="$3"
htmlfile="$4"
luafilterimg="$3"
orgfile="$4"
htmlfile="$5"
tocoption=""
if grep -ie '^#+options:' "$orgfile" | grep 'toc:t'>/dev/null; then
@ -16,6 +17,7 @@ set -x
pandoc $tocoption \
--template="$template" \
--lua-filter="$luafilter" \
--lua-filter="$luafilterimg" \
--mathml \
--from org \
--to html5 \

5
engine/optim-img.sh

@ -7,10 +7,11 @@ sizeof() {
stat --format="%s" "$*"
}
convert "$src" -resize 800x800\> -quality 50 "$dst"
convert "$src" -resize 800x800\> "$dst"
cwebp "$dst" -quiet -o "$dst.webp"
before=$(sizeof $src)
after=$(sizeof $dst)
after=$(sizeof $dst.webp)
if (( before <= after )); then
cp -f "$src" "$dst"

1
shell.nix

@ -24,6 +24,7 @@ pkgs.mkShell {
direnv
ghc
tmux
libwebp
# for emacs dev
ripgrep
nodePackages.http-server

Loading…
Cancel
Save