From 73c7feb32ec1ab9b53d0a7308ab088e9287ea5ac Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 14 Jan 2024 12:10:17 +0100 Subject: bin: list channel stream summary in email like style --- src/bin/zot/main.rs | 22 ++++++++++++++-------- src/stream/actor.rs | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/bin/zot/main.rs b/src/bin/zot/main.rs index 83ae916..383f25f 100644 --- a/src/bin/zot/main.rs +++ b/src/bin/zot/main.rs @@ -125,16 +125,22 @@ async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> { let s = Stream::from_json(&json)?; for item in s.items { if item.is_post() { - if item.title.len() > 0 { - println!("# {}", item.title); + let mut summary = item.title; + + if summary.len() == 0 { + if item.summary.len() > 0 { + summary = item.summary; + } else { + summary = item.body; + } } - if item.summary.len() > 0 { - println!("Summary: {}\n", item.summary); - } else { - println!("{}\n", item.body); - } - println!(); + summary.truncate(64); + + println!("{} {} - {}", + item.created.to_string(), + item.author.name, + summary); } } //println!("{}", z.channel_stream().await?); diff --git a/src/stream/actor.rs b/src/stream/actor.rs index 4e2bbe4..3ee371d 100644 --- a/src/stream/actor.rs +++ b/src/stream/actor.rs @@ -12,7 +12,7 @@ use url::Url; #[derive(Debug, Deserialize, PartialEq)] pub struct Actor { - name: String, + pub name: String, address: Option, url: Option, id: String, -- cgit v1.2.3