~/selfhut

0f44ce257e0299b6b82cdfb384c656be30a71b71 — Arthur Melton 50967860 2 years ago
read readme from main branch
1 files changed, 5 insertions(+), 9 deletions(-)

M src/repository/summary.rs
M src/repository/summary.rs => src/repository/summary.rs +5 -9
@@ 6,16 6,12 @@ use crate::utils::repo_config::repo_config;

use crate::git::commits::get_commits;
use crate::git::main_branch::main_branch;
use crate::git::tag::get_tag;
use crate::git::file::file;

#[get("/<repo>")]
pub fn repository(repo: String) -> Option<Template> {
    let mut readme = CONFIG.git_location.clone();
    readme.push(format!("{}.git", repo));
    readme.push("README.md");
    let readme_string = match fs::read(readme) {
        Ok(content) => String::from_utf8_lossy(&content).parse().unwrap_or("".to_string()),
        Err(_) => "".to_string()
    };
    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! {

@@ 23,10 19,10 @@ pub fn repository(repo: String) -> Option<Template> {

                repo: repo.clone(),
                config: repo_config(repo.clone()),
                domain: CONFIG.domain.to_string(),
                readme: md_to_html(&readme_string),
                readme: md_to_html(&file.1?),
                active: "summary",
                preview: get_commits(repo.clone(), 3, None),
                main_branch: main_branch(repo.clone()),
                main_branch,
                tag: match get_tag(repo.clone(), 1) {
                    Some(x) => match x.get(0) {
                        Some(x) => Some(x.clone()),