add thumbnail generation
This commit is contained in:
commit
e7db60b56d
44
Makefile
44
Makefile
@ -34,11 +34,14 @@ SRC_FLS =
|
|||||||
CSS_DIRS = style
|
CSS_DIRS = style
|
||||||
CSS_FILES =
|
CSS_FILES =
|
||||||
|
|
||||||
# SOURCE FILES:
|
# RESOURCE FILES:
|
||||||
# all RESOURCE_FLS and all files in the RESOURCE_DIRS will be copied to OUT_DIR
|
# all RESOURCE_FLS and all files in the RESOURCE_DIRS will be copied to OUT_DIR
|
||||||
RESOURCE_DIRS = resources
|
RESOURCE_DIRS = resources
|
||||||
RESOURCE_FLS =
|
RESOURCE_FLS =
|
||||||
|
|
||||||
|
# THUMBNAILS:
|
||||||
|
# if set, thumbnails for all resource files will be generated and placed in THUMB_OUT_DIR (relative to OUT_DIR)
|
||||||
|
THUMB_OUT_DIR = thumbs
|
||||||
|
|
||||||
# MULTI-LANG SOURCE FILES:
|
# MULTI-LANG SOURCE FILES:
|
||||||
# the files in COMMON_DIR will be built for all LANGS:
|
# the files in COMMON_DIR will be built for all LANGS:
|
||||||
@ -117,6 +120,15 @@ ML_OUT_DIRS = $(foreach lang, $(LANGS), $(patsubst $(_COMMON_DIR)/%, $(ML_OUT_D
|
|||||||
ML_OUT_FLS = $(foreach lang, $(LANGS), $(patsubst $(_COMMON_DIR)/%, $(ML_OUT_DIR)/$(lang)/%, $(_ML_SRC_FLS)))
|
ML_OUT_FLS = $(foreach lang, $(LANGS), $(patsubst $(_COMMON_DIR)/%, $(ML_OUT_DIR)/$(lang)/%, $(_ML_SRC_FLS)))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef THUMB_OUT_DIR
|
||||||
|
_THUMB_FOR_TYPES = png gif jpg jpeg webp pdf
|
||||||
|
_THUMB_TYPE = jpg
|
||||||
|
# files for which to generate thumbnails
|
||||||
|
_THUMB_FLS = $(filter $(foreach type, $(_THUMB_FOR_TYPES), %.$(type)), $(_RES_FLS))
|
||||||
|
THUMB_OUT_FLS = $(addsuffix .jpg, $(basename $(patsubst $(PROJECT_DIR)/%, $(OUT_DIR)/$(THUMB_OUT_DIR)/%, $(_THUMB_FLS))))
|
||||||
|
THUMB_OUT_DIRS = $(sort $(dir $(THUMB_OUT_FLS))) # sort for removing duplicates
|
||||||
|
endif
|
||||||
|
|
||||||
# needed for creating them
|
# needed for creating them
|
||||||
_DEP_DIRS = $(sort $(patsubst $(OUT_DIR)/%, $(DEP_DIR)/%, $(OUT_DIRS) $(ML_OUT_DIRS)))
|
_DEP_DIRS = $(sort $(patsubst $(OUT_DIR)/%, $(DEP_DIR)/%, $(OUT_DIRS) $(ML_OUT_DIRS)))
|
||||||
# needed for reading
|
# needed for reading
|
||||||
@ -129,8 +141,9 @@ _SASS_CMD = $(SASS_CMD) $(foreach includedir, $(_SASS_INCLUDE_DIRS), --load-pa
|
|||||||
FMT_VAR_SRC ="Variable '\e[1;34m%s\e[0m': \e[0;33m%s\e[0m\n"
|
FMT_VAR_SRC ="Variable '\e[1;34m%s\e[0m': \e[0;33m%s\e[0m\n"
|
||||||
FMT_VAR_OUT ="Variable '\e[1;34m%s\e[0m': \e[0;35m%s\e[0m\n"
|
FMT_VAR_OUT ="Variable '\e[1;34m%s\e[0m': \e[0;35m%s\e[0m\n"
|
||||||
FMT_DIR ="\e[1;34mMaking directory\e[0m: \e[0;35m%s\e[0m\n"
|
FMT_DIR ="\e[1;34mMaking directory\e[0m: \e[0;35m%s\e[0m\n"
|
||||||
FMT_OUT_HTML ="\e[1;34mBuilding html\e[0m \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
FMT_OUT_HTML ="\e[1;34mBuilding html\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
||||||
FMT_OUT_CSS ="\e[1;34mBuilding css\e[0m \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
FMT_OUT_CSS ="\e[1;34mBuilding css\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
||||||
|
FMT_OUT_THUMB ="\e[1;34mBuilding thumbnail\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
||||||
FMT_OUT_OTHER ="\e[1;34mBuilding\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
FMT_OUT_OTHER ="\e[1;34mBuilding\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
||||||
|
|
||||||
FMT_OUT_ML_HTML="\e[1;34mBuilding html\e[0m in lang \e[1;34m%s\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
FMT_OUT_ML_HTML="\e[1;34mBuilding html\e[0m in lang \e[1;34m%s\e[0m: \e[1;33m%s\e[0m at \e[1;35m%s\e[0m\n"
|
||||||
@ -145,10 +158,11 @@ FMT_OUT_ML_OTHER="\e[1;34mBuilding\e[0m in lang \e[1;34m%s\e[0m: \e[1;33m%s\e[0m
|
|||||||
# include all the dependency makefiles
|
# include all the dependency makefiles
|
||||||
include $(_DEP_FLS)
|
include $(_DEP_FLS)
|
||||||
|
|
||||||
all: normal multilang resources
|
all: normal multilang resources thumbnails
|
||||||
normal: $(OUT_FLS)
|
normal: $(OUT_FLS)
|
||||||
multilang: $(ML_OUT_FLS)
|
multilang: $(ML_OUT_FLS)
|
||||||
resources: $(RES_OUT_FLS)
|
resources: $(RES_OUT_FLS)
|
||||||
|
thumbnails: $(THUMB_OUT_FLS)
|
||||||
|
|
||||||
print:
|
print:
|
||||||
@printf $(FMT_VAR_SRC) "PROJECT_DIR" "$(PROJECT_DIR)"
|
@printf $(FMT_VAR_SRC) "PROJECT_DIR" "$(PROJECT_DIR)"
|
||||||
@ -164,10 +178,16 @@ ifdef COMMON_DIR
|
|||||||
@printf $(FMT_VAR_OUT) "ML_OUT_FLS" "$(ML_OUT_FLS)"
|
@printf $(FMT_VAR_OUT) "ML_OUT_FLS" "$(ML_OUT_FLS)"
|
||||||
endif
|
endif
|
||||||
@printf $(FMT_VAR_SRC) "_DEP_FLS" "$(_DEP_FLS)"
|
@printf $(FMT_VAR_SRC) "_DEP_FLS" "$(_DEP_FLS)"
|
||||||
|
ifdef THUMB_OUT_DIR
|
||||||
|
@printf $(FMT_VAR_SRC) "THUMB_OUT_DIR" "$(THUMB_OUT_DIR)"
|
||||||
|
@printf $(FMT_VAR_OUT) "_THUMB_FLS" "$(_THUMB_FLS)"
|
||||||
|
@printf $(FMT_VAR_OUT) "THUMB_OUT_FLS" "$(THUMB_OUT_FLS)"
|
||||||
|
@printf $(FMT_VAR_OUT) "THUMB_OUT_DIRS" "$(THUMB_OUT_DIRS)"
|
||||||
|
endif
|
||||||
@# @printf $(FMT_VAR_SRC) "y" "$(y)"
|
@# @printf $(FMT_VAR_SRC) "y" "$(y)"
|
||||||
|
|
||||||
# DIRECTORIES
|
# DIRECTORIES
|
||||||
$(sort $(ML_OUT_DIRS) $(_DEP_DIRS) $(RES_OUT_DIRS) $(OUT_DIRS)):
|
$(sort $(ML_OUT_DIRS) $(_DEP_DIRS) $(RES_OUT_DIRS) $(OUT_DIRS) $(THUMB_OUT_DIRS)):
|
||||||
@printf $(FMT_DIR) "$@"
|
@printf $(FMT_DIR) "$@"
|
||||||
@mkdir -p $@
|
@mkdir -p $@
|
||||||
|
|
||||||
@ -190,6 +210,20 @@ $(foreach out_dir, $(ML_OUT_LANG_DIRS), $(out_dir)/%): $(_COMMON_DIR)/% | $(ML_O
|
|||||||
cp $< $@
|
cp $< $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# THUMBNAILS
|
||||||
|
$(OUT_DIR)/$(THUMB_OUT_DIR)/%.jpg: | $(THUMB_OUT_DIRS)
|
||||||
|
@fulltarget="$@"; \
|
||||||
|
target="$(patsubst $(OUT_DIR)/$(THUMB_OUT_DIR)/%.jpg,%,$@)"; \
|
||||||
|
sources=($(_THUMB_FLS)); \
|
||||||
|
source=$$(printf "%s\n" $${sources[@]} | grep "$$target"'\.'); \
|
||||||
|
printf $(FMT_OUT_THUMB) "$$source" "$$fulltarget"; \
|
||||||
|
if [ "$${source##*.}" = "pdf" ]; then \
|
||||||
|
pdftoppm -f 1 -singlefile -jpeg -r 50 "$$source" "$${fulltarget%.*}"; \
|
||||||
|
else \
|
||||||
|
magick "$$source" -thumbnail '100x100>' "$@"; \
|
||||||
|
fi; \
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# (NORMAL/RE-)SOURCE RULES
|
# (NORMAL/RE-)SOURCE RULES
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user