diff --git a/src/render.rs b/src/render.rs index cbcf3fa..a029320 100644 --- a/src/render.rs +++ b/src/render.rs @@ -7,18 +7,30 @@ pub const DEFAULT_TEMPLATE: &str = r#" {{title}} -

guestbook

- {{form}} - {{entries}} +
+{{title}}
+
+guestbook
+=========
+
+{{form}}
+
+entries
+=======
+{{entries}}
+
"#; @@ -40,27 +52,32 @@ fn render_entries(entries: &[Entry]) -> String { } fn render_entry(entry: &Entry) -> String { - let mut header = format!( - "
\n

{} - {}", - entry.meta.date, entry.meta.name - ); + let mut header = format!("{} - {}", entry.meta.date, entry.meta.name); if !entry.meta.website.is_empty() { header.push_str(&format!( " ({})", entry.meta.website, entry.meta.website )); } - header.push_str("

\n"); - format!("{header} {}\n
\n", entry.body) + format!( + "\n{header}\n\n{}\n\n------------------------------------------------------------\n", + entry.body + ) } -pub const FORM_HTML: &str = r#"
- - - - - -
"#; +pub const FORM_HTML: &str = r#"If you visited my site, please sign my guestbook! +
+Your name: + + +Your website (optional): + + +Your message: + + + +
"#; #[cfg(test)] mod tests { @@ -85,6 +102,7 @@ mod tests { let html = render_page(DEFAULT_TEMPLATE, "ily.rs", &[], FORM_HTML); assert!(html.contains("ily.rs")); assert!(html.contains("action=\"/submit\"")); + assert!(html.contains("
"));
     }
 
     #[test]
@@ -99,9 +117,9 @@ mod tests {
     fn test_render_entry_no_website() {
         let entry = make_entry("alice", "2026-04-09", "Hello!");
         let html = render_page(DEFAULT_TEMPLATE, "test", &[entry], FORM_HTML);
-        assert!(html.contains("alice"));
+        assert!(html.contains("2026-04-09 - alice"));
         assert!(html.contains("Hello!"));
-        assert!(!html.contains("
+
+
+  
+  
+  {{title}}
+  
+
+
+
+{{title}}
+
+guestbook
+=========
+
+{{form}}
+
+entries
+=======
+{{entries}}
+
+ +