You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
861 B
33 lines
861 B
//! 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))
|
|
}
|
|
|