diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-04-14T20·06+0200 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2018-04-14T20·21+0200 |
commit | 4132869277656437f1f62869a2b1676d4c1c42d7 (patch) | |
tree | 6ee6a8302e4712bc8aca47e8c021063ad338b0bf /src/render.rs | |
parent | dae97fdaf5a9541895d9719f1f58902cca846e2b (diff) |
feat: Implement search result view & enable search
Implements a very simple and currently kinda broken-looking search result view.
Diffstat (limited to 'src/render.rs')
-rw-r--r-- | src/render.rs | 21 |
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)?) + } +} |