aboutsummaryrefslogtreecommitdiff
path: root/src/pages/repo/about.rs
blob: 8797edd20503659b685b07bb3f4fbb057afd0d63 (plain)
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
34
35
use actix_web::{web, HttpRequest, HttpResponse, Result};
use askama::Template;

#[derive(Template)]
#[template(path = "repo.html")]
struct Repo<'a> {
    project_owner: &'a str,
    project_summary: &'a str,
    project_name: &'a str,
    project_logo: &'a str,
    project_logo_alt_text: &'a str,
    first_commit: &'a str,
    num_commits: usize,
    num_contributors: usize,
}

/// Renders the "repository/about" subpage
pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> {
    println!("Rendering path: {:#?}", path);
    dbg!(req);

    let repo = Repo {
        project_owner: "spacekookie",
        project_summary: "A lightweight web frontend for git repositories",
        project_name: "webgit",
        project_logo: "rust.png",
        project_logo_alt_text: "Rust logo",
        first_commit: "f6ca929",
        num_commits: 123,
        num_contributors: 3,
    }
    .render()
    .unwrap();
    Ok(HttpResponse::Ok().content_type("text/html").body(repo))
}