From 4d7625227b6f231b79b0f7213a3b8deb955463ed Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Sat, 9 Jan 2021 20:48:42 -0800 Subject: [PATCH] IndieWeb: gather WebWentions with static-webmention Update the Makefile to download the old version of the site, run static-webmentions, and collect the WebMentions to send in a json file saved as a build artifact. Don't send these automatically; just save them for now. Until I work out a solution to save sent WebMentions and avoid sending duplicates, I'll keep the sending of WebMentions manual. For some reason this caused webhint's axe/aria test to error out with a "Protocol error" so I disabled it. Axe tests are covered by Lighthouse anyway. --- .build.yml | 3 +++ .gitignore | 10 ++++++---- .hintrc | 1 + .rsyncignore | 6 +++--- Makefile | 17 +++++++++++++---- README.md | 3 +++ config.toml | 22 ++++++++++++++++++++++ 7 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.build.yml b/.build.yml index ad34393..f03feca 100644 --- a/.build.yml +++ b/.build.yml @@ -6,6 +6,7 @@ packages: - brotli # for max compression w/ brotli_static, decompressing binaries - git # for Hugo's gitInfo - make + - jq - npm # for testing with lighthouse and webhint - chromium # for testing with lighthouse and webhint environment: @@ -33,5 +34,7 @@ tasks: make DOMAIN=staging.seirdy.one ZOPFLI_ITERATIONS=50 test-staging tar czf ~/lighthouse-reports.tar.gz lighthouse-reports make clean deploy + cp mentions.json ~/mentions.json artifacts: - lighthouse-reports.tar.gz + - mentions.json diff --git a/.gitignore b/.gitignore index d07a591..100c2be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -public/ -public_*/ -hint-report/ -.hintrc-* *.report.html *.report.json +.hintrc-* .lighthouseci/* +hint-report/ lighthouse-reports/* +mentions.json node_modules/* +old/ +public/ +public_*/ diff --git a/.hintrc b/.hintrc index 1380d3e..3866600 100644 --- a/.hintrc +++ b/.hintrc @@ -14,6 +14,7 @@ ], "hints": { "apple-touch-icons": "off", + "axe/aria": "off", "axe/other": "error", "compat-api/css": [ "error", diff --git a/.rsyncignore b/.rsyncignore index 8b3d00d..fdbabc8 100644 --- a/.rsyncignore +++ b/.rsyncignore @@ -1,6 +1,6 @@ +.well-known/ +_* misc/ music.txt music.txt.gz -.well-known -_* -webmentions +webmentions/ diff --git a/Makefile b/Makefile index a2c7e0a..98dfa37 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ hugo: clean .PHONY: clean clean: - rm -rf $(OUTPUT_DIR) .lighthouseci lighthouse-reports + rm -rf $(OUTPUT_DIR) .lighthouseci lighthouse-reports mentions.json .PHONY: lint-css lint-css: @@ -72,14 +72,23 @@ ifndef NO_STATIC | xargs brotli -q 11 endif +# 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 + jq '[ .[] | select(.Dest|test("https://(git.sr.ht/~seirdy/seirdy.one/log/master|seirdy.one|web.archive.org|matrix.to)") | not) ]' mentions.json + rm mentions.json.unfiltered .PHONY: deploy-html -deploy-html: build +deploy-html: build mentions.json rsync $(RSYNCFLAGS) --exclude 'gemini' --exclude '*.gmi' --exclude-from .rsyncignore $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST) --delete .PHONY: deploy-gemini deploy-gemini: hugo - rsync $(RSYNCFLAGS) --exclude '*.html' --exclude '*.xml' --exclude '*.gz' --exclude-from .rsyncignore $(OUTPUT_DIR)/gemini/ $(OUTPUT_DIR)/about $(OUTPUT_DIR)/posts $(OUTPUT_DIR)/publickey.* $(GEMINI_RSYNC_DEST)/ --delete + 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 rsync $(RSYNCFLAGS) $(OUTPUT_DIR)/posts/gemini.xml $(GEMINI_RSYNC_DEST)/feed.xml .PHONY: deploy @@ -87,7 +96,7 @@ deploy: deploy-html deploy-gemini ## stuff for the staging server .PHONY: test-staging -test-staging: deploy-html +test-staging: yq e '.ci .collect .url | .[]' .lighthouserc.yml | xargs npx hint -f codeframe npx lhci autorun diff --git a/README.md b/README.md index 28da9e8..b7379d1 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,7 @@ To test in CI, after deploying to the staging environment: - webhint CLI - [lighthouse-ci](https://github.com/GoogleChrome/lighthouse-ci) +CI also runs [static-webmention](https://github.com/nekr0z/static-webmentions) to +gather a list of WebMentions for me to send and review manually. + See the `Makefile` for details. The CI saves lighthouse reports as a build artifact. diff --git a/config.toml b/config.toml index 07474af..dfac2b1 100644 --- a/config.toml +++ b/config.toml @@ -78,6 +78,28 @@ path = "gemini/" [outputs] section = ["HTML", "RSS", "GEMRSS"] +# https://github.com/nekr0z/static-webmentions +[webmentions] +newDir = "public" +oldDir = "old" +webmentionsFile = "mentions.json" +excludeSources = [ + "/tags/*", # only trailing * are supported at the moment + "/posts/*", # this only excludes /posts/index.html, not /posts/somepost/ + "/", # same as "/index.html" +] + +# addresses that we don't want to send webmentions to +# other schemes and stuff that's I link to too often +excludeDestinations = [ + "mailto:", + "gemini:", + "https://web.archive.org", + "https://lists.sr.ht/~seirdy/seirdy.one-comments", + "https://useplaintext.email/", + "https://seirdy.one", +] + [server] [[server.headers]] for = "/**.{css,png,webp,webm}"