From 6ca40e23219c34994cceeb358fe36a8dab06cea2 Mon Sep 17 00:00:00 2001 From: lew Date: Wed, 29 Apr 2026 01:40:48 +0100 Subject: [PATCH] feat: add base_path support for mounting under a URL prefix Wraps the router in axum's `nest` when BOOK_BASE_PATH is set, prepends the prefix to form actions and asset URLs, and exposes a {{base}} template placeholder. basePath option added to the NixOS module. --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 15 ++++++-- module.nix | 17 +++++++-- src/config.rs | 63 ++++++++++++++++++++++++++++++++ src/render.rs | 82 +++++++++++++++++++++++++++++++++++++++--- src/web.rs | 79 ++++++++++++++++++++++++++++++++++++++-- templates/default.html | 2 ++ templates/success.html | 3 +- 9 files changed, 251 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fef0d0c..3c654da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -470,7 +470,7 @@ dependencies = [ [[package]] name = "guestbook" -version = "0.2.10" +version = "0.2.11" dependencies = [ "axum", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index c7ab141..5d3f9fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "guestbook" -version = "0.2.10" +version = "0.2.11" edition = "2021" description = "A configurable, self-hosted guestbook for the web, allowing visitors to leave behind messages, drawings, and voice notes, with spam-prevention and moderation via Telegram bot." license = "MIT" diff --git a/README.md b/README.md index c794716..3ffc5b9 100644 --- a/README.md +++ b/README.md @@ -191,15 +191,21 @@ Running `guestbook` with no env vars will give you a working guestbook on `local # Message textarea height in pixels. # BOOK_TEXTAREA_HEIGHT=150 -# Custom HTML template file with {{title}}, {{form}}, {{entries}}, and {{style}} placeholders. +# Custom HTML template file with {{title}}, {{form}}, {{entries}}, {{style}}, and {{base}} placeholders. # Uses built-in default if unset. # BOOK_TEMPLATE=./templates/default.html # Custom success page template shown after a successful submission. -# Supports {{title}} and {{style}} placeholders. Use