mirror of
https://github.com/YGGverse/mb.git
synced 2026-03-31 09:05:28 +00:00
add post_max_chars config option
This commit is contained in:
parent
d66dd6fe05
commit
0f9105d14a
4 changed files with 9 additions and 2 deletions
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue