add post_max_chars config option

This commit is contained in:
yggverse 2025-08-22 22:47:44 +03:00
parent d66dd6fe05
commit 0f9105d14a
4 changed files with 9 additions and 2 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "mb" name = "mb"
version = "0.1.2" version = "0.2.0"
edition = "2024" edition = "2024"
license = "MIT" license = "MIT"
readme = "README.md" readme = "README.md"

View file

@ -55,4 +55,8 @@ pub struct Config {
/// Configure instance in the debug mode /// Configure instance in the debug mode
#[arg(long, default_value_t = false)] #[arg(long, default_value_t = false)]
pub debug: bool, pub debug: bool,
/// Limit post max length to `n` chars (JS-less, `maxlength` attribute)
#[arg(long)]
pub post_max_chars: Option<usize>,
} }

View file

@ -83,6 +83,7 @@ fn index(
}).collect::<Vec<Post>>(), }).collect::<Vec<Post>>(),
home: uri!(index(None::<&str>, None::<usize>, token)), home: uri!(index(None::<&str>, None::<usize>, token)),
version: env!("CARGO_PKG_VERSION"), version: env!("CARGO_PKG_VERSION"),
post_max_chars: config.post_max_chars,
search, search,
token token
}, },

View file

@ -2,7 +2,9 @@
{% block content %} {% block content %}
{% if token %} {% if token %}
<form action="/submit" method="post"> <form action="/submit" method="post">
<textarea name="message" placeholder="Enter your message..."></textarea> <textarea name="message"
placeholder="Enter your message..."
{% if post_max_chars %}maxlength="{{ post_max_chars }}"{% endif %}></textarea>
<input type="hidden" name="token" value="{{ token }}" /> <input type="hidden" name="token" value="{{ token }}" />
<input type="submit" value="Submit" /> <input type="submit" value="Submit" />
</form> </form>