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
2020-12-24 01:02:43 +00:00
.PHONY : hugo
2022-05-11 17:09:58 +00:00
hugo : $( SRCFILES )
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)
.PHONY : lint -html
2022-05-11 17:09:58 +00:00
lint-html :
$( VNU) --stdout --format json --skip-non-html --also-check-svg $( OUTPUT_DIR) | jq --from-file linter-configs/vnu_filter.jq
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-05-11 17:01:22 +00:00
lint-local : lint -css lint -html
2020-12-24 01:02:43 +00:00
# dev server
.PHONY : serve
serve :
2021-01-27 21:35:39 +00:00
hugo serve --disableLiveReload $( HUGO_FLAGS)
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-11 17:09:58 +00:00
gz :
2021-07-03 04:01:14 +00:00
find $( OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.webmanifest' -o -name '*.*.svg' \
2020-12-13 05:04:01 +00:00
| grep -v gemini \
2021-06-12 22:22:11 +00:00
| xargs ect -$( ECT_LEVEL) -gzip
2022-05-11 17:09:58 +00:00
brotli :
2021-07-03 04:01:14 +00:00
find $( OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.webmanifest' -o -name '*.*.svg' \
2020-12-31 07:43:29 +00:00
| grep -v gemini \
2021-06-12 22:22:11 +00:00
| xargs brotli -q 11 --
2022-05-11 17:09:58 +00:00
compress : gz brotli
.PHONY : compress gz brotli
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 :
2021-01-10 04:48:42 +00:00
rsync $( RSYNCFLAGS) --exclude '*.html' --exclude '*.xml' --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
## stuff for the staging server
.PHONY : test -staging
2021-01-11 06:12:04 +00:00
test-staging : deploy -html
2020-12-24 01:12:40 +00:00
yq e '.ci .collect .url | .[]' .lighthouserc.yml | xargs npx hint -f codeframe
npx lhci autorun
2020-12-13 05:04:01 +00:00
2020-12-24 01:02:43 +00:00
.PHONY : all
all : test deploy
2022-05-11 17:09:58 +00:00
.PHONY : deploy -envs
deploy-envs :
@$( MAKE) NO_STATIC = 1 HUGO_FLAGS = '--gc' 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 hugo
2022-05-13 00:33:12 +00:00
@$( MAKE) NO_STATIC = 1 HUGO_FLAGS = '--gc' 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 deploy
2022-05-11 17:09:58 +00:00
.PHONY : deploy -prod
deploy-prod :
@$( MAKE) clean
@$( MAKE) hugo
@$( MAKE) compress
@$( MAKE) deploy
2022-05-13 00:33:12 +00:00
# linting and compression can happen in parallel
2022-05-11 17:09:58 +00:00
.PHONY : deploy -staging
deploy-staging :
2022-05-30 22:49:31 +00:00
@$( MAKE) HUGO_FLAGS = '--gc' DOMAIN = staging.seirdy.one USER = deploy@seirdy.one OUTPUT_DIR = public_staging clean
@$( MAKE) HUGO_FLAGS = '--gc' DOMAIN = staging.seirdy.one USER = deploy@seirdy.one OUTPUT_DIR = public_staging hugo
@$( MAKE) HUGO_FLAGS = '--gc' DOMAIN = staging.seirdy.one USER = deploy@seirdy.one OUTPUT_DIR = public_staging compress
@$( MAKE) HUGO_FLAGS = '--gc' DOMAIN = staging.seirdy.one USER = deploy@seirdy.one OUTPUT_DIR = public_staging deploy
2022-05-11 17:09:58 +00:00
.PHONY : deploy -onion
deploy-onion :
@$( MAKE) WWW_ROOT = /var/www/seirdy.onion HUGO_BASEURL = 'http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR = public_onion clean
@$( MAKE) WWW_ROOT = /var/www/seirdy.onion HUGO_BASEURL = 'http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR = public_onion hugo
@$( MAKE) WWW_ROOT = /var/www/seirdy.onion HUGO_BASEURL = 'http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR = public_onion compress
@$( MAKE) WWW_ROOT = /var/www/seirdy.onion HUGO_BASEURL = 'http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR = public_onion deploy-html