1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//! The main file browser
use crate::{
git,
templ_data::{files::Files, BaseData},
};
use actix_web::{web, HttpRequest, HttpResponse, Result};
use askama::Template;
pub async fn render((req, path): (HttpRequest, web::Path<String>)) -> Result<HttpResponse> {
let repo = git::open();
let branch = repo.get_branch("main".into()).unwrap(); // FIXME: this is baaaaad
let head = branch.get_head();
let tree = head.get_tree();
debug!("Loading path: `{}`", path);
let _yield = tree.load(&path).unwrap();
debug!("{:#?}", _yield);
let files = Files {
base: BaseData {
sitename: "dev.spacekookie.de".into(),
..BaseData::default()
},
readme: None,
path: "/".into(),
}
.render()
.unwrap();
Ok(HttpResponse::Ok().content_type("text/html").body(files))
}
|