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)/"
|
|
|
|
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
|
2024-06-20 20:08:33 +00:00
|
|
|
SSHFLAGS = -o KexAlgorithms=sntrup761x25519-sha512@openssh.com -o VerifyHostKeyDNS=yes
|
|
|
|
SKIP_COMPRESS=gz/br/zst/png/webp/jpg/avif/jxl/mp4/mkv/webm/opus/mp3/gif/ico
|
|
|
|
RSYNCFLAGS += -rlpcv --zc=zstd --zl=6 --skip-compress=$(SKIP_COMPRESS) -e "ssh $(SSHFLAGS)" --chmod=D755,F644
|
2022-08-06 05:49:18 +00:00
|
|
|
RSYNCFLAGS_EXTRA ?=
|
2023-08-27 21:26:33 +00:00
|
|
|
# compression gets slow for extreme levels like the old "70109".
|
|
|
|
# Diminishing returns after level 6; sometimes even larger files.
|
|
|
|
ECT_LEVEL=6
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2022-06-07 16:39:32 +00:00
|
|
|
csv/webrings.csv:
|
|
|
|
sh scripts/populate-webrings.sh
|
|
|
|
|
2023-11-29 08:33:06 +00:00
|
|
|
data/bookmarks.json:
|
|
|
|
sh scripts/get-bookmarks.sh
|
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: hugo
|
2023-11-29 08:33:06 +00:00
|
|
|
hugo: csv/webrings.csv data/bookmarks.json $(SRCFILES)
|
2022-12-24 17:38:30 +00:00
|
|
|
sh scripts/get-webmentions.sh
|
2022-05-11 17:09:58 +00:00
|
|
|
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS) -d $(OUTPUT_DIR)
|
2024-03-25 05:56:06 +00:00
|
|
|
find "$(OUTPUT_DIR)/about/_index.gmi" && mv $(OUTPUT_DIR)/about/_index.gmi $(OUTPUT_DIR)/about/index.gmi || echo
|
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
|
2023-08-27 21:26:33 +00:00
|
|
|
jaq --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
|
2023-08-27 21:26:33 +00:00
|
|
|
jaq --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:
|
2023-11-29 08:33:06 +00:00
|
|
|
rm -rf $(OUTPUT_DIR) .lighthouseci lighthouse-reports data/webmentions.json csv/webrings.csv data/bookmarks.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-07-18 03:01:54 +00:00
|
|
|
# IBM Equal Access Accessibility Checker can't handle content-visibility,
|
|
|
|
# so run it on a special version of the site without content-visibility.
|
|
|
|
.PHONY: equal-access
|
|
|
|
equal-access:
|
|
|
|
cp -r $(OUTPUT_DIR) $(OUTPUT_DIR).eac
|
|
|
|
find $(OUTPUT_DIR).eac -type f -name "*.html" | xargs -n1 sd 'content-visibility:auto;' ''
|
2023-11-10 18:43:09 +00:00
|
|
|
pnpm --package accessibility-checker dlx achecker $(OUTPUT_DIR).eac/
|
2022-07-18 03:01:54 +00:00
|
|
|
rm -rf $(OUTPUT_DIR).eac
|
|
|
|
|
2022-06-16 02:43:01 +00:00
|
|
|
.PHONY: validate-json
|
|
|
|
validate-json:
|
2024-01-31 00:57:31 +00:00
|
|
|
jaq -re '""' $(OUTPUT_DIR)/manifest.*.webmanifest 1>/dev/null
|
2023-08-27 21:26:33 +00:00
|
|
|
jaq -re '""' $(OUTPUT_DIR)/webfinger.json 1>/dev/null
|
2022-06-16 02:43:01 +00:00
|
|
|
|
|
|
|
.PHONY: validate-html
|
|
|
|
validate-html:
|
2022-08-13 21:05:16 +00:00
|
|
|
sh scripts/vnu.sh $(OUTPUT_DIR)
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2022-06-18 03:36:35 +00:00
|
|
|
.PHONY: htmlproofer
|
|
|
|
htmlproofer:
|
2023-04-24 16:53:36 +00:00
|
|
|
htmlproofer $(OUTPUT_DIR) --disable-external --checks Images,Scripts,Favicon,OpenGraph --ignore-files $(OUTPUT_DIR)/search/index.html --ignore-urls '../music.txt'
|
2022-06-18 03:36:35 +00:00
|
|
|
|
2024-05-28 04:58:36 +00:00
|
|
|
linter-configs/htmltest/refcache.json:
|
2022-08-06 05:49:18 +00:00
|
|
|
rsync $(RSYNCFLAGS) $(RSYNCFLAGS_EXTRA) deploy@seirdy.one:/home/deploy/refcache.json linter-configs/htmltest/refcache.json
|
2022-06-30 01:15:28 +00:00
|
|
|
|
2022-06-18 05:09:32 +00:00
|
|
|
# basic checks for generated HTML and broken links. Persist the broken
|
|
|
|
# link cache remotely so we can run this in CI.
|
2022-06-18 03:36:35 +00:00
|
|
|
.PHONY: htmltest
|
2024-05-28 04:58:36 +00:00
|
|
|
htmltest: linter-configs/htmltest/refcache.json
|
2022-06-18 03:36:35 +00:00
|
|
|
htmltest -c linter-configs/htmltest.yml $(OUTPUT_DIR)
|
2022-08-06 05:49:18 +00:00
|
|
|
rsync $(RSYNCFLAGS) $(RSYNCFLAGS_EXTRA) linter-configs/htmltest/refcache.json deploy@seirdy.one:/home/deploy/refcache.json
|
2022-06-18 03:36:35 +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
|
|
|
|
|
2023-10-20 11:06:36 +00:00
|
|
|
.PHONY: html-validate
|
|
|
|
html-validate:
|
2023-11-26 22:57:56 +00:00
|
|
|
find $(OUTPUT_DIR) -type f -name "*.html" | grep -v 'resume/index.html' | xargs pnpm -s dlx html-validate --ext=html -c linter-configs/htmlvalidate.json
|
2023-10-20 11:06:36 +00:00
|
|
|
|
2023-11-17 23:25:31 +00:00
|
|
|
.validate-feed-main:
|
|
|
|
scripts/bin/validate-feed file://$(PWD)/$(OUTPUT_DIR)/atom.xml
|
|
|
|
.validate-feed-posts:
|
|
|
|
scripts/bin/validate-feed file://$(PWD)/$(OUTPUT_DIR)/posts/atom.xml
|
|
|
|
.validate-feed-notes:
|
|
|
|
scripts/bin/validate-feed file://$(PWD)/$(OUTPUT_DIR)/notes/atom.xml
|
|
|
|
validate-feeds: .validate-feed-main .validate-feed-posts .validate-feed-notes
|
2024-07-14 05:19:03 +00:00
|
|
|
|
|
|
|
fflint: hugo
|
|
|
|
sh scripts/fflint.sh $(OUTPUT_DIR)
|
|
|
|
|
|
|
|
.PHONY: validate-feeds .validate-feed-main .validate-feed-posts .validate-feed-notes fflint
|
2023-11-17 23:25:31 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: lint-local
|
2024-07-14 05:19:03 +00:00
|
|
|
lint-local: fflint htmlproofer validate-feeds validate-json html-validate validate-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
|
2023-11-29 08:33:06 +00:00
|
|
|
xhtmlize: hugo
|
2022-05-30 23:09:40 +00:00
|
|
|
sh scripts/xhtmlize.sh $(OUTPUT_DIR)
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2024-03-25 05:56:06 +00:00
|
|
|
.PHONY: quick-build
|
|
|
|
|
2022-08-11 04:30:22 +00:00
|
|
|
.PHONY: copy-to-xhtml
|
2023-11-29 13:16:48 +00:00
|
|
|
copy-to-xhtml:
|
2023-11-26 23:12:35 +00:00
|
|
|
find $(OUTPUT_DIR) -type f -name "*.html" | grep -v 'resume/index.html' | xargs -n1 sh scripts/copy-file-to-xhtml.sh
|
2022-08-11 04:30:22 +00:00
|
|
|
|
2024-06-20 20:08:33 +00:00
|
|
|
# The grep command at the end makes the output much less noisy.
|
|
|
|
# filter out duplicate xhtml files (they're just copies of the .html files)
|
|
|
|
# filter gzip files (their zopfli-like compression is not deterministic)
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: deploy-html
|
2022-05-11 17:09:58 +00:00
|
|
|
deploy-html:
|
2024-06-20 20:08:33 +00:00
|
|
|
rsync $(RSYNCFLAGS) $(RSYNCFLAGS_EXTRA) --exclude 'gemini' --exclude '*.gmi' --exclude-from .rsyncignore $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST) --delete | grep -Ev '\.(gz|xhtml)$$'
|
2020-12-24 01:02:43 +00:00
|
|
|
|
|
|
|
.PHONY: deploy-gemini
|
2022-05-11 17:09:58 +00:00
|
|
|
deploy-gemini:
|
2022-08-06 05:49:18 +00:00
|
|
|
rsync $(RSYNCFLAGS) $(RSYNCFLAGS_EXTRA) --exclude '*.html' --exclude '*.xml' --exclude '*.xhtml' --exclude '*.gz' --exclude '*.br' --exclude-from .rsyncignore $(OUTPUT_DIR)/gemini/ $(OUTPUT_DIR)/about $(OUTPUT_DIR)/posts $(OUTPUT_DIR)/about $(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
|
2023-11-29 13:20:30 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='--gc --ignoreCache' xhtmlize
|
2022-05-30 23:09:40 +00:00
|
|
|
|
|
|
|
# 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-08-11 04:30:22 +00:00
|
|
|
@$(MAKE) copy-to-xhtml
|
2022-05-11 17:09:58 +00:00
|
|
|
@$(MAKE) deploy
|
|
|
|
|
2022-08-13 21:25:49 +00:00
|
|
|
# hidden service doesn't need brotli
|
2022-05-30 23:09:40 +00:00
|
|
|
.PHONY: deploy-onion
|
|
|
|
deploy-onion:
|
2022-06-11 01:41:21 +00:00
|
|
|
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion .prepare-deploy
|
2022-08-13 21:25:49 +00:00
|
|
|
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion gzip
|
2022-08-11 04:30:22 +00:00
|
|
|
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion copy-to-xhtml
|
2022-06-11 01:41:21 +00:00
|
|
|
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion deploy-html
|
2022-05-11 17:09:58 +00:00
|
|
|
|
2023-11-24 20:58:45 +00:00
|
|
|
# in CI, check connectivity and then build + deploy the clearnet and onion sites.
|
|
|
|
.PHONY: ci
|
|
|
|
ci:
|
|
|
|
sh scripts/connectivity-check.sh
|
|
|
|
@$(MAKE) deploy-prod deploy-onion
|
|
|
|
|
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-11 01:41:21 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS=-DF DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging .prepare-deploy
|
|
|
|
@$(MAKE) HUGO_FLAGS=-DF DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging compress
|
2022-08-11 04:30:22 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS=-DF DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging copy-to-xhtml
|
2022-06-11 01:41:21 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS=-DF 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-11 01:41:21 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='-DF' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging .prepare-deploy
|
|
|
|
@$(MAKE) HUGO_FLAGS='-DF' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging compress lint-local
|
2022-08-11 04:30:22 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='-DF' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging copy-to-xhtml
|
2022-06-11 01:41:21 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='-DF' 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:
|
2023-11-29 13:16:48 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='--gc --ignoreCache' 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 xhtmlize
|
2023-11-29 13:11:00 +00:00
|
|
|
@$(MAKE) HUGO_FLAGS='--gc --ignoreCache' 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 copy-to-xhtml
|
2024-07-14 05:19:03 +00:00
|
|
|
@$(MAKE) 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 fflint validate-json validate-feeds validate-html html-validate
|
2022-09-02 16:29:06 +00:00
|
|
|
@$(MAKE) SSHFLAGS='-o KexAlgorithms=curve25519-sha256@libssh.org' 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
|