From 7620dd41ca41cf4fb445d6a6e9afe2607ed77a95 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 06:44:04 -0600 Subject: actually handle subfolders --- src/templates.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/templates.rs') diff --git a/src/templates.rs b/src/templates.rs index bb285fa..257c41e 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -1,5 +1,3 @@ -use std::borrow::Cow; - use askama::Template; use crate::state::State; @@ -11,13 +9,20 @@ pub struct Index<'a> { } #[derive(Template)] -#[template(path = "about.html")] -pub struct About<'a> { - pub path: &'a str, - pub readme: Cow<'a, str>, +#[template(path = "repo_folder.html")] +pub struct RepoFolder<'a> { + pub repo: &'a git2::Repository, + pub repo_path: &'a str, + pub title: &'a str, + pub rel_path: &'a str, + pub tree: git2::Tree<'a>, } mod filters { + pub fn from_utf8_lossy(utf8: &[u8]) -> ::askama::Result { + Ok(String::from_utf8_lossy(utf8).into_owned()) + } + pub fn markdown(s: &str) -> ::askama::Result { use pulldown_cmark::{Parser, Options, html}; -- cgit v1.2.3