Render the name and the uploaded date for each file in the gallery
This commit is contained in:
parent
e96b8087e2
commit
ee348c29cb
|
@ -1,6 +1,6 @@
|
|||
use crate::html::*;
|
||||
use build_html::{self, Container, ContainerType, Html, HtmlContainer};
|
||||
use file_service::{FileHandle, FileId, ReadFileError};
|
||||
use file_service::{FileHandle, FileInfo, ReadFileError};
|
||||
|
||||
pub fn auth(_message: Option<String>) -> build_html::HtmlPage {
|
||||
build_html::HtmlPage::new()
|
||||
|
@ -49,14 +49,7 @@ pub fn gallery(handles: Vec<Result<FileHandle, ReadFileError>>) -> build_html::H
|
|||
let mut gallery = Container::new(ContainerType::Div).with_attributes([("class", "gallery")]);
|
||||
for handle in handles {
|
||||
let container = match handle {
|
||||
Ok(ref handle) => thumbnail(&handle.id).with_html(
|
||||
Form::new()
|
||||
.with_path(&format!("/{}", *handle.id))
|
||||
.with_method("post")
|
||||
.with_html(Input::new("hidden", "_method").with_value("delete"))
|
||||
.with_html(Button::new("Delete")),
|
||||
),
|
||||
|
||||
Ok(ref handle) => thumbnail(&handle.info),
|
||||
Err(err) => Container::new(ContainerType::Div)
|
||||
.with_attributes(vec![("class", "file")])
|
||||
.with_paragraph(format!("{:?}", err)),
|
||||
|
@ -88,15 +81,31 @@ pub fn upload_form() -> Form {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn thumbnail(id: &FileId) -> Container {
|
||||
pub fn thumbnail(info: &FileInfo) -> Container {
|
||||
Container::new(ContainerType::Div)
|
||||
.with_attributes(vec![("class", "card thumbnail")])
|
||||
.with_html(
|
||||
Container::new(ContainerType::Div).with_link(
|
||||
format!("/{}", **id),
|
||||
Image::new(&format!("{}/tn", **id))
|
||||
format!("/{}", *info.id),
|
||||
Image::new(&format!("{}/tn", *info.id))
|
||||
.with_attributes([("class", "thumbnail__image")])
|
||||
.to_html_string(),
|
||||
),
|
||||
)
|
||||
.with_html(
|
||||
Container::new(ContainerType::Div)
|
||||
.with_html(
|
||||
UnorderedList::new()
|
||||
.with_attributes(vec![("class", "thumbnail__metadata")])
|
||||
.with_html(info.name.clone())
|
||||
.with_html(format!("{}", info.created.format("%Y-%m-%d"))),
|
||||
)
|
||||
.with_html(
|
||||
Form::new()
|
||||
.with_path(&format!("/{}", *info.id))
|
||||
.with_method("post")
|
||||
.with_html(Input::new("hidden", "_method").with_value("delete"))
|
||||
.with_html(Button::new("Delete")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -77,6 +77,10 @@ body {
|
|||
border: none;
|
||||
}
|
||||
|
||||
.thumbnail__metadata {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/*
|
||||
[type="submit"] {
|
||||
border-radius: 1em;
|
||||
|
|
Loading…
Reference in New Issue