2021-01-18 04:13:38 +00:00
|
|
|
CSS_DIR = assets/css
|
2022-05-11 17:09:58 +00:00
|
|
|
SRCFILES = layouts/**/*.html layouts/**/*.xml content/**/*.md $(CSS_DIR)/*.css static/*.svg assets/*.svg config.toml csv/*
|
2020-12-24 01:02:43 +00:00
|
|
|
DEVSERVER_URL="http://localhost:1313/"
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
DOMAIN = seirdy.one
|
|
|
|
HUGO_BASEURL = "https://$(DOMAIN)/"
|
2022-04-25 15:49:13 +00:00
|
|
|
HUGO_FLAGS = --gc --ignoreCache
|
2020-12-24 01:02:43 +00:00
|
|
|
USER = deploy@$(DOMAIN)
|
|
|
|
WWW_ROOT = /var/www/$(DOMAIN)
|
|
|
|
GEMINI_ROOT = /srv/gemini/$(DOMAIN)
|
2020-12-13 05:04:01 +00:00
|
|
|
|
|
|
|
WWW_RSYNC_DEST = $(USER):$(WWW_ROOT)
|
|
|
|
GEMINI_RSYNC_DEST = $(USER):$(GEMINI_ROOT)
|
|
|
|
|
2020-12-15 06:12:06 +00:00
|
|
|
OUTPUT_DIR = public
|
2022-05-11 17:09:58 +00:00
|
|
|
RSYNCFLAGS += -rlcv --zc=zstd --zl=6 --skip-compress=gz/br/zst/png/webp/jpg/avif/jxl/mp4/mkv/webm/opus/mp3
|
2022-03-28 21:56:49 +00:00
|
|
|
# compression gets slow for extreme levels like the old "70109"
|
|
|
|
ECT_LEVEL=9
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2022-05-11 17:01:22 +00:00
|
|
|
VNU ?= vnu
|
|
|
|
|
2022-06-07 16:39:32 +00:00
|
|
|
csv/webrings.csv:
|
|
|
|
sh scripts/populate-webrings.sh
|
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: hugo
|
2022-06-07 16:39:32 +00:00
|
|
|
hugo: csv/webrings.csv $(SRCFILES)
|
2022-05-11 17:09:58 +00:00
|
|
|
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS) -d $(OUTPUT_DIR)
|
2020-12-22 00:38:26 +00:00
|
|
|
|
2020-12-13 05:04:01 +00:00
|
|
|
# .hintrc-local for linting local files
|
|
|
|
# same as regular .hintrc but with a different connector.
|
|
|
|
.hintrc-local: .hintrc
|
2022-05-11 17:01:22 +00:00
|
|
|
jq --tab '.connector .name = "local" | del(.connector .options)' <linter-configs/hintrc >.hintrc-local
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.hintrc-devserver: .hintrc
|
2022-05-11 17:01:22 +00:00
|
|
|
jq --tab '.extends = ["development"] | .hints["http-compression","https-only","ssllabs","sri"] = "off"' <linter-configs/hintrc >.hintrc-devserver
|
2020-12-24 01:02:43 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
2020-12-13 05:04:01 +00:00
|
|
|
clean:
|
2021-01-10 04:48:42 +00:00
|
|
|
rm -rf $(OUTPUT_DIR) .lighthouseci lighthouse-reports mentions.json
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: lint-css
|
2022-05-11 17:09:58 +00:00
|
|
|
lint-css: $(CSS_DIR)/*.css
|
|
|
|
pnpm -s dlx stylelint --config linter-configs/stylelintrc.json --di --rd --rdd $(CSS_DIR)/*.css
|
2022-05-11 17:01:22 +00:00
|
|
|
@#csslint --quiet $(CSS_DIR)
|
|
|
|
|
2022-06-03 00:17:19 +00:00
|
|
|
.PHONY: lint-html
|
|
|
|
lint-html:
|
2022-06-03 00:18:13 +00:00
|
|
|
$(VNU) --stdout --format json --skip-non-html --also-check-svg $(OUTPUT_DIR) | sh scripts/filter-vnu.sh
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: hint
|
|
|
|
hint: hugo .hintrc-local
|
2020-12-13 05:04:01 +00:00
|
|
|
hint --config .hintrc-local -f codeframe $(OUTPUT_DIR)
|
2020-12-24 01:02:43 +00:00
|
|
|
rm .hintrc-local
|
|
|
|
|
|
|
|
.PHONY: lint-local
|
2022-06-03 00:17:19 +00:00
|
|
|
lint-local: lint-css lint-html
|
2020-12-24 01:02:43 +00:00
|
|
|
|
2022-05-30 23:09:40 +00:00
|
|
|
# dev server, includes future and draft posts
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: serve
|
|
|
|
serve:
|
2022-05-30 23:09:40 +00:00
|
|
|
hugo serve --disableLiveReload $(HUGO_FLAGS) -FwDb http://localhost:1313/
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: hint-devserver
|
|
|
|
hint-devserver: .hintrc-devserver
|
|
|
|
hint --config .hintrc-devserver -f codeframe $(DEVSERVER_URL)
|
|
|
|
rm .hintrc-devserver
|
|
|
|
|
|
|
|
.PHONY: check-links
|
2020-12-16 07:16:01 +00:00
|
|
|
check-links: hugo
|
2020-12-22 00:38:26 +00:00
|
|
|
lychee --verbose $(find public -type f -name '*.html' -o -name '*.gmi' -o -name '*.txt') content/posts/*.md content/posts/*.gmi
|
2020-12-15 06:12:06 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: lint-css hint-devserver check-links
|
2020-12-15 06:12:06 +00:00
|
|
|
|
2022-05-30 23:09:40 +00:00
|
|
|
gzip:
|
|
|
|
sh scripts/compress.sh $(OUTPUT_DIR) gzip $(ECT_LEVEL)
|
2022-05-11 17:09:58 +00:00
|
|
|
brotli:
|
2022-05-30 23:09:40 +00:00
|
|
|
sh scripts/compress.sh $(OUTPUT_DIR) brotli
|
|
|
|
compress: gzip brotli
|
|
|
|
.PHONY: gzip brotli compress
|
2022-05-11 17:09:58 +00:00
|
|
|
|
2022-05-30 23:09:40 +00:00
|
|
|
.PHONY: xhtmlize
|
|
|
|
xhtmlize:
|
|
|
|
sh scripts/xhtmlize.sh $(OUTPUT_DIR)
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2021-01-10 04:48:42 +00:00
|
|
|
# save webmentions to a file, don't send yet
|
|
|
|
mentions.json: hugo
|
|
|
|
# gather old version of the site
|
|
|
|
# rsync $(RSYNCFLAGS) --exclude '*.gz' --exclude '*.br' --exclude '*.png' --exclude-from .rsyncignore $(WWW_RSYNC_DEST)/ old
|
2022-05-11 17:01:22 +00:00
|
|
|
static-webmentions -f mentions.json.unfiltered find
|
2021-01-10 04:48:42 +00:00
|
|
|
# filter the webmentions a bit; jq offers more flexibility than config.toml
|
2021-02-23 05:10:10 +00:00
|
|
|
jq '[ .[] | select(.Dest|test("https://(git.sr.ht/~seirdy/seirdy.one/log/master|seirdy.one|web.archive.org|archive.is|en.wikipedia.org|matrix.to|([a-z]*.)?reddit.com|github.com)") | not) ]' <mentions.json.unfiltered >mentions.json
|
2021-01-10 04:48:42 +00:00
|
|
|
rm mentions.json.unfiltered
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: deploy-html
|
2022-05-11 17:09:58 +00:00
|
|
|
deploy-html:
|
2020-12-13 06:07:00 +00:00
|
|
|
rsync $(RSYNCFLAGS) --exclude 'gemini' --exclude '*.gmi' --exclude-from .rsyncignore $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST) --delete
|
2020-12-24 01:02:43 +00:00
|
|
|
|
|
|
|
.PHONY: deploy-gemini
|
2022-05-11 17:09:58 +00:00
|
|
|
deploy-gemini:
|
2022-05-30 23:09:40 +00:00
|
|
|
rsync $(RSYNCFLAGS) --exclude '*.html' --exclude '*.xml' --exclude '*.xhtml' --exclude '*.gz' --exclude '*.br' --exclude-from .rsyncignore $(OUTPUT_DIR)/gemini/ $(OUTPUT_DIR)/about $(OUTPUT_DIR)/posts $(OUTPUT_DIR)/publickey.* $(GEMINI_RSYNC_DEST)/ --delete
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: deploy
|
2021-12-13 23:32:58 +00:00
|
|
|
deploy: deploy-html deploy-gemini
|
2020-12-24 01:02:43 +00:00
|
|
|
|
2022-05-30 23:09:40 +00:00
|
|
|
.PHONY: .prepare-deploy
|
|
|
|
.prepare-deploy:
|
2022-05-11 17:09:58 +00:00
|
|
|
@$(MAKE) clean
|
|
|
|
@$(MAKE) hugo
|
2022-05-30 23:09:40 +00:00
|
|
|
@$(MAKE) xhtmlize
|
|
|
|
|
|
|
|
# deploy steps need to happen one at a time
|
|
|
|
.PHONY: deploy-prod
|
|
|
|
deploy-prod: .prepare-deploy
|
2022-06-03 00:17:19 +00:00
|
|
|
@$(MAKE) compress
|
2022-05-11 17:09:58 +00:00
|
|
|
@$(MAKE) deploy
|
|
|
|
|
2022-05-30 23:09:40 +00:00
|
|
|
.PHONY: deploy-onion
|
|
|
|
deploy-onion:
|
|
|
|
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion deploy-prod
|
2022-05-11 17:09:58 +00:00
|
|
|
|
2022-05-30 23:09:40 +00:00
|
|
|
# we only deploy html to the staging site
|
2022-05-11 17:09:58 +00:00
|
|
|
.PHONY: deploy-staging
|
|
|
|
deploy-staging:
|
2022-06-03 22:49:11 +00:00
|
|
|
@$(MAKE) DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging .prepare-deploy
|
|
|
|
@$(MAKE) DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging compress
|
|
|
|
@$(MAKE) DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging deploy-html
|
2022-05-30 23:09:40 +00:00
|
|
|
|
|
|
|
.PHONY: lint-and-deploy-staging
|
|
|
|
lint-and-deploy-staging:
|
2022-06-03 00:17:19 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging .prepare-deploy
|
|
|
|
@$(MAKE) HUGO_FLAGS='' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging compress lint-local
|
|
|
|
@$(MAKE) HUGO_FLAGS='' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging deploy-html
|
2022-05-30 23:09:40 +00:00
|
|
|
|
|
|
|
.PHONY: deploy-envs
|
|
|
|
deploy-envs:
|
2022-06-03 00:17:19 +00:00
|
|
|
@$(MAKE) NO_STATIC=1 HUGO_FLAGS='' USER=seirdy@envs.net WWW_ROOT=/home/seirdy/public_html GEMINI_ROOT=/home/seirdy/public_gemini HUGO_BASEURL='https://envs.net/~seirdy/' OUTPUT_DIR=public_envs .prepare-deploy
|
|
|
|
@$(MAKE) NO_STATIC=1 HUGO_FLAGS='' USER=seirdy@envs.net WWW_ROOT=/home/seirdy/public_html GEMINI_ROOT=/home/seirdy/public_gemini HUGO_BASEURL='https://envs.net/~seirdy/' OUTPUT_DIR=public_envs lint-local
|
|
|
|
@$(MAKE) NO_STATIC=1 HUGO_FLAGS='' USER=seirdy@envs.net WWW_ROOT=/home/seirdy/public_html GEMINI_ROOT=/home/seirdy/public_gemini HUGO_BASEURL='https://envs.net/~seirdy/' OUTPUT_DIR=public_envs deploy
|