From 0f9105d14add1e30caa5a8b6fa909c469c62500b Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 22 Aug 2025 22:47:44 +0300 Subject: [PATCH] add `post_max_chars` config option --- Cargo.toml | 2 +- src/config.rs | 4 ++++ src/main.rs | 1 + templates/index.html.tera | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fff6a62..ffa35be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mb" -version = "0.1.2" +version = "0.2.0" edition = "2024" license = "MIT" readme = "README.md" diff --git a/src/config.rs b/src/config.rs index e066484..b6141bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -55,4 +55,8 @@ pub struct Config { /// Configure instance in the debug mode #[arg(long, default_value_t = false)] pub debug: bool, + + /// Limit post max length to `n` chars (JS-less, `maxlength` attribute) + #[arg(long)] + pub post_max_chars: Option, } diff --git a/src/main.rs b/src/main.rs index 17c6781..8f2f6d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,6 +83,7 @@ fn index( }).collect::>(), home: uri!(index(None::<&str>, None::, token)), version: env!("CARGO_PKG_VERSION"), + post_max_chars: config.post_max_chars, search, token }, diff --git a/templates/index.html.tera b/templates/index.html.tera index 62cc6dc..6d1825f 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -2,7 +2,9 @@ {% block content %} {% if token %}
- +