aboutsummaryrefslogtreecommitdiff
path: root/src/templates.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-22 05:08:11 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-22 05:08:11 -0600
commit1fc46e3c0bd0075f6ca9eeb50eecad10dbf767b8 (patch)
tree9680e67b5d592fe803981784f9dbc8da3f469717 /src/templates.rs
parent7c0daee1843e36c4c204c653a2ce010e4e0f98b2 (diff)
downloadgityeet-1fc46e3c0bd0075f6ca9eeb50eecad10dbf767b8.tar.gz
gityeet-1fc46e3c0bd0075f6ca9eeb50eecad10dbf767b8.zip
actually render the readme
Diffstat (limited to 'src/templates.rs')
-rw-r--r--src/templates.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/templates.rs b/src/templates.rs
new file mode 100644
index 0000000..bb285fa
--- /dev/null
+++ b/src/templates.rs
@@ -0,0 +1,35 @@
+use std::borrow::Cow;
+
+use askama::Template;
+
+use crate::state::State;
+
+#[derive(Template)]
+#[template(path = "index.html")]
+pub struct Index<'a> {
+ pub state: &'a State,
+}
+
+#[derive(Template)]
+#[template(path = "about.html")]
+pub struct About<'a> {
+ pub path: &'a str,
+ pub readme: Cow<'a, str>,
+}
+
+mod filters {
+ pub fn markdown(s: &str) -> ::askama::Result<String> {
+ use pulldown_cmark::{Parser, Options, html};
+
+ let mut options = Options::empty();
+ options.insert(Options::ENABLE_STRIKETHROUGH);
+ options.insert(Options::ENABLE_SMART_PUNCTUATION);
+ let parser = Parser::new_ext(s, options);
+
+ let mut result = String::new();
+ html::push_html(&mut result, parser);
+
+ // TODO mark as safe automatically
+ Ok(result)
+ }
+}