mirror of
https://github.com/YGGverse/mb.git
synced 2026-03-31 17:15:28 +00:00
use native tera filters
This commit is contained in:
parent
59b1df76c9
commit
02e8e1cfa7
3 changed files with 8 additions and 10 deletions
|
|
@ -14,7 +14,6 @@ repository = "https://github.com/yggverse/mb"
|
|||
anyhow = "1.0"
|
||||
chrono = { version = "0.4.41", features = ["serde"] }
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
plurify = "0.2"
|
||||
redb = "3.0"
|
||||
rocket = "0.5"
|
||||
rocket_dyn_templates = { version = "0.2", features = ["tera"] }
|
||||
|
|
|
|||
11
src/main.rs
11
src/main.rs
|
|
@ -8,7 +8,6 @@ mod feed;
|
|||
use config::Config;
|
||||
use db::{Db, Order, Sort};
|
||||
use feed::Feed;
|
||||
use plurify::Plurify;
|
||||
use rocket::{
|
||||
State,
|
||||
form::Form,
|
||||
|
|
@ -70,13 +69,9 @@ fn index(
|
|||
back: page.map(|p| uri!(index(search, if p > 2 { Some(p - 1) } else { None }, token))),
|
||||
next: if page.unwrap_or(1) * config.limit >= posts.total { None }
|
||||
else { Some(uri!(index(search, Some(page.map_or(2, |p| p + 1)), token))) },
|
||||
pagination_totals: if posts.total > 0 { Some(format!(
|
||||
"Page {} / {} ({} {} total)",
|
||||
page.unwrap_or(1),
|
||||
(posts.total as f64 / config.limit as f64).ceil(),
|
||||
posts.total,
|
||||
posts.total.plurify(&["post", "posts", "posts"])
|
||||
)) } else { None },
|
||||
total: posts.total,
|
||||
page: page.unwrap_or(1),
|
||||
pages: (posts.total as f64 / config.limit as f64).ceil(),
|
||||
posts: posts.posts.into_iter().map(|p| Post {
|
||||
id: p.id,
|
||||
time: p.time().format(&config.time_format).to_string(),
|
||||
|
|
|
|||
|
|
@ -29,5 +29,9 @@
|
|||
{% endif %}
|
||||
{% if next %}<a href="{{ next }}">Next</a>{% endif %}
|
||||
{% if back %}<a href="{{ back }}">Back</a>{% endif %}
|
||||
{% if pagination_totals %}<span>{{ pagination_totals }}</span>{% endif %}
|
||||
{% if total %}
|
||||
<span>
|
||||
Page {{ page }} / {{ pages }} ({{ total }} post{{ total | pluralize(plural="s") }} total)
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endblock content %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue