about summary refs log tree commit diff
path: root/src/render.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/render.rs')
-rw-r--r--src/render.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/render.rs b/src/render.rs
index c0a2fe88e697..e02ac31ea98c 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -200,7 +200,7 @@ impl Handler<NewThreadPage> for Renderer {
     type Result = Result<String>;
 
     fn handle(&mut self, msg: NewThreadPage, _: &mut Self::Context) -> Self::Result {
-        let ctx: FormContext = FormContext {
+        let ctx = FormContext {
             alerts: msg.alerts,
             title: msg.title,
             post: msg.post,
@@ -210,6 +210,28 @@ impl Handler<NewThreadPage> for Renderer {
     }
 }
 
+/// Message used to render post editing page.
+pub struct EditPostPage {
+    pub id: i32,
+    pub post: String,
+}
+message!(EditPostPage, Result<String>);
+
+impl Handler<EditPostPage> for Renderer {
+    type Result = Result<String>;
+
+    fn handle(&mut self, msg: EditPostPage, _: &mut Self::Context) -> Self::Result {
+        let ctx = FormContext {
+            mode: EditingMode::EditPost,
+            id: Some(msg.id),
+            post: Some(msg.post),
+            ..Default::default()
+        };
+
+        Ok(self.tera.render("post.html", &ctx)?)
+    }
+}
+
 /// Message used to render search results
 #[derive(Serialize)]
 pub struct SearchResultPage {