~/selfhut

selfhut/src/repository/summary.rs -rw-r--r-- 1.26 kB
468a751a — Arthur Melton mailing_list option 2 years ago

            
ef55c0da arthurmelton
00c0a257 Arthur Melton
616316d3 Arthur Melton
ef55c0da arthurmelton
00c0a257 Arthur Melton
ef55c0da arthurmelton
00c0a257 Arthur Melton
ef55c0da arthurmelton
0f44ce25 Arthur Melton
ef55c0da arthurmelton
00c0a257 Arthur Melton
144cd6f8 arthurmelton
00c0a257 Arthur Melton
5ec2ce6e Arthur Melton
00c0a257 Arthur Melton
0016c2cc arthurmelton
00c0a257 Arthur Melton
468a751a Arthur Melton
00c0a257 Arthur Melton
ef55c0da arthurmelton















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
36
37
use crate::config::CONFIG;
use rocket_dyn_templates::{context, Template};

use crate::git::commits::get_commits;
use crate::git::file::file;
use crate::git::main_branch::main_branch;
use crate::git::tag::get_tag;
use crate::utils::markdown::md_to_html;
use crate::utils::repo_config::repo_config;

#[get("/<repo>")]
pub fn repository(repo: String) -> Option<Template> {
    let main_branch = main_branch(repo.clone())?;
    let file = file(repo.clone(), main_branch.clone(), "README.md".to_string())?;
    Some(Template::render(
        "repository/summary",
        context! {
            title: repo.clone(),
            repo: repo.clone(),
            config: repo_config(repo.clone()),
            domain: CONFIG.domain.to_string(),
            readme: md_to_html(&file.1?),
            active: "summary",
            preview: get_commits(repo.clone(), 3, None, None),
            main_branch,
            tag: match get_tag(repo.clone(), 1) {
                Some(x) => match x.get(0) {
                    Some(x) => Some(x.clone()),
                    None => None
                },
                None => None
            },
            payment: CONFIG.payment_link.clone(),
            mailing_list: CONFIG.mailing_list.clone()
        },
    ))
}