From e30713b84bc9e66f7a8e8d2f51e953472cac28e4 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Mon, 22 Jun 2020 06:23:04 +0200 Subject: Committing all the libgit2 progress before throwing it away I don't think libgit2 is the way forward to make any of this work. There's so much work involved in parsing the git k-v store, and the library itself is essentially of zero help for most of the heavy lifting. --- src/main.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 6d0ef79..7e589ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,36 @@ +mod git; mod pages; mod repo; -// mod router; -mod types; +mod templ_data; use actix_files as fs; -use actix_web::{web, App, HttpServer}; +use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer}; use std::io; use std::path::PathBuf; #[actix_rt::main] async fn main() -> io::Result<()> { - std::env::set_var("RUST_LOG", "actix_web=info"); + std::env::set_var("RUST_LOG", "actix_server=info,octopus=debug"); env_logger::init(); let root = PathBuf::new(); + let repo = git::repo::Repo::new("."); + let commits = git::log::create_commit_log( + "84a9a0ccee713e26a28ff5e54ea3776085d93b5f".into(), + &repo.inner, + ); + HttpServer::new(move || { App::new() .service(fs::Files::new("/static", root.join("static"))) + // This is a bit of a hack so that people don't get the + // 404 on the root page. Especially as long as octopus + // doesn't have the account overview yet! + .service(web::resource("/").route(web::get().to(|_: HttpRequest| { + HttpResponse::PermanentRedirect() + .header("Location", "octopus") + .finish() + }))) .service(web::resource("/{repo}").route(web::get().to(pages::repo::about))) .service(web::resource("/{repo}/details").route(web::get().to(pages::repo::details))) .default_service(web::resource("").route(web::get().to(pages::p404))) -- cgit v1.2.3