2021-03-07 14:49:25 -05:00
|
|
|
CABALFLAGS ?= --verbose=0 --jobs
|
|
|
|
|
2020-07-19 12:05:01 -04:00
|
|
|
DATADIR := data
|
|
|
|
TMPDIR := _tmp
|
|
|
|
BUILDDIR := _build
|
|
|
|
INFONAME := info.yaml
|
|
|
|
ROOT := https://gallery.niss.website
|
2020-07-14 01:10:33 -04:00
|
|
|
|
|
|
|
# SMALL = thumbnails, MED = single pages (link to full size)
|
|
|
|
SMALL := 200
|
2020-07-18 18:11:42 -04:00
|
|
|
MEDW := 1000
|
|
|
|
MEDH := 1200
|
2020-07-14 01:10:33 -04:00
|
|
|
|
2020-07-19 12:05:01 -04:00
|
|
|
MAKEPAGES := $(TMPDIR)/make-pages
|
2020-07-14 01:10:33 -04:00
|
|
|
|
2020-07-17 06:29:13 -04:00
|
|
|
YAMLS != find $(DATADIR) -name $(INFONAME)
|
2020-07-15 05:58:44 -04:00
|
|
|
|
2020-07-31 23:09:23 -04:00
|
|
|
SCRIPTS != find script -name '*.js'
|
2020-07-19 16:36:15 -04:00
|
|
|
STYLES != find style -name '*.css'
|
|
|
|
STYLESVGS != find style -name '*.svg'
|
|
|
|
STYLEPNGS != find style -name '*.png'
|
2020-07-18 05:44:30 -04:00
|
|
|
|
2020-07-31 23:09:23 -04:00
|
|
|
FONTS != find fonts \
|
2020-07-17 06:29:13 -04:00
|
|
|
-iname '*.eot' -or -iname '*.svg' -or \
|
|
|
|
-iname '*.ttf' -or -iname '*.woff' -or \
|
2020-07-31 23:09:23 -04:00
|
|
|
-iname '*.woff2' -or -iname '*.css'
|
2020-07-18 05:44:30 -04:00
|
|
|
|
2020-07-31 23:09:23 -04:00
|
|
|
STATIC = $(SCRIPTS) $(STYLES) $(STYLEPNGS) $(STYLESVGS) $(FONTS)
|
|
|
|
BSTATIC = $(patsubst %,$(BUILDDIR)/%,$(STATIC))
|
2020-07-17 06:29:13 -04:00
|
|
|
|
2020-07-18 05:58:41 -04:00
|
|
|
.PHONY: all build
|
|
|
|
all: build
|
|
|
|
build: $(BUILDDIR)/index.html $(BSTATIC)
|
2020-07-17 06:29:13 -04:00
|
|
|
|
2020-07-19 06:08:44 -04:00
|
|
|
$(BUILDDIR)/index.html: $(DATADIR)/index.yaml $(MAKEPAGES)
|
2020-07-18 05:58:41 -04:00
|
|
|
echo "[index] "$@
|
2020-07-17 06:29:13 -04:00
|
|
|
mkdir -p $(dir $@)
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) $(MPFLAGS) index --root $(ROOT) $< --output $@
|
2020-07-15 05:58:44 -04:00
|
|
|
|
2020-07-18 05:44:30 -04:00
|
|
|
|
2020-07-18 05:58:41 -04:00
|
|
|
$(BUILDDIR)/%: %
|
2020-07-25 21:04:40 -04:00
|
|
|
$(call copy)
|
2020-07-18 05:58:41 -04:00
|
|
|
|
|
|
|
$(BUILDDIR)/%: $(TMPDIR)/%
|
2021-03-07 14:49:25 -05:00
|
|
|
$(call copy,--link)
|
2020-07-18 05:58:41 -04:00
|
|
|
|
2020-07-15 14:09:40 -04:00
|
|
|
|
2020-07-24 09:20:10 -04:00
|
|
|
$(TMPDIR)/%_small.png: $(DATADIR)/%.png
|
|
|
|
$(call resize,$(SMALL),$(SMALL),^,-gravity center -crop 1:1+0)
|
|
|
|
|
|
|
|
$(TMPDIR)/%_med.png: $(DATADIR)/%.png
|
|
|
|
$(call resize,$(MEDW),$(MEDH),>)
|
|
|
|
|
|
|
|
|
2020-09-13 16:11:21 -04:00
|
|
|
$(TMPDIR)/%_small.jpg: $(DATADIR)/%.jpg
|
|
|
|
$(call resize,$(SMALL),$(SMALL),^,-gravity center -crop 1:1+0)
|
|
|
|
|
|
|
|
$(TMPDIR)/%_med.jpg: $(DATADIR)/%.jpg
|
|
|
|
$(call resize,$(MEDW),$(MEDH),>)
|
|
|
|
|
|
|
|
|
2020-07-17 06:29:13 -04:00
|
|
|
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
|
2020-07-16 10:07:28 -04:00
|
|
|
echo "[make-pages]"
|
|
|
|
mkdir -p $(dir $@)
|
2021-03-07 14:49:25 -05:00
|
|
|
cabal v2-build all $(CABALFLAGS)
|
2020-07-16 10:07:28 -04:00
|
|
|
find dist-newstyle -name make-pages -executable -type f \
|
|
|
|
-exec cp {} $@ \;
|
2020-07-14 01:10:33 -04:00
|
|
|
|
2020-07-18 05:58:41 -04:00
|
|
|
|
2020-07-21 19:48:08 -04:00
|
|
|
$(TMPDIR)/index.mk: $(DATADIR)/index.yaml $(YAMLS) $(MAKEPAGES)
|
2020-07-24 09:20:10 -04:00
|
|
|
$(call depend-gallery)
|
2020-07-15 14:09:40 -04:00
|
|
|
|
2020-08-01 09:54:39 -04:00
|
|
|
ifneq ($(MAKECMDGOALS),mostlyclean)
|
2020-07-21 05:27:31 -04:00
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
ifneq ($(MAKECMDGOALS),distclean)
|
2020-07-25 09:05:38 -04:00
|
|
|
ifneq ($(MAKECMDGOALS),list-tags)
|
2020-07-19 06:08:44 -04:00
|
|
|
-include $(TMPDIR)/index.mk
|
2020-07-21 05:27:31 -04:00
|
|
|
endif
|
|
|
|
endif
|
2020-07-25 09:05:38 -04:00
|
|
|
endif
|
2020-08-01 09:54:39 -04:00
|
|
|
endif
|
2020-07-15 05:58:58 -04:00
|
|
|
|
2020-07-18 05:58:41 -04:00
|
|
|
|
2020-08-16 14:35:22 -04:00
|
|
|
.PHONY: clean distclean
|
|
|
|
clean:
|
2020-08-01 09:54:39 -04:00
|
|
|
echo "[clean $(BUILDDIR)]"
|
|
|
|
rm -rf $(BUILDDIR)
|
2020-08-16 14:35:22 -04:00
|
|
|
distclean: clean
|
2020-08-01 09:54:39 -04:00
|
|
|
echo "[clean $(TMPDIR)]"
|
|
|
|
rm -rf $(TMPDIR)
|
|
|
|
echo "[cabal clean]"
|
2021-03-07 14:49:25 -05:00
|
|
|
cabal --verbose=0 v2-clean
|
2020-07-16 10:07:28 -04:00
|
|
|
|
2020-07-18 05:55:53 -04:00
|
|
|
|
2020-07-25 09:05:38 -04:00
|
|
|
.PHONY: list-tags
|
|
|
|
list-tags: $(MAKEPAGES)
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) list-tags --untagged --nsfw
|
2020-07-25 09:05:38 -04:00
|
|
|
|
|
|
|
|
2020-07-19 12:05:01 -04:00
|
|
|
HOST ?= gallery.niss.website
|
2020-07-18 05:55:53 -04:00
|
|
|
REMOTE_USER ?= www-data
|
2020-07-19 12:05:01 -04:00
|
|
|
IDFILE ?= ~/.ssh/xyz
|
|
|
|
REMOTE_DIR ?= gallery
|
2020-07-18 05:55:53 -04:00
|
|
|
|
2020-07-18 05:58:41 -04:00
|
|
|
.PHONY: upload
|
|
|
|
upload: build
|
2021-02-07 02:26:39 -05:00
|
|
|
@rsync --recursive --partial --progress --copy-links \
|
|
|
|
--compress --human-readable --hard-links --size-only \
|
2021-02-09 06:35:39 -05:00
|
|
|
--delete --delete-after \
|
2021-03-07 14:49:25 -05:00
|
|
|
--rsh='ssh -l $(REMOTE_USER) -i $(IDFILE)' \
|
2021-02-07 02:26:39 -05:00
|
|
|
$(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/
|
2020-07-18 05:55:53 -04:00
|
|
|
|
|
|
|
|
2020-07-31 23:09:23 -04:00
|
|
|
# one arg for extra flags
|
2020-07-24 09:20:10 -04:00
|
|
|
define copy
|
|
|
|
echo "[copy] "$@
|
|
|
|
mkdir -p "$(dir $@)"
|
2021-03-07 14:49:25 -05:00
|
|
|
cp $(1) --dereference "$^" "$@"
|
2020-07-24 09:20:10 -04:00
|
|
|
endef
|
|
|
|
|
|
|
|
# args:
|
|
|
|
# 1. width
|
|
|
|
# 2. height
|
|
|
|
# 3. imagemagick resize hint (^, <, !, etc)
|
|
|
|
# 4. other flags (e.g. cropping)
|
|
|
|
define resize
|
|
|
|
echo "[resize] "$@
|
|
|
|
mkdir -p "$(dir $@)"
|
|
|
|
convert -resize "$(1)x$(2)$(3)" $(4) "$^" "$@"
|
|
|
|
endef
|
|
|
|
|
|
|
|
# no args
|
|
|
|
define depend-gallery
|
|
|
|
echo "[deps] "$@
|
|
|
|
mkdir -p $(dir $@)
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< \
|
|
|
|
--output "$@" \
|
|
|
|
--build-dir "$(BUILDDIR)" \
|
|
|
|
--data-dir "$(DATADIR)" \
|
|
|
|
--tmp-dir "$(TMPDIR)" \
|
|
|
|
--info "$(INFONAME)"
|
2020-07-24 09:20:10 -04:00
|
|
|
endef
|
|
|
|
|
|
|
|
# args:
|
|
|
|
# 1. gallery prefix
|
|
|
|
# 2. build dir
|
|
|
|
# 3. data dir
|
|
|
|
# 4. other flags
|
|
|
|
define depend-single
|
|
|
|
echo "[deps] "$@
|
|
|
|
mkdir -p "$(dir $@)"
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) $(MPFLAGS) depend-single $(4) \
|
|
|
|
--output "$@" \
|
|
|
|
--prefix "$(1)" \
|
|
|
|
--build-dir "$(2)" \
|
|
|
|
--data-dir "$(3)" $<
|
2020-07-24 09:20:10 -04:00
|
|
|
endef
|
|
|
|
|
|
|
|
# args
|
2020-08-03 20:25:59 -04:00
|
|
|
# 1. index file
|
2020-07-24 09:20:10 -04:00
|
|
|
# 2. gallery prefix
|
|
|
|
# 3. other flags
|
|
|
|
define gallery
|
|
|
|
echo "[gallery] "$@
|
|
|
|
mkdir -p "$(dir $@)"
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) $(MPFLAGS) gallery $(3) \
|
|
|
|
--index "$(1)" \
|
|
|
|
--root "$(ROOT)" \
|
|
|
|
--prefix "$(2)" \
|
|
|
|
--output "$@" \
|
2020-07-24 09:20:10 -04:00
|
|
|
$(filter $(DATADIR)/%/$(INFONAME),$^)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# args:
|
|
|
|
# 1. data dir
|
2020-08-11 14:29:54 -04:00
|
|
|
# 2. gallery prefix
|
|
|
|
# 3. other flags
|
2020-07-24 09:20:10 -04:00
|
|
|
define single
|
|
|
|
echo "[single] "$@
|
|
|
|
mkdir -p "$(dir $@)"
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) $(MPFLAGS) single $(3) \
|
|
|
|
--root $(ROOT) \
|
|
|
|
--data-dir "$(1)" \
|
|
|
|
--prefix "$(2)" \
|
|
|
|
--output "$@" \
|
|
|
|
$<
|
2020-07-24 09:20:10 -04:00
|
|
|
endef
|
|
|
|
|
|
|
|
# args:
|
2020-08-03 20:25:59 -04:00
|
|
|
# 1. index file
|
|
|
|
# 2. gallery prefix
|
|
|
|
# 3. data dir
|
|
|
|
# 4. other flags
|
2020-07-24 09:20:10 -04:00
|
|
|
define rss
|
|
|
|
echo "[rss] "$@
|
|
|
|
mkdir -p "$(dir $@)"
|
2021-03-07 14:49:25 -05:00
|
|
|
$(MAKEPAGES) $(MPFLAGS) rss $(4) \
|
|
|
|
--index "$(1)" \
|
|
|
|
--root "$(ROOT)" \
|
|
|
|
--prefix "$(2)" \
|
|
|
|
--data-dir "$(3)" \
|
|
|
|
--output "$@" \
|
2020-07-24 09:20:10 -04:00
|
|
|
$(filter $(DATADIR)/%/$(INFONAME),$^)
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
# never delete intermediate files
|
|
|
|
.SECONDARY:
|
|
|
|
|
2020-07-16 10:07:28 -04:00
|
|
|
.SILENT:
|