aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs
index dd5fea0..0710d40 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,19 +1,13 @@
+use std::ops::Deref;
use std::path::Path;
-use askama::Template;
use async_std::sync::{Arc, Mutex};
use eyre::Result;
use tide::prelude::*;
mod state;
+mod templates;
use state::State;
-use std::ops::Deref;
-
-#[derive(Template)]
-#[template(path = "index.html")]
-struct IndexTemplate<'a> {
- state: &'a State,
-}
#[async_std::main]
async fn main() -> Result<()> {
@@ -52,7 +46,7 @@ type Request = tide::Request<Arc<Mutex<State>>>;
async fn index(req: Request) -> tide::Result {
let state = req.state();
let state = state.lock_arc().await;
- Ok(IndexTemplate { state: state.deref() }.into())
+ Ok(templates::Index { state: state.deref() }.into())
}
async fn about(req: Request) -> tide::Result {
@@ -96,10 +90,6 @@ async fn about(req: Request) -> tide::Result {
Err(_) => return Ok("somehow that README wasn't a file".into()),
};
- let body = if head_readme_blob.is_binary() {
- tide::Body::from(head_readme_blob.content())
- } else {
- tide::Body::from(String::from_utf8_lossy(head_readme_blob.content()).into_owned())
- };
- Ok(body.into())
+ let readme = String::from_utf8_lossy(head_readme_blob.content());
+ Ok(templates::About { path: repo_rel_path, readme }.into())
}