From 690bb6715bf10394a3a265d06e588b6b198704eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 25 Jul 2021 13:40:04 +0200 Subject: [PATCH] add recently changed (fix #5) --- src/main.rs | 16 +++++++++++ templates/main.css | 28 ++++++++++++++++--- templates/main.html | 66 ++++++++++++++++++++++++++++++++------------- 3 files changed, 87 insertions(+), 23 deletions(-) diff --git a/src/main.rs b/src/main.rs index e1abd5e..bcc65ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -208,6 +208,21 @@ async fn render( let normalized_name = normalize_name(filename); + let mut recently_changed = cache + .pages + .clone() + .into_iter() + .filter_map(|i| match i.1.timestamp { + Some(ts) => Some(( + i.0, + ts.duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(), + )), + None => None, + }) + .collect::>(); + recently_changed.sort_by_key(|i| i.1); + recently_changed.reverse(); + let mut backlinks: Vec = vec![]; for (path, page) in cache.pages.iter() { if page @@ -228,6 +243,7 @@ async fn render( data.title.as_ref().unwrap_or(&"Digital Garden".to_string()), ); context.insert("files", &cache.files); + context.insert("recently_changed", &recently_changed); context.insert( "page_title", &match page { diff --git a/templates/main.css b/templates/main.css index 02d78d9..4ba664a 100644 --- a/templates/main.css +++ b/templates/main.css @@ -70,6 +70,10 @@ aside h1 { font-variant: small-caps; } +aside h2 { + font-size: 12pt; +} + @media screen and (max-width: 800px) { body { flex-direction: column-reverse; @@ -129,6 +133,14 @@ nav li { margin: .25em 0; } +nav ul a { + text-decoration: none; +} + +nav .filepath { + text-decoration: underline; +} + nav .file { font-style: italic; opacity: .8; @@ -138,6 +150,18 @@ nav .not-last { opacity: .5; } +nav .timestamp { + opacity: .8; +} + +nav .timestamp:before { + content: "["; +} + +nav .timestamp:after { + content: "]"; +} + footer { padding: 1em 0; color: gray; @@ -165,19 +189,15 @@ main footer { background: #141414; color: #e3e3e3; } - a { color: #90d7e5; } - a:visited { color: #3d9bb3; } - nav h1 a { color: white; } - code { background: black; color: #F8F8FC; diff --git a/templates/main.html b/templates/main.html index 7d215bb..9fd43ca 100644 --- a/templates/main.html +++ b/templates/main.html @@ -25,25 +25,53 @@