Skip to content

Commit 32532af

Browse files
committed
web: WIP: Update askama to 0.15
It throws new warnings about how I call the title block multiple times in the base template. Tracking this on their discussion tracker: askama-rs/askama#657 (reply in thread)
1 parent 0f1ebe7 commit 32532af

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

Cargo.lock

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bobashare-web/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default-run = "bobashare-web"
1313

1414
[dependencies]
1515
anyhow = "1.0.65"
16-
askama = "0.14.0"
16+
askama = "0.15.1"
1717
axum = { version = "0.8.0", features = ["multipart"] }
1818
axum-extra = { version = "0.12.5", features = ["typed-header", "with-rejection"] }
1919
bobashare = { path = "../bobashare" }

bobashare-web/src/views/filters.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use askama::Result;
22
use chrono::TimeDelta;
3-
use humansize::format_size;
3+
use ::humansize::format_size;
44

55
fn pluralize(input: &str, count: i64) -> String {
66
if count == 1 {
@@ -11,6 +11,7 @@ fn pluralize(input: &str, count: i64) -> String {
1111
}
1212

1313
// TODO: this would be nice and easy to test
14+
#[askama::filter_fn]
1415
pub fn humanduration(duration: &TimeDelta, _: &dyn askama::Values) -> Result<String> {
1516
let duration = *duration;
1617
if duration < TimeDelta::try_minutes(1).unwrap() {
@@ -36,6 +37,7 @@ pub fn humanduration(duration: &TimeDelta, _: &dyn askama::Values) -> Result<Str
3637
// probably no point going past months
3738
}
3839

40+
#[askama::filter_fn]
3941
pub fn humansize(size: &u64, _: &dyn askama::Values) -> Result<String> {
40-
Ok(format_size(*size, humansize::BINARY))
42+
Ok(format_size(*size, ::humansize::BINARY))
4143
}

bobashare-web/templates/display.html.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{% block title %}{{ filename }}{% endblock %}
44
{% block preview_metadata %}
5-
{% let filename_truncated %}
5+
{% decl filename_truncated %}
66
{% if filename.len() > 50 %}
77
{# U+2026 is ellipses (three dots) #}
88
{% let filename_truncated = format!("{:.50}\u{2026}", self.filename) %}
@@ -54,14 +54,14 @@
5454
{% endblock %}
5555

5656
{% block main %}
57-
{% let expiry_human %}
57+
{% decl expiry_human %}
5858
{% if let Some(e) = expiry_relative %}
5959
{% let expiry_human = e|humanduration %}
6060
{% else %}
6161
{% let expiry_human = String::from("never") %}
6262
{% endif %}
6363

64-
{% let expiry_exact %}
64+
{% decl expiry_exact %}
6565
{% if let Some(e) = expiry_date %}
6666
{% let expiry_exact = e.to_string() %}
6767
{% else %}

0 commit comments

Comments
 (0)