about summary refs log tree commit diff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/src/lib.rs67
1 files changed, 62 insertions, 5 deletions
diff --git a/templates/src/lib.rs b/templates/src/lib.rs
index 01c69ab..f21ffb3 100644
--- a/templates/src/lib.rs
+++ b/templates/src/lib.rs
@@ -59,8 +59,7 @@ mod tests {
                     "properties": {
                         "content": [html(content)],
                         "published": [dt],
-                        "uid": [&uid],
-                        "url": [&uid],
+                        "uid": [&uid], "url": [&uid],
                         "author": [gen_hcard(domain)]
                     }
                 })
@@ -74,14 +73,68 @@ mod tests {
                     "properties": {
                         "content": [html(content)],
                         "published": [dt],
-                        "uid": [&uid],
-                        "url": [&uid],
+                        "uid": [&uid], "url": [&uid],
                         "author": [gen_hcard(domain)],
                         "name": [name.to_string()]
                     }
                 })
             }
-            _ => todo!()
+            PostType::ReplyTo(ctx) => {
+                let content = rand::random::<Paragraph>();
+
+                json!({
+                    "type": ["h-entry"],
+                    "properties": {
+                        "content": [html(content)],
+                        "published": [dt],
+                        "uid": [&uid], "url": [&uid],
+                        "author": [gen_hcard(domain)],
+                        "in-reply-to": [{
+                            "type": ["h-cite"],
+                            "properties": ctx["properties"]
+                        }]
+                    }
+                })
+            },
+            PostType::ReplyToLink(link) => {
+                let content = rand::random::<Paragraph>();
+
+                json!({
+                    "type": ["h-entry"],
+                    "properties": {
+                        "content": [html(content)],
+                        "published": [dt],
+                        "uid": [&uid], "url": [&uid],
+                        "author": [gen_hcard(domain)],
+                        "in-reply-to": [link]
+                    }
+                })
+            },
+            PostType::LikeOf(ctx) => {
+                json!({
+                    "type": ["h-entry"],
+                    "properties": {
+                        "published": [dt],
+                        "author": [gen_hcard(domain)],
+                        "uid": [&uid], "url": [&uid],
+                        "like-of": [{
+                            "type": ["h-cite"],
+                            "properties": ctx["properties"]
+                        }]
+                    }
+                })
+            },
+            PostType::LikeOfLink(link) => {
+                json!({
+                    "type": ["h-entry"],
+                    "properties": {
+                        "published": [dt],
+                        "author": [gen_hcard(domain)],
+                        "uid": [&uid], "url": [&uid],
+                        "like-of": [link]
+                    }
+                })
+            }
         }
     }
 
@@ -129,6 +182,10 @@ mod tests {
             {
                 use chrono::{DateTime, FixedOffset, NaiveDateTime};
 
+                // Faithfully reconstruct the original datetime
+                // I wonder why not just have an Enum that would
+                // get you either date, time or a datetime,
+                // potentially with an offset?
                 let offset = item.as_offset().unwrap().data;
                 let ndt: NaiveDateTime = item.as_date().unwrap().data
                     .and_time(item.as_time().unwrap().data)