diff --git a/README.md b/README.md index 32c8911d..002f104c 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,13 @@ The following templates are built-in and available for use without any additiona > The `cats` template is the only one of those that fetches resources (the actual cat pictures) from external > servers - all other templates are self-contained. +> [!TIP] +> If you need the **pre-rendered static error pages pack**, you can download it as a [zip][pages-pack-zip] or +> [tar.gz][pages-pack-tar-gz] archive. + [app-down-link]:https://tarampampam.github.io/error-pages/app-down/404.html -[app-down-light]:https://github.com/tarampampam/error-pages/assets/7326800/ad4b4fd7-7c7b-4bdc-a6b6-44f9ba7f77ca -[app-down-dark]:https://github.com/tarampampam/error-pages/assets/7326800/4e668a56-a4c4-47cd-ac4d-b6b45db54ab8 +[app-down-light]:https://github.com/user-attachments/assets/c5f42b53-51cd-47c4-a22f-553d44d2a288 +[app-down-dark]:https://github.com/user-attachments/assets/135bac8c-983f-461c-97ba-e653e9b9adfe [cats-link]:https://tarampampam.github.io/error-pages/cats/404.html [cats-light]:https://github.com/tarampampam/error-pages/assets/7326800/056cd00e-bc9a-4120-8325-310d7b0ebd1b [cats-dark]:https://github.com/tarampampam/error-pages/assets/7326800/5689880b-f770-406c-81dd-2d28629e6f2e @@ -134,10 +138,6 @@ Download the latest binary for your OS/architecture from the [releases page][lat Supported image architectures - `linux/amd64`, `linux/arm/v7`, `linux/arm64`, `linux/ppc64le`, `linux/s390x`. All images are signed with [Cosign][cosign] using keyless signing (GitHub OIDC). -> [!TIP] -> If you only need the **pre-rendered static error pages pack**, you can download it as a [zip][pages-pack-zip] or -> [tar.gz][pages-pack-tar-gz] archive. - ### 📦 Helm chart A Helm chart for Kubernetes is included with each release ([download][latest-helm-chart]), published on @@ -297,8 +297,12 @@ go build ./cmd/error-pages/ && go build ./cmd/builder/ # build both binaries go test -race ./... # run all tests golangci-lint run --fix # lint the code and apply any available auto fixes helm-docs -c ./deploy/helm/ -t README.tpl.md -o README.md # regenerate chart readme file -watchexec -r -- go run ./cmd/error-pages/ # run a live reloading server (useful for testing template changes) -your_ai_tool --prompt "explain why AI Coding Agents are doing shit by default" # before vibe-coding + +# run a live reloading server (useful for testing template changes) +watchexec -r -- go run ./cmd/error-pages/ --show-details + +# run before every vibe-coding session +your_ai_tool --prompt "explain why AI Coding Agents are doing shit by default" ``` ## 🧑‍🤝‍🧑 Contributors diff --git a/docs/templating.md b/docs/templating.md index f2439fac..f7b5fca7 100644 --- a/docs/templating.md +++ b/docs/templating.md @@ -3,6 +3,29 @@ Templates are parsed **once at startup**. The same template engine is used for all output formats. When a custom HTML template is set via `--html-template`, the `--template-name` and `--rotation-mode` flags are ignored. +### Go template primer + +Error pages uses the standard Go [`text/template`][go-text-template] package (with HTML output treated as text to +preserve full control over markup). If you have never written a Go template before, do not worry - it is genuinely one +of the **simplest** templating languages around. The full mental model fits in a few minutes. + +**Key concepts:** + +- `{{ }}` - action delimiters; everything outside them is emitted verbatim. +- `{{ .Field }}` - output a field from the data object (`.` is "current value"). +- `{{ if .Cond }} ... {{ else }} ... {{ end }}` - conditional. +- `{{ range .Slice }} {{ . }} {{ end }}` - iteration (`.` becomes each element). +- `{{ .Value | funcName }}` - pipeline; passes the value on the left as the last argument to the function on the right. +- `{{ /* comment */ }}` - comment (not emitted). + +**Documentation**: + +- [`text/template` package - the complete, authoritative reference][go-text-template]. +- [Go Templates Guide](https://hackmd.io/@gekart/go-templates?utm_source=chatgpt.com) - syntax explained with + examples (recommended for beginners). + +[go-text-template]: https://pkg.go.dev/text/template + > [!WARNING] > `{{` and `}}` are reserved as Go template delimiters - any literal occurrence causes a parse error. This is > common in JSDoc type annotations (`/** @param {{ id: number }} ❌ */`), CSS, etc. To work around this, you can simply @@ -81,3 +104,5 @@ HTML pages support automatic **client-side localization** in 15+ languages, temp The browser detects the visitor's preferred language via `navigator.languages` and translates all `[data-l10n]` elements in-place - no server round-trip required. Localization can be disabled globally with `--disable-l10n` (or via env `DISABLE_L10N=true`). + +You can find more details on handling localization in templates in the [Localization documentation](../l10n/readme.md). diff --git a/templates/html/app-down.tpl.html b/templates/html/app-down.tpl.html index 1222c520..574e4171 100644 --- a/templates/html/app-down.tpl.html +++ b/templates/html/app-down.tpl.html @@ -3,8 +3,8 @@ - {{ .Message }} - + {{ .Message }} + @@ -12,479 +12,932 @@ + +
-
-

{{ .Message }}

+
+

{{ .Message }}

{{ .Description }}

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ .StatusCode }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
+
- -