aboutsummaryrefslogtreecommitdiff
path: root/src/pages/repo/about.rs
blob: fa88eb10c2e4cce8232e4f13c4075c94c5f028e6 (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 super::RepoWrapper;
use crate::types::RepoData;
use actix_web::{web, HttpRequest, HttpResponse, Result};
use askama::Template;

#[derive(Template)]
#[template(path = "repo/about.html")]
struct AboutRepo {
    repo: RepoWrapper,
    readme: String,
}

/// Renders the "repository/about" subpage
pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> {
    let repo = AboutRepo {
        readme: include_str!("../../../README").to_string(),
        repo: RepoWrapper {
            data: RepoData {
                owner: "spacekookie".into(),
                name: "octopus".into(),
                tagline: "A lightweight web frontend for git repositories".into(),
                num_commit: 141,
                num_branch: 1,
                num_tag: 0,
                num_contributor: 3,
                size: "13.12M".into(),
            },
            logo: "fakeavi.png".into(),
        },
    }
    .render()
    .unwrap();

    Ok(HttpResponse::Ok().content_type("text/html").body(repo))
}