parent
2bffa4154b
commit
d937afc208
5
Makefile
5
Makefile
|
@ -47,9 +47,10 @@ DST_PANDOC_FILES ?= $(patsubst %$(EXT),%.html, \
|
||||||
$(SRC_PANDOC_FILES)))
|
$(SRC_PANDOC_FILES)))
|
||||||
PANDOC_TEMPLATE ?= templates/post.html
|
PANDOC_TEMPLATE ?= templates/post.html
|
||||||
PANDOC_LUA_FILTER ?= engine/links-to-html.lua
|
PANDOC_LUA_FILTER ?= engine/links-to-html.lua
|
||||||
|
PANDOC_LUA_FILTER_IMG ?= engine/img-to-webp.lua
|
||||||
MK_HTML := engine/mk-html.sh
|
MK_HTML := engine/mk-html.sh
|
||||||
PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER)
|
PANDOC := $(MK_HTML) $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG)
|
||||||
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(MK_HTML) $(ENV_VARS)
|
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(PANDOC_LUA_FILTER) $(PANDOC_LUA_FILTER_IMG) $(MK_HTML) $(ENV_VARS)
|
||||||
@mkdir -p "$(dir $@)"
|
@mkdir -p "$(dir $@)"
|
||||||
$(PANDOC) "$<" "$@.tmp"
|
$(PANDOC) "$<" "$@.tmp"
|
||||||
minify --mime text/html "$@.tmp" > "$@"
|
minify --mime text/html "$@.tmp" > "$@"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
-- img-to-webp.lua
|
||||||
|
function Image(el)
|
||||||
|
local fileext = el.src:match("%.[^%.]+$");
|
||||||
|
-- DEBUG -- print("LUA IMG: ", fileext);
|
||||||
|
if ( fileext == ".jpg" or fileext == ".png" or fileext == ".jpeg" ) then
|
||||||
|
el.src = el.src .. ".webp"
|
||||||
|
end
|
||||||
|
return el
|
||||||
|
end
|
|
@ -4,8 +4,9 @@ set -eu
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit 1
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
template="$1"
|
template="$1"
|
||||||
luafilter="$2"
|
luafilter="$2"
|
||||||
orgfile="$3"
|
luafilterimg="$3"
|
||||||
htmlfile="$4"
|
orgfile="$4"
|
||||||
|
htmlfile="$5"
|
||||||
|
|
||||||
tocoption=""
|
tocoption=""
|
||||||
if grep -ie '^#+options:' "$orgfile" | grep 'toc:t'>/dev/null; then
|
if grep -ie '^#+options:' "$orgfile" | grep 'toc:t'>/dev/null; then
|
||||||
|
@ -16,6 +17,7 @@ set -x
|
||||||
pandoc $tocoption \
|
pandoc $tocoption \
|
||||||
--template="$template" \
|
--template="$template" \
|
||||||
--lua-filter="$luafilter" \
|
--lua-filter="$luafilter" \
|
||||||
|
--lua-filter="$luafilterimg" \
|
||||||
--mathml \
|
--mathml \
|
||||||
--from org \
|
--from org \
|
||||||
--to html5 \
|
--to html5 \
|
||||||
|
|
|
@ -7,10 +7,18 @@ sizeof() {
|
||||||
stat --format="%s" "$*"
|
stat --format="%s" "$*"
|
||||||
}
|
}
|
||||||
|
|
||||||
convert "$src" -resize 800x800\> -quality 50 "$dst"
|
|
||||||
|
convert "$src" -resize 800x800\> "$dst"
|
||||||
|
|
||||||
before=$(sizeof $src)
|
before=$(sizeof $src)
|
||||||
after=$(sizeof $dst)
|
|
||||||
|
if [[ "${src:e}" == "gif" ]]; then
|
||||||
|
after=$(sizeof $dst)
|
||||||
|
else
|
||||||
|
cwebp "$dst" -quiet -o "$dst.webp"
|
||||||
|
after=$(sizeof $dst.webp)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if (( before <= after )); then
|
if (( before <= after )); then
|
||||||
cp -f "$src" "$dst"
|
cp -f "$src" "$dst"
|
||||||
|
|
Loading…
Reference in New Issue