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 2a4165e9e0
5 changed files with 78 additions and 19 deletions

View file

@ -20,6 +20,35 @@ run-watch:
alias w := run-watch
# Build on changes
[group: 'develop']
build-watch target=default_target:
@{{ watch_cmd }} {{ just_cmd }} build {{ target }}
alias bw := build-watch
# Build dev container
[group: 'develop', working-directory: 'containers']
build-containerized distro="alpine": build
./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]
quick-assess:
{{ just_cmd }} lint check quick-test-cover
@ -297,13 +326,28 @@ clean:
alias cl := clean
# Build project with Cargo
# Build
[group: 'build']
build target=default_target:
cargo build --target {{ target }} --locked
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
[group: 'build']
release-build target=default_target:
@ -314,7 +358,7 @@ alias rb := release-build
# glibc release build
[group: 'build']
release-build-gnu:
cargo build --target {{ glibc_target }} --locked --release
cargo build --target {{ glibc_target }} --locked --release
alias rbg := release-build-gnu

4
Cargo.lock generated
View file

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

View file

@ -9,9 +9,9 @@ if podman container exists "$tag"; then
fi
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
cp -v ../target/x86_64-unknown-linux-musl/release/en en
cp -v ../target/x86_64-unknown-linux-musl/debug/en en
fi
podman build \

View file

@ -53,7 +53,10 @@ pub(in crate::router::handlers) fn render(
let tera = match tera::Tera::new("./templates/**/*") {
Ok(t) => t,
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\
<head>\n\
<title>en Pre-Templating Error</title>\n
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >\n\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\
<meta \
http-equiv=\"Content-Type\" \
content=\"text/html; charset=utf-8\" >\n\
<meta name=\"viewport\" \
content=\"width=device-width, initial-scale=1\">\n\
<style>\n\
:root {{ color-scheme: light dark; }}\n\
* {{\n\
@ -121,14 +127,21 @@ fn emergency_wrap(error: &tera::Error, message: &str) -> String {
<pre>\n\
{error:#?}\n\
</pre>\n\
<p>This normally indicates a malformed or missing template.</p>\n\
<p>\n\
If you haven't modified templates, please consider\n\
<a href=\"https://codeberg.org/jutty/en/issues\">reporting it</a>.\n\
<p>This error may indicate a malformed or missing template.</p>\n\
<p>If you haven't modified templates, please consider \
<a href=\"https://codeberg.org/jutty/en/issues\">\
reporting it</a>, including:\
</p>\n\
<ul>\n\
<li>The error message above</li>\n\
<li>en version: <code>{}</code></li>\n\
<li>If possible, your graph file's <code>[meta.config]</code> \
values and definition for this page.</li>\n\
</ul>\n\
</body>\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.
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.
@ -24,11 +24,13 @@ You will need:
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.
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|.
## 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:
`
git clone https://codeberg.org/jutty/en
git clone -b v{{ en_version }} --single-branch https://codeberg.org/jutty/en
cd en
cargo build --release
cargo build --locked --release
`
In this case, the `en` binary will be in `target/release/en`.
## 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.
"""