Better templating error message, container builds justfile recipes
Some checks are pending
/ verify (push) Waiting to run

This commit is contained in:
Juno Takano 2026-03-08 23:17:14 -03:00
commit ad9c47d0e2
5 changed files with 78 additions and 19 deletions

View file

@ -20,6 +20,35 @@ run-watch:
alias w := run-watch alias w := run-watch
# Build on changes
[group: 'develop']
build-watch target=default_target:
@{{ watch_cmd }} cargo build --target {{ target }}
alias bw := build-watch
# Build dev container
[group: 'develop', working-directory: 'containers']
build-containerized distro="alpine":
./build.sh {{ distro }}-dev
alias bc := build-containerized
# Run dev container
[group: 'develop', working-directory: 'containers']
run-containerized distro="alpine":
./run.sh {{ distro }}-dev
alias rc := run-containerized
# Build dev container and serve from it on changes
[group: 'develop']
run-watch-containerized:
@{{ watch_cmd }} "{{ just_cmd }} build-containerized \
&& {{ just_cmd }} run-containerized"
alias wc := run-watch-containerized
[private] [private]
quick-assess: quick-assess:
{{ just_cmd }} lint check quick-test-cover {{ just_cmd }} lint check quick-test-cover
@ -304,6 +333,20 @@ build target=default_target:
alias b := build alias b := build
# glibc build
[group: 'build']
build-gnu:
cargo build --target {{ glibc_target }} --locked
alias bg := build-gnu
# musl build
[group: 'build']
build-musl:
cargo build --target {{ musl_target }} --locked
alias bm := build-musl
# Release build # Release build
[group: 'build'] [group: 'build']
release-build target=default_target: release-build target=default_target:
@ -314,7 +357,7 @@ alias rb := release-build
# glibc release build # glibc release build
[group: 'build'] [group: 'build']
release-build-gnu: release-build-gnu:
cargo build --target {{ glibc_target }} --locked --release cargo build --target {{ glibc_target }} --locked --release
alias rbg := release-build-gnu alias rbg := release-build-gnu

4
Cargo.lock generated
View file

@ -550,9 +550,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.182" version = "0.2.183"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
[[package]] [[package]]
name = "libm" name = "libm"

View file

@ -9,9 +9,9 @@ if podman container exists "$tag"; then
fi fi
if [ "$suffix" = 'debian-dev' ]; then if [ "$suffix" = 'debian-dev' ]; then
cp -v ../target/x86_64-unknown-linux-gnu/release/en en cp -v ../target/x86_64-unknown-linux-gnu/debug/en en
elif [ "$suffix" = 'alpine-dev' ]; then elif [ "$suffix" = 'alpine-dev' ]; then
cp -v ../target/x86_64-unknown-linux-musl/release/en en cp -v ../target/x86_64-unknown-linux-musl/debug/en en
fi fi
podman build \ podman build \

View file

@ -53,7 +53,10 @@ pub(in crate::router::handlers) fn render(
let tera = match tera::Tera::new("./templates/**/*") { let tera = match tera::Tera::new("./templates/**/*") {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
return (emergency_wrap(&e, "Failed instantiating template engine"), 500); return (
emergency_wrap(&e, "Failed instantiating template engine"),
500,
);
}, },
}; };
@ -103,8 +106,11 @@ fn emergency_wrap(error: &tera::Error, message: &str) -> String {
<html>\n\ <html>\n\
<head>\n\ <head>\n\
<title>en Pre-Templating Error</title>\n <title>en Pre-Templating Error</title>\n
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >\n\ <meta \
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\ http-equiv=\"Content-Type\" \
content=\"text/html; charset=utf-8\" >\n\
<meta name=\"viewport\" \
content=\"width=device-width, initial-scale=1\">\n\
<style>\n\ <style>\n\
:root {{ color-scheme: light dark; }}\n\ :root {{ color-scheme: light dark; }}\n\
* {{\n\ * {{\n\
@ -121,14 +127,22 @@ fn emergency_wrap(error: &tera::Error, message: &str) -> String {
<pre>\n\ <pre>\n\
{error:#?}\n\ {error:#?}\n\
</pre>\n\ </pre>\n\
<p>This normally indicates a malformed or missing template.</p>\n\ <p>This error may be due to malformed or missing templates.</p>\n\
<p>\n\ <p>If you haven't modified templates, please consider \
If you haven't modified templates, please consider\n\ <a href=\"https://codeberg.org/jutty/en/issues\">\
<a href=\"https://codeberg.org/jutty/en/issues\">reporting it</a>.\n\ reporting it, including:\
</p>\n\ </a>.</p>\n\
<ul>\n\
<li>The error message above</li>\n\
<li>en version: <code>{}</code></li>\n\
<li>If possible, your graph file. Otherwise, at least the \
relevant parts: configuration values and the definition \
for this failing page.</li>\n\
</ul>\n\
</body>\n\ </body>\n\
</html>\n\ </html>\n\
" ",
env!("CARGO_PKG_VERSION")
) )
} }

View file

@ -8,7 +8,7 @@ text = """
The easiest way to get started is by downloading a pre-built binary. The easiest way to get started is by downloading a pre-built binary.
x86-64 Linux binaries are available from the |git.jutty.dev package registry|https://git.jutty.dev/jutty/-/packages/generic/en|. Check the links under "Assets" for direct downloads. x64 Linux binaries are available from the |git.jutty.dev package registry|https://git.jutty.dev/jutty/-/packages/generic/en|. Check the links under "Assets" for direct downloads.
Other platforms may be supported in the future depending on CI resources. Other platforms may be supported in the future depending on CI resources.
@ -24,11 +24,13 @@ You will need:
Given the above is satisfied, you can build directly through Cargo: Given the above is satisfied, you can build directly through Cargo:
` `
cargo install --git https://codeberg.org/jutty/en cargo install --git https://codeberg.org/jutty/en --tag v{{ en_version }}
` `
And you should now have the `en` command available on your shell. And you should now have the `en` command available on your shell.
The `cargo install` example shown above will build en from the latest tagged release, which should be more stable. You can remove the `--tag v{{ en_version }}` part if you'd like to build the very latest development sources.
For more details on building from source, see |SourceBuild|. For more details on building from source, see |SourceBuild|.
## Usage ## Usage
@ -131,16 +133,16 @@ You may also need `curl`, `git` and `ca-certificates` depending on how you will
Aside from the `cargo install` approach described in |Documentation|, ou can alternatively fetch the code yourself using Git, which allows you to inspect and change it before compiling: Aside from the `cargo install` approach described in |Documentation|, ou can alternatively fetch the code yourself using Git, which allows you to inspect and change it before compiling:
` `
git clone https://codeberg.org/jutty/en git clone -b v{{ en_version }} --single-branch https://codeberg.org/jutty/en
cd en cd en
cargo build --release cargo build --locked --release
` `
In this case, the `en` binary will be in `target/release/en`. In this case, the `en` binary will be in `target/release/en`.
## Runnable examples ## Runnable examples
You can find the exact commands used to test installation on both systems in the |<code>tests/containers</code>|https://codeberg.org/jutty/en/src/branch/main/tests/containers| directory of the en source repository. You can find the exact commands used to test installation on both systems in the |<code>containers</code>|https://codeberg.org/jutty/en/src/branch/main/containers| directory of the en source repository.
""" """