2021-01-18 04:13:38 +00:00
|
|
|
CSS_DIR = assets/css
|
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)/"
|
2021-01-12 23:28:59 +00:00
|
|
|
HUGO_FLAGS += --gc
|
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
|
2020-12-13 05:16:40 +00:00
|
|
|
RSYNCFLAGS += -rlvz --zc=zstd
|
2020-12-29 17:47:45 +00:00
|
|
|
ZOPFLI_ITERATIONS=500 # max compression
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: hugo
|
|
|
|
hugo: clean
|
2021-01-12 23:28:59 +00:00
|
|
|
hugo --gc -b $(HUGO_BASEURL) $(HUGO_FLAGS)
|
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
|
|
|
|
jq --tab '.connector .name = "local" | del(.connector .options)' <.hintrc >.hintrc-local
|
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.hintrc-devserver: .hintrc
|
|
|
|
jq --tab '.extends = ["development"] | .hints["http-compression","https-only","ssllabs","sri"] = "off"' <.hintrc >.hintrc-devserver
|
|
|
|
|
|
|
|
.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
|
2020-12-13 05:04:01 +00:00
|
|
|
lint-css:
|
2020-12-24 01:02:43 +00:00
|
|
|
stylelint --di --rd --rdd $(CSS_DIR)/main.css $(CSS_DIR)/dark.css
|
|
|
|
csslint --quiet $(CSS_DIR)
|
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
|
|
|
|
lint-local: lint-css hint
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: build
|
2020-12-13 05:04:01 +00:00
|
|
|
build: hugo
|
2020-12-13 06:07:00 +00:00
|
|
|
# gzip_static + max zopfli compression
|
2020-12-31 07:43:29 +00:00
|
|
|
ifndef NO_STATIC
|
2021-01-03 17:01:12 +00:00
|
|
|
find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.txt' -o -name '*.asc' -o -name '*.webmanifest' -o -name "*.svg" \
|
2020-12-13 05:04:01 +00:00
|
|
|
| grep -v gemini \
|
2020-12-27 04:43:48 +00:00
|
|
|
| xargs zopfli --i$(ZOPFLI_ITERATIONS) --gzip
|
2021-01-03 17:01:12 +00:00
|
|
|
find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.txt' -o -name '*.asc' -o -name '*.webmanifest' -o -name "*.svg" \
|
2020-12-31 07:43:29 +00:00
|
|
|
| grep -v gemini \
|
|
|
|
| xargs brotli -q 11
|
2020-12-13 05:04:01 +00:00
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
static-webmentions find
|
|
|
|
mv mentions.json mentions.json.unfiltered
|
|
|
|
# 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
|
2021-01-10 04:48:42 +00:00
|
|
|
deploy-html: build mentions.json
|
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
|
|
|
|
deploy-gemini: hugo
|
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 06:07:00 +00:00
|
|
|
rsync $(RSYNCFLAGS) $(OUTPUT_DIR)/posts/gemini.xml $(GEMINI_RSYNC_DEST)/feed.xml
|
2020-12-13 05:04:01 +00:00
|
|
|
|
2020-12-24 01:02:43 +00:00
|
|
|
.PHONY: deploy
|
|
|
|
deploy: deploy-html deploy-gemini
|
|
|
|
|
|
|
|
## 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
|