index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat (limited to 'src/routes/repository/about.rs')

-rw-r--r-- src/routes/repository/about.rs 30
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/src/routes/repository/about.rs b/src/routes/repository/about.rs
index 47ad299..cc5c448 100644
--- a/src/routes/repository/about.rs
+++ b/src/routes/repository/about.rs
@@ -15,35 +15,17 @@
    path: web::Path<String>,
    query: web::Query<PageQuery>,
    data: web::Data<App>,
) -> ActixResult<HttpResponse> {
    let name = path.into_inner();
    let repo = match data.find_repo(name) {
        Some(r) => r,
        None => return Ok(HttpResponse::NotFound().body("Repo not found")),
    };

    let current_ref = match Ref::resolve(&repo, &query) {
        Ok(r) => r,
        Err(e) => return Ok(HttpResponse::InternalServerError().body(e.to_string())),
    };
    let branch_names = match repo.branch_names() {
        Ok(b) => b,
        Err(e) => return Ok(HttpResponse::InternalServerError().body(e.to_string())),
    };

) -> Result<HttpResponse, Error> {
    let repo = data.get_repo(&path)?;
    let current_ref = Ref::resolve(&repo, &query)?;
    let branch_names = repo.branch_names()?;
    let readme_html = repo.readme().map(|raw| markdown::render(&raw));

    let rendered = AboutPage {
    render_html(&AboutPage {
        repo,
        current_ref,
        branch_names,
        readme_html,
        query,
    }
    .render();

    match rendered {
        Ok(html) => Ok(HttpResponse::Ok().content_type("text/html").body(html)),
        Err(e) => Ok(HttpResponse::InternalServerError().body(e.to_string())),
    }
    })
}