diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-06-19 19:57:13 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-06-19 19:57:13 -0400 |
| commit | ece1c6fcf4fe51ce6e57f3c261a042ff9e84faf1 (patch) | |
| tree | ea21f062744c16b67c4348288c4a3017f37f9815 /src | |
| parent | e1cae593b1acde2d5552dfbae8367c6b0a726d5c (diff) | |
[birka-web] strip full path from image display page.
Diffstat (limited to 'src')
| -rw-r--r-- | src/birka-web.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/birka-web.rs b/src/birka-web.rs index 0bbaf59..2053805 100644 --- a/src/birka-web.rs +++ b/src/birka-web.rs @@ -296,13 +296,21 @@ fn display_post(conn: SiteState, id: i64) -> Result<Template> { .tb; let file = tb.file_by_id(id)?; + let orig_filename = String::from( + Path::new(&file.path) + .file_name() + .ok_or(anyhow!("Directory indexed and returned by query"))? + .to_str() + .ok_or(anyhow!("Could not parse filename"))?, + ); + Ok(Template::render( "image", Context { id, + orig_filename, tags: file.tags, filename: store_filename(file.id, &file.path), - orig_filename: file.path, }, )) } |