1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 21:02:09 +00:00

Compare commits

..

No commits in common. "6a7ac36f110dc03843c801f29d184587cd906e61" and "1aed7a66d4a1a3d768f644ab61d799a578ad8eca" have entirely different histories.

14 changed files with 61 additions and 176 deletions

View file

@ -52,10 +52,10 @@ hint: hugo .hintrc-local
.PHONY: lint-local .PHONY: lint-local
lint-local: lint-css lint-html lint-local: lint-css lint-html
# dev server, includes future and draft posts # dev server
.PHONY: serve .PHONY: serve
serve: serve:
hugo serve --disableLiveReload $(HUGO_FLAGS) -FwDb http://localhost:1313/ hugo serve --disableLiveReload $(HUGO_FLAGS)
.PHONY: hint-devserver .PHONY: hint-devserver
hint-devserver: .hintrc-devserver hint-devserver: .hintrc-devserver
@ -69,16 +69,19 @@ check-links: hugo
.PHONY: test .PHONY: test
test: lint-css hint-devserver check-links test: lint-css hint-devserver check-links
gzip: gz:
sh scripts/compress.sh $(OUTPUT_DIR) gzip $(ECT_LEVEL) find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.webmanifest' -o -name '*.*.svg' \
brotli: | grep -v gemini \
sh scripts/compress.sh $(OUTPUT_DIR) brotli | xargs ect -$(ECT_LEVEL) -gzip
compress: gzip brotli
.PHONY: gzip brotli compress
.PHONY: xhtmlize brotli:
xhtmlize: find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.webmanifest' -o -name '*.*.svg' \
sh scripts/xhtmlize.sh $(OUTPUT_DIR) | grep -v gemini \
| xargs brotli -q 11 --
compress: gz brotli
.PHONY: compress gz brotli
# save webmentions to a file, don't send yet # save webmentions to a file, don't send yet
mentions.json: hugo mentions.json: hugo
@ -95,47 +98,44 @@ deploy-html:
.PHONY: deploy-gemini .PHONY: deploy-gemini
deploy-gemini: deploy-gemini:
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 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
.PHONY: deploy .PHONY: deploy
deploy: deploy-html deploy-gemini deploy: deploy-html deploy-gemini
.PHONY: .prepare-deploy ## stuff for the staging server
.prepare-deploy: .PHONY: test-staging
@$(MAKE) clean test-staging: deploy-html
@$(MAKE) hugo yq e '.ci .collect .url | .[]' .lighthouserc.yml | xargs npx hint -f codeframe
@$(MAKE) xhtmlize npx lhci autorun
@$(MAKE) compress
# deploy steps need to happen one at a time .PHONY: all
.PHONY: deploy-prod all: test deploy
deploy-prod: .prepare-deploy
@$(MAKE) deploy
.PHONY: deploy-onion
deploy-onion:
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion deploy-prod
# we only deploy html to the staging site
.PHONY: deploy-staging
deploy-staging:
@$(MAKE) HUGO_FLAGS='--gc' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging .prepare-deploy
@$(MAKE) HUGO_FLAGS='--gc' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging deploy-html
# we can lint and compress in parallel if cores are available
.PHONY: .lint-and-prepare-deploy
.lint-and-prepare-deploy:
@$(MAKE) clean
@$(MAKE) hugo
@$(MAKE) xhtmlize
@$(MAKE) lint-local compress
.PHONY: lint-and-deploy-staging
lint-and-deploy-staging:
@$(MAKE) HUGO_FLAGS='--gc' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging .lint-and-prepare-deploy
@$(MAKE) HUGO_FLAGS='--gc' DOMAIN=staging.seirdy.one USER=deploy@seirdy.one OUTPUT_DIR=public_staging deploy-html
.PHONY: deploy-envs .PHONY: deploy-envs
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 .lint-and-prepare-deploy @$(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
@$(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 deploy @$(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
.PHONY: deploy-prod
deploy-prod:
@$(MAKE) clean
@$(MAKE) hugo
@$(MAKE) compress
@$(MAKE) deploy
# linting and compression can happen in parallel
.PHONY: deploy-staging
deploy-staging:
@$(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
.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

View file

@ -1,10 +0,0 @@
---
outputs:
- html
url: "/404.html"
title: "Error 404 (Not Found)"
layout: "404"
---
You have requested a page that was not found on this server.
If you are sure you spelled the URL correctly and expected it to work, I or someone else might have made made a mistake. Let me know the URL and how you found it; [here's my contact info](https://seirdy.one/about/#location-seirdy-online).

0
layouts/404.html Normal file
View file

View file

@ -1,80 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{- default "" .Site.LanguageCode }}" xml:lang="{{- default "" .Site.LanguageCode }}" prefix="cc: http://creativecommons.org/ns#">
<head>
<meta charset="UTF-8" />
<meta name="disabled-adaptations" content="watch" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="robots" content="noindex,nofollow" />
<title>{{ .Title }}</title>
{{ if not (in site.BaseURL ".onion") -}}
{{ $icon_svg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" }}
{{- printf `<link rel="icon" sizes="any" href="%s" type="image/svg+xml" />` $icon_svg.RelPermalink | safeHTML }}
{{- end }}
{{ $icon_192 := resources.Get "/apple-touch-icon.png" | resources.Fingerprint "md5" }}
{{- printf `<link rel="icon" sizes="192x192" href="%s" type="image/png" />` $icon_192.RelPermalink | safeHTML -}}
{{ $favicon := resources.Get "/favicon.png" -}}
{{ $favicon_base64 := $favicon.Content | base64Encode }}
{{ printf `<link rel="icon" sizes="32x32" href="data:image/png;base64,%s" type="image/png" />` $favicon_base64 | safeHTML }}
<meta name="color-scheme" content="light dark" />
<meta name="theme-color" content="#111" media="(prefers-color-scheme:dark)" />
<meta name="theme-color" content="#fff" media="(prefers-color-scheme:light)" />
<!-- inline CSS; remember to allow it with a hash in the CSP -->
{{- $resources := slice -}}
{{- $resources = $resources | append (resources.Get "/css/main.css") -}}
{{ $dark := .Site.Params.dark | default "auto" -}}
{{- if not (eq $dark "off") -}}
{{ $resources = $resources | append (resources.Get "css/dark.css" | resources.ExecuteAsTemplate "dark.css" .) -}}
{{- end -}}
{{ $resources = $resources | append (resources.Get "css/print.css" | resources.ExecuteAsTemplate "print.css" .) -}}
{{- $css := $resources | resources.Concat "css/style.css" | minify -}}
<style>{{ $css.Content | safeCSS }}</style>
{{ hugo.Generator }}
</head>
<body>
<header>
<nav aria-label="Global">
<ul>
<li>
<a rel="home" href="https://seirdy.one/">Seirdy&#39;s Home</a>
</li>
<li>
<a href="/posts/">Posts</a>
</li>
<li>
<a href="/notes/">Notes</a>
</li>
<li>
<a href="/bookmarks/">Bookmarks</a>
</li>
<li>
<a href="/about/">About</a>
</li>
</ul>
</nav>
</header>
<main>
<h1>{{ .Title }}</h1>
{{ partial "processed-content.html" . -}}
</main>
<footer>
<nav aria-label="site info">
<ul>
<li>
<a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>
</li>
<li>
<a rel="source" href="{{ .Site.Params.src }}">Source code</a>
</li>
<li>
<a rel="alternate" href="http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion{{ .RelPermalink }}">Tor mirror</a>
</li>
<li>
<a href="{{ site.BaseURL }}privacy/">Privacy</a>
</li>
<li>
<a href="{{ site.BaseURL }}about/#location-seirdy-online">Contact</a>
</li>
</ul>
</nav>
</footer>
</body>
</html>

View file

@ -1,4 +1,4 @@
{{ define "main" -}} {{ define "main" }}
<main itemprop="mainEntity" class="h-feed hfeed" itemscope="" itemtype="https://schema.org/DataFeed"> <main itemprop="mainEntity" class="h-feed hfeed" itemscope="" itemtype="https://schema.org/DataFeed">
<h1 id="bookmarks" class="p-name" itemprop="name headline">My book&#173;marks</h1> <h1 id="bookmarks" class="p-name" itemprop="name headline">My book&#173;marks</h1>
{{ partial "processed-content.html" . }} {{ partial "processed-content.html" . }}

View file

@ -1,4 +1,4 @@
{{ define "main" -}} {{ define "main" }}
{{- if eq .Page.Section "notes" -}} {{- if eq .Page.Section "notes" -}}
{{- partial "notes.html" . -}} {{- partial "notes.html" . -}}
{{- else -}} {{- else -}}

View file

@ -1,4 +1,4 @@
{{ define "main" -}} {{ define "main" }}
<main itemprop="mainEntity" class="h-feed hfeed" itemscope="" itemtype="https://schema.org/DataFeed"> <main itemprop="mainEntity" class="h-feed hfeed" itemscope="" itemtype="https://schema.org/DataFeed">
<h1 class="p-name" itemprop="name headline" id="notes">Notes</h1> <h1 class="p-name" itemprop="name headline" id="notes">Notes</h1>
<p>This is my microblog. These are my short informal entries, sorted by date (newest first). For longer entries, <a href="../posts/">see my blog</a>.</p> <p>This is my microblog. These are my short informal entries, sorted by date (newest first). For longer entries, <a href="../posts/">see my blog</a>.</p>

View file

@ -1,4 +1,4 @@
{{ define "main" -}} {{ define "main" }}
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }} {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<main itemprop="mainEntity" itemscope="" itemtype="https://schema.org/Article" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}"> <main itemprop="mainEntity" itemscope="" itemtype="https://schema.org/Article" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
{{ partial "full-article.html" . }} {{ partial "full-article.html" . }}

View file

@ -1,4 +1,4 @@
{{ define "main" -}} {{ define "main" }}
<main> <main>
{{ partial "processed-content.html" . }} {{ partial "processed-content.html" . }}
{{ partial "posts.html" . }} {{ partial "posts.html" . }}

View file

@ -1,5 +1,5 @@
<head> <head>
<meta charset="UTF-8" /> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }} {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<meta name="disabled-adaptations" content="watch" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <meta name="disabled-adaptations" content="watch" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
{{ if or (eq site.BaseURL site.Params.CanonicalBaseURL) (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}} {{ if or (eq site.BaseURL site.Params.CanonicalBaseURL) (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}}
@ -8,7 +8,7 @@
<link href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" rel="canonical" /> <link href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" rel="canonical" />
<link href="{{ .Site.Params.WebmentionEndpoint }}" rel="webmention" /> <link href="{{ .Site.Params.WebmentionEndpoint }}" rel="webmention" />
{{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}} {{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}}
{{- printf `<link href="%s" rel="manifest" />` $webmanifest.RelPermalink | safeHTML -}} {{- printf `<link href="%s" rel="manifest" />` $webmanifest.RelPermalink | safeHTML }}
<!--Feeds for both notes and posts; posts come first unless we're in the notes section.--> <!--Feeds for both notes and posts; posts come first unless we're in the notes section.-->
{{- $isNotes := false -}} {{- $isNotes := false -}}
{{- if or (eq .Section "notes") (eq .Title "Notes") -}} {{- if or (eq .Section "notes") (eq .Title "Notes") -}}

View file

@ -25,7 +25,7 @@
</li> </li>
{{ range .Site.Menus.main -}} {{ range .Site.Menus.main -}}
{{ $isCurrent := false }} {{ $isCurrent := false }}
<li itemprop="hasPart" itemscope="" itemtype="https://schema.org/SiteNavigationElement"> <li itemProp="hasPart" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
<a href="{{ .URL }}" itemprop="url" {{- if or (eq $currentPage.RelPermalink .URL) ($currentPage.HasMenuCurrent "main" .) -}}{{- $isCurrent = true }} aria-current="page"{{- end -}}> <a href="{{ .URL }}" itemprop="url" {{- if or (eq $currentPage.RelPermalink .URL) ($currentPage.HasMenuCurrent "main" .) -}}{{- $isCurrent = true }} aria-current="page"{{- end -}}>
{{- if or $isCurrent (eq $currentPage.Section .Title) -}} {{- if or $isCurrent (eq $currentPage.Section .Title) -}}
<strong itemprop="name">{{- .Name -}}</strong> <strong itemprop="name">{{- .Name -}}</strong>

View file

@ -11,8 +11,14 @@
or or
( # See https://github.com/validator/validator/issues/1166 ( # See https://github.com/validator/validator/issues/1166
.message == "Attribute “media” not allowed on element “meta” at this point." .message == "Attribute “media” not allowed on element “meta” at this point."
and .firstColumn == 1
and (.extract | test(" name=\"theme-color\"")) and (.extract | test(" name=\"theme-color\""))
) )
or
( # XHTML5 gang
.message == "Bad value “application/xhtml+xml; charset=utf-8” for attribute “content” on element “meta”: The legacy encoding declaration did not start with “text/html;”."
and .firstColumn == 1
)
) | not ) | not
) )
) )

View file

@ -1,20 +0,0 @@
#!/bin/sh
# takes three args:
# 1. output dir
# 2. "gzip" or "brotli"
# 3. ECT zopfli compression level
set -e -u
output_dir="$1"
format="$2"
alias find_compressible='find "$output_dir" -type f \( -name "*.html" -o -name "*.xml" -o -name "*.webmanifest" -o -name "*.*.svg" \)'
if [ "$format" = "gzip" ]; then
compress_level="$3"
find_compressible -exec ect -quiet -"$compress_level" -gzip {} \;
elif [ "$2" = "brotli" ]; then
find_compressible -exec brotli -Z -- {} \;
fi

View file

@ -1,11 +0,0 @@
#!/bin/sh
# takes an arg for the output dir.
# copies every .html file to an equivalent .xhtml file, but replaces
# the meta charset with an XML declaration for compatibility with some
# XML tooling.
# this means that every index.html file has an equivalent index.xhtml file.
# content negotiation allows an agent to pick html or xhtml.
find "$1" -type f -name '*.html' \
-exec sh -c 'echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | cat - "$0" | grep -Fv "<meta charset=\"UTF-8\" />" >"${0%*.html}.xhtml"' {} \;
# done