Compare commits
2 Commits
78db14d6fb
...
5e7bca80ad
Author | SHA1 | Date |
---|---|---|
Yann Esposito (Yogsototh) | 5e7bca80ad | |
Yann Esposito (Yogsototh) | d937afc208 |
5
Makefile
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" > "$@"
|
||||
|
|
|
@ -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
|
||||
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 \
|
||||
|
|
|
@ -7,10 +7,18 @@ sizeof() {
|
|||
stat --format="%s" "$*"
|
||||
}
|
||||
|
||||
convert "$src" -resize 800x800\> -quality 50 "$dst"
|
||||
|
||||
convert "$src" -resize 800x800\> "$dst"
|
||||
|
||||
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
|
||||
cp -f "$src" "$dst"
|
||||
|
|
Loading…
Reference in New Issue