From 89ed21ded5d052d54a28e2a08e042f50a9ccd5a0 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sun, 17 Feb 2019 09:18:13 +0100 Subject: Improved design of last-modification column --- src/listing.rs | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/listing.rs b/src/listing.rs index 93ae04b..b985b1e 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -190,24 +190,26 @@ pub fn directory_listing( if reverse_sort { entries.reverse(); } - for entry in entries { + let (modification_date, modification_time) = convert_to_utc(entry.last_modification_date); + match entry.entry_type { EntryType::Directory => { let _ = write!( body, - "{}/{} ({})", - entry.link, entry.name, convert_to_utc(entry.last_modification_date), humanize_duration(entry.last_modification_date) + "{}/{}{}{}", + entry.link, entry.name, modification_date, modification_time, humanize_duration(entry.last_modification_date) ); } EntryType::File => { let _ = write!( body, - "{}{}{} ({})", + "{}{}{}{}{}", entry.link, entry.name, entry.size.unwrap(), - convert_to_utc(entry.last_modification_date), + modification_date, + modification_time, humanize_duration(entry.last_modification_date) ); } @@ -269,8 +271,16 @@ pub fn directory_listing( a:visited {{\ color: #8e44ad;\ }}\ - .ago {{\ - color: #c5c5c5;\ + td.date-cell {{\ + display: flex;\ + width: calc(100% - 1.25rem);\ + }}\ + td.date-cell span:first-of-type,\ + td.date-cell span:nth-of-type(2) {{\ + flex-basis:4.5rem;\ + }}\ + td.date-cell span:nth-of-type(3) {{\ + color: #c5c5c5\ }}\ @media (max-width: 600px) {{\ h1 {{\ @@ -297,13 +307,16 @@ pub fn directory_listing( .body(html)) } -fn convert_to_utc(src_time: Option) -> String { +fn convert_to_utc(src_time: Option) -> (String, String) { match src_time { Some(time) => { let date_time = DateTime::::from(time); - date_time.format("%e %b  %R").to_string() + ( + date_time.format("%e %b").to_string(), + date_time.format("%R").to_string(), + ) } - None => "".to_string(), + None => ("".to_string(), "".to_string()), } } -- cgit v1.2.3