mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-10 00:12:09 +00:00
Auto-format markup in CI
Use xmlfmt with some extra post-processing since xmlfmt has a few issues wrt extra newlines.
This commit is contained in:
parent
874414229e
commit
425071eade
5 changed files with 121 additions and 119 deletions
|
@ -1,9 +1,13 @@
|
||||||
---
|
---
|
||||||
|
# we rsync binaries.tar.gz from the same server we deploy to.
|
||||||
|
# it contains these static-pie binaries:
|
||||||
|
# hugo, brotli, ect (like gzip/zopfli), sd, and xmlfmt.
|
||||||
image: alpine/edge
|
image: alpine/edge
|
||||||
packages:
|
packages:
|
||||||
- rsync
|
- rsync
|
||||||
- git # for Hugo's gitInfo
|
- git # for Hugo's gitInfo
|
||||||
- bmake
|
- bmake
|
||||||
|
- moreutils
|
||||||
sources:
|
sources:
|
||||||
- https://git.sr.ht/~seirdy/seirdy.one
|
- https://git.sr.ht/~seirdy/seirdy.one
|
||||||
secrets:
|
secrets:
|
||||||
|
|
|
@ -1,83 +1,80 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta 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") -}}
|
||||||
<meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1" />
|
<meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1" />
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<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") -}}
|
||||||
{{- $isNotes = true -}}
|
{{- $isNotes = true -}}
|
||||||
<link rel="alternate" type="application/atom+xml" href="{{ site.BaseURL }}notes/atom.xml" title="Notes" />
|
<link rel="alternate" type="application/atom+xml" href="{{ site.BaseURL }}notes/atom.xml" title="Notes" />
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<link rel="alternate" type="application/atom+xml" href="{{ site.BaseURL }}posts/atom.xml" title="Posts" />
|
<link rel="alternate" type="application/atom+xml" href="{{ site.BaseURL }}posts/atom.xml" title="Posts" />
|
||||||
{{ if not $isNotes -}}
|
{{ if not $isNotes -}}
|
||||||
<link rel="alternate" type="application/atom+xml" href="{{ site.BaseURL }}/notes/atom.xml" title="Notes" />
|
<link rel="alternate" type="application/atom+xml" href="{{ site.BaseURL }}/notes/atom.xml" title="Notes" />
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne $canonicalRelPermalink "/") }} - Seirdy{{ end }}</title>
|
<title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne $canonicalRelPermalink "/") }} - Seirdy{{ end }}</title>
|
||||||
{{ $description := .Site.Params.Description -}}
|
{{ $description := .Site.Params.Description -}}
|
||||||
{{- if .Params.description -}}
|
{{- if .Params.description -}}
|
||||||
{{- $description = .Params.Description -}}
|
{{- $description = .Params.Description -}}
|
||||||
{{- else if .Summary -}}
|
{{- else if .Summary -}}
|
||||||
{{- $description = .Summary | replaceRE `\n` ` ` | replaceRE `\’` `’` | replaceRE `\ ` `\ ` | replaceRE `\“` `“` | replaceRE `\”` `”` | replaceRE `\…` `—` | replaceRE `\—` `—` | replaceRE `\­` `\­` | replaceRE `‘` `‘` | safeHTML -}}
|
{{- $description = .Summary | replaceRE `\n` ` ` | replaceRE `\’` `’` | replaceRE `\ ` `\ ` | replaceRE `\“` `“` | replaceRE `\”` `”` | replaceRE `\…` `—` | replaceRE `\—` `—` | replaceRE `\­` `\­` | replaceRE `‘` `‘` | safeHTML -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<meta name="description" content="{{ $description }}" />
|
<meta name="description" content="{{ $description }}" />
|
||||||
<meta name="author" content="{{ .Site.Author.name }}" />
|
<meta name="author" content="{{ .Site.Author.name }}" />
|
||||||
<meta property="article:author" content="{{ .Site.Author.name }}" />
|
<meta property="article:author" content="{{ .Site.Author.name }}" />
|
||||||
{{ if and (gt .Date 0) (not .Params.evergreen) -}}
|
{{ if and (gt .Date 0) (not .Params.evergreen) -}}
|
||||||
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" />
|
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}" />
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if lt .Date .Lastmod -}}
|
{{ if lt .Date .Lastmod -}}
|
||||||
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}" />
|
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}" />
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<!--the Tor Browser's safest setting disables SVGs but still downloads them to avoid fingerprinting-->
|
<!--the Tor Browser's safest setting disables SVGs but still downloads them to avoid fingerprinting-->
|
||||||
{{ if not (in site.BaseURL ".onion") -}}
|
{{ if not (in site.BaseURL ".onion") -}}
|
||||||
{{ $icon_svg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" }}
|
{{ $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 }}
|
{{- printf `<link rel="icon" sizes="any" href="%s" type="image/svg+xml" />` $icon_svg.RelPermalink | safeHTML }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ $icon_192 := resources.Get "/apple-touch-icon.png" | resources.Fingerprint "md5" }}
|
{{ $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 -}}
|
{{- printf `<link rel="icon" sizes="192x192" href="%s" type="image/png" />` $icon_192.RelPermalink | safeHTML -}}
|
||||||
{{ $favicon := resources.Get "/favicon.png" -}}
|
<meta name="color-scheme" content="light dark" />
|
||||||
{{ $favicon_base64 := $favicon.Content | base64Encode }}
|
<meta name="format-detection" content="telephone=no" /><!-- Why does apple do this -->
|
||||||
{{ printf `<link rel="icon" sizes="32x32" href="data:image/png;base64,%s" type="image/png" />` $favicon_base64 | safeHTML }}
|
<meta name="theme-color" content="#111" media="(prefers-color-scheme:dark)" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="theme-color" content="#fff" media="(prefers-color-scheme:light)" />
|
||||||
<meta name="format-detection" content="telephone=no" /><!-- Why does apple do this -->
|
<!-- inline CSS; remember to allow it with a hash in the CSP -->
|
||||||
<meta name="theme-color" content="#111" media="(prefers-color-scheme:dark)" />
|
{{- $resources := slice -}}
|
||||||
<meta name="theme-color" content="#fff" media="(prefers-color-scheme:light)" />
|
{{- $resources = $resources | append (resources.Get "/css/main.css") -}}
|
||||||
<!-- inline CSS; remember to allow it with a hash in the CSP -->
|
{{ $dark := .Site.Params.dark | default "auto" -}}
|
||||||
{{- $resources := slice -}}
|
{{- if not (eq $dark "off") -}}
|
||||||
{{- $resources = $resources | append (resources.Get "/css/main.css") -}}
|
{{ $resources = $resources | append (resources.Get "css/dark.css" | resources.ExecuteAsTemplate "dark.css" .) -}}
|
||||||
{{ $dark := .Site.Params.dark | default "auto" -}}
|
{{- end -}}
|
||||||
{{- if not (eq $dark "off") -}}
|
{{ $resources = $resources | append (resources.Get "css/print.css" | resources.ExecuteAsTemplate "print.css" .) -}}
|
||||||
{{ $resources = $resources | append (resources.Get "css/dark.css" | resources.ExecuteAsTemplate "dark.css" .) -}}
|
{{- $css := $resources | resources.Concat "css/style.css" | minify -}}
|
||||||
{{- end -}}
|
<style>{{ $css.Content | safeCSS }}</style>
|
||||||
{{ $resources = $resources | append (resources.Get "css/print.css" | resources.ExecuteAsTemplate "print.css" .) -}}
|
<meta property="og:title" content="{{ .Title }}" />
|
||||||
{{- $css := $resources | resources.Concat "css/style.css" | minify -}}
|
<meta property="og:site_name" content="{{ $.Site.Title }}" />
|
||||||
<style>{{ $css.Content | safeCSS }}</style>
|
{{- if not (or (ne "page" .Kind) (eq $canonicalRelPermalink "/bookmarks/") (eq $canonicalRelPermalink "/posts/")) }}
|
||||||
<meta property="og:title" content="{{ .Title }}" />
|
<meta property="og:type" content="article" />
|
||||||
<meta property="og:site_name" content="{{ $.Site.Title }}" />
|
{{- end -}}
|
||||||
{{- if not (or (ne "page" .Kind) (eq $canonicalRelPermalink "/bookmarks/") (eq $canonicalRelPermalink "/posts/")) }}
|
<!-- ANOTHER meta image?! When will it end? -->
|
||||||
<meta property="og:type" content="article" />
|
{{- $og_image := resources.Get "/favicon512.png" | resources.Fingerprint "md5" -}}
|
||||||
{{- end -}}
|
{{- $og_image_alt := "" -}}<!--Default open graph image is purely decorative and visual, so it should be hidden from assistive technologies.-->
|
||||||
<!-- ANOTHER meta image?! When will it end? -->
|
{{- with .Params.image -}}
|
||||||
{{- $og_image := resources.Get "/favicon512.png" | resources.Fingerprint "md5" -}}
|
|
||||||
{{- $og_image_alt := "" -}}<!--Default open graph image is purely decorative and visual, so it should be hidden from assistive technologies.-->
|
|
||||||
{{- with .Params.image -}}
|
|
||||||
{{- $og_image = resources.Get (printf "/p/%s" . ) | resources.Fingerprint "md5" -}}
|
{{- $og_image = resources.Get (printf "/p/%s" . ) | resources.Fingerprint "md5" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- with .Params.image_alt -}}
|
{{- with .Params.image_alt -}}
|
||||||
{{- $og_image_alt = . -}}
|
{{- $og_image_alt = . -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ printf `<meta property="og:image" content="%s" />` $og_image.Permalink | safeHTML }}
|
{{ printf `<meta property="og:image" content="%s" />` $og_image.Permalink | safeHTML }}
|
||||||
<meta property="og:image:type" content="image/png" />
|
<meta property="og:image:type" content="image/png" />
|
||||||
<meta property="og:image:height" content="{{ $og_image.Height }}" /><meta property="og:image:width" content="{{ $og_image.Width }}" />
|
<meta property="og:image:height" content="{{ $og_image.Height }}" /><meta property="og:image:width" content="{{ $og_image.Width }}" />
|
||||||
<meta property="og:image:alt" content="{{ $og_image_alt }}" />
|
<meta property="og:image:alt" content="{{ $og_image_alt }}" />
|
||||||
<meta property="og:url" content="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" />
|
<meta property="og:url" content="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" />
|
||||||
<meta property="og:description" content="{{ $description }}" />
|
<meta property="og:description" content="{{ $description }}" />
|
||||||
{{ hugo.Generator }}
|
{{ hugo.Generator }}
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<header>
|
<header>
|
||||||
<nav aria-label="Global">
|
<nav aria-label="Global">
|
||||||
<ul>
|
<ul>
|
||||||
{{- $currentPage := . -}}
|
{{- $currentPage := . -}}
|
||||||
|
@ -33,4 +33,4 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -55,5 +55,5 @@
|
||||||
<dd>This post does not have any approved Webmentions yet.</dd>
|
<dd>This post does not have any approved Webmentions yet.</dd>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</dl>
|
</dl>
|
||||||
<p></p>
|
<p>Feel free to contact me directly with feedback; <a href="{{ .Site.BaseURL }}about/#location-seirdy-online">here’s my contact info</a></p>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
# XML tooling.
|
# XML tooling.
|
||||||
# this means that every index.html file has an equivalent index.xhtml file.
|
# this means that every index.html file has an equivalent index.xhtml file.
|
||||||
# content negotiation allows an agent to pick html or xhtml.
|
# content negotiation allows an agent to pick html or xhtml.
|
||||||
|
# echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
|
|
||||||
find "$1" -type f -name '*.html' \
|
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"' {} \;
|
-exec sh -c 'echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >"${0%*.html}.xhtml" && xmlfmt -i " " -f "$0" | busybox sed -e :a -e "/./,\$!d;/^\n*\$/{\$d;N;};/\n\$/ba" | sd -f m "\n(?:\t*)?</" "</" | sd -f m "<pre>\n\t*<code" "<pre><code" | pee "sed 5d >>\"${0%*.html}.xhtml\"" "sponge \"$0\""' {} \;
|
||||||
# done
|
# done
|
||||||
|
|
Loading…
Reference in a new issue