diff --git a/src/html.rs b/src/html.rs index 46a081c..9ad65fc 100644 --- a/src/html.rs +++ b/src/html.rs @@ -86,11 +86,13 @@ pub fn serve_note_html( // 1: abbreviated description // 2: hostname // 3: bech32 entity - // 4: Full content + // 5: formatted date + // 6: pfp url let hostname = "https://damus.io"; let abbrev_content = html_escape::encode_text(abbreviate(¬e_data.note.content, 64)); let profile_name = html_escape::encode_text(¬e_data.profile.name); + let bech32 = nip19.to_bech32().unwrap(); write!( data, @@ -98,7 +100,9 @@ pub fn serve_note_html( {0} on nostr + + @@ -119,13 +123,35 @@ pub fn serve_note_html( -

Note!

-
-
"#, +
+
+
+ + + + +
+

Note

+
+
+
+ +
{0}
+
·
+
{4}
+
+ +
"#, profile_name, abbrev_content, hostname, - nip19.to_bech32().unwrap() + bech32, + note_data.note.timestamp, + note_data.profile.pfp_url, )?; let ok = (|| -> Result<(), nostrdb::Error> { @@ -150,12 +176,26 @@ pub fn serve_note_html( write!( data, - " + r#" +
+
+
+ -
+
+
+ + Damus is a decentralized social network app built on the Nostr protocol. + + + © Damus Nostr Inc. + +
- " + "#, + bech32 ); Ok(Response::builder() diff --git a/src/render.rs b/src/render.rs index dfa3604..bcf3e90 100644 --- a/src/render.rs +++ b/src/render.rs @@ -22,6 +22,7 @@ impl ProfileRenderData { name: "nostrich".to_string(), display_name: None, about: "A am a nosy nostrich".to_string(), + pfp_url: "https://damus.io/img/no-profile.svg".to_owned(), pfp: pfp, } } @@ -31,12 +32,14 @@ impl ProfileRenderData { pub struct NoteData { pub id: Option<[u8; 32]>, pub content: String, + pub timestamp: u64, } pub struct ProfileRenderData { pub name: String, pub display_name: Option, pub about: String, + pub pfp_url: String, pub pfp: egui::ImageData, } @@ -97,7 +100,12 @@ impl From for EventSource { impl NoteData { fn default() -> Self { let content = "".to_string(); - NoteData { content, id: None } + let timestamp = 0; + NoteData { + content, + timestamp, + id: None, + } } } @@ -188,11 +196,13 @@ fn get_profile_render_data( let about = profile.about().unwrap_or("").to_string(); let display_name = profile.display_name().as_ref().map(|a| a.to_string()); let pfp = app.default_pfp.clone(); + let pfp_url = "https://damus.io/img/no-profile.svg".to_owned(); Ok(ProfileRenderData { name, pfp, about, + pfp_url, display_name, }) } @@ -200,13 +210,20 @@ fn get_profile_render_data( fn ndb_note_to_data(note: &Note) -> NoteData { let content = note.content().to_string(); let id = Some(*note.id()); - NoteData { content, id } + let timestamp = note.created_at(); + NoteData { + content, + timestamp, + id, + } } fn sdk_note_to_note_data(note: &Event) -> NoteData { let content = note.content.clone(); + let timestamp = note.created_at.as_u64(); NoteData { content, + timestamp, id: Some(note.id.to_bytes()), } }