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.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/render.rs b/src/render.rs
index 186b96d247c0..537cab59daef 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -175,3 +175,24 @@ impl Handler<NewThreadPage> for Renderer {
         Ok(self.tera.render("new-thread.html", &ctx)?)
     }
 }
+
+/// Message used to render search results
+pub struct SearchResultPage {
+    pub query: String,
+    pub results: Vec<SearchResult>,
+}
+
+impl Message for SearchResultPage {
+    type Result = Result<String>;
+}
+
+impl Handler<SearchResultPage> for Renderer {
+    type Result = Result<String>;
+
+    fn handle(&mut self, msg: SearchResultPage, _: &mut Self::Context) -> Self::Result {
+        let mut ctx = Context::new();
+        ctx.add("query", &msg.query);
+        ctx.add("results", &msg.results);
+        Ok(self.tera.render("search.html", &ctx)?)
+    }
+}