diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-22 06:44:04 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-22 06:44:04 -0600 |
commit | 7620dd41ca41cf4fb445d6a6e9afe2607ed77a95 (patch) | |
tree | 7dbe0decfae17563886418ef653d5461c57e51cb /src/templates.rs | |
parent | 1fc46e3c0bd0075f6ca9eeb50eecad10dbf767b8 (diff) | |
download | gityeet-7620dd41ca41cf4fb445d6a6e9afe2607ed77a95.tar.gz gityeet-7620dd41ca41cf4fb445d6a6e9afe2607ed77a95.zip |
actually handle subfolders
Diffstat (limited to 'src/templates.rs')
-rw-r--r-- | src/templates.rs | 17 |
1 files changed, 11 insertions, 6 deletions
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<String> { + Ok(String::from_utf8_lossy(utf8).into_owned()) + } + pub fn markdown(s: &str) -> ::askama::Result<String> { use pulldown_cmark::{Parser, Options, html}; |