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

Compare commits

...

4 commits

Author SHA1 Message Date
Rohan Kumar
6a7ac36f11
Add 404 page 2022-05-31 18:07:04 -07:00
Rohan Kumar
b4850ed89a
Use XML declaration on XHTML, other XHTML tweaks
- Remove XHTML content-type meta header from HTML documents, reverting
  back to the meta charset
- Give XHTML documents their own XHTML declaration
- Remove now-redundant meta charset from XHTML
- Since XHTML and HTML documents differ now, compress after running
  xhtmlize and make xhtmlize only act on uncompressed files.
- Validate XHTML using vnu
2022-05-31 17:16:44 -07:00
Rohan Kumar
c936ca1902
Remove extra newlines 2022-05-31 17:11:52 -07:00
Rohan Kumar
90aeb2d23a
Create both index.html and index.xhtml files
Combines well with content-negotiation based on the "Accept" header.
2022-05-30 16:09:40 -07:00
14 changed files with 172 additions and 57 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 # dev server, includes future and draft posts
.PHONY: serve .PHONY: serve
serve: serve:
hugo serve --disableLiveReload $(HUGO_FLAGS) hugo serve --disableLiveReload $(HUGO_FLAGS) -FwDb http://localhost:1313/
.PHONY: hint-devserver .PHONY: hint-devserver
hint-devserver: .hintrc-devserver hint-devserver: .hintrc-devserver
@ -69,19 +69,16 @@ check-links: hugo
.PHONY: test .PHONY: test
test: lint-css hint-devserver check-links test: lint-css hint-devserver check-links
gz: gzip:
find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.webmanifest' -o -name '*.*.svg' \ sh scripts/compress.sh $(OUTPUT_DIR) gzip $(ECT_LEVEL)
| grep -v gemini \
| xargs ect -$(ECT_LEVEL) -gzip
brotli: brotli:
find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.webmanifest' -o -name '*.*.svg' \ sh scripts/compress.sh $(OUTPUT_DIR) brotli
| grep -v gemini \ compress: gzip brotli
| xargs brotli -q 11 -- .PHONY: gzip brotli compress
compress: gz brotli .PHONY: xhtmlize
xhtmlize:
.PHONY: compress gz brotli sh scripts/xhtmlize.sh $(OUTPUT_DIR)
# save webmentions to a file, don't send yet # save webmentions to a file, don't send yet
mentions.json: hugo mentions.json: hugo
@ -98,44 +95,47 @@ deploy-html:
.PHONY: deploy-gemini .PHONY: deploy-gemini
deploy-gemini: deploy-gemini:
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) --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
.PHONY: deploy .PHONY: deploy
deploy: deploy-html deploy-gemini deploy: deploy-html deploy-gemini
## stuff for the staging server .PHONY: .prepare-deploy
.PHONY: test-staging .prepare-deploy:
test-staging: deploy-html
yq e '.ci .collect .url | .[]' .lighthouserc.yml | xargs npx hint -f codeframe
npx lhci autorun
.PHONY: all
all: test deploy
.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
@$(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) clean
@$(MAKE) hugo @$(MAKE) hugo
@$(MAKE) xhtmlize
@$(MAKE) compress @$(MAKE) compress
# deploy steps need to happen one at a time
.PHONY: deploy-prod
deploy-prod: .prepare-deploy
@$(MAKE) deploy @$(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 .PHONY: deploy-onion
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 deploy-prod
@$(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 # we only deploy html to the staging site
@$(MAKE) WWW_ROOT=/var/www/seirdy.onion HUGO_BASEURL='http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/' OUTPUT_DIR=public_onion deploy-html .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
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 deploy

10
content/404.md Normal file
View file

@ -0,0 +1,10 @@
---
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).

View file

80
layouts/_default/404.html Normal file
View file

@ -0,0 +1,80 @@
<!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 http-equiv="Content-Type" content="application/xhtml+xml; 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") -}}
@ -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,14 +11,8 @@
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
) )
) )

20
scripts/compress.sh Normal file
View file

@ -0,0 +1,20 @@
#!/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

11
scripts/xhtmlize.sh Normal file
View file

@ -0,0 +1,11 @@
#!/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