~/selfhut

selfhut/src/repository/raw.rs -rw-r--r-- 855 B
7dbdfabf — arthurmelton I did alot, I should have commited more 2 years ago

            
00c0a257 Arthur Melton
7dbdfabf arthurmelton
616316d3 Arthur Melton
00c0a257 Arthur Melton
7dbdfabf arthurmelton
19f9b68c arthurmelton
00c0a257 Arthur Melton
7dbdfabf 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
use rocket_dyn_templates::{context, Template};
use crate::config::CONFIG;
use crate::utils::repo_config::repo_config;
use crate::git::commits::get_commits;
use crate::git::main_branch::main_branch;
use crate::git::file::{files, file};
use crate::PathBufWithDotfiles;
use std::ffi::OsStr;
use syntect::easy::HighlightLines;
use syntect::parsing::SyntaxSet;
use syntect::highlighting::{ThemeSet, Style};
use syntect::util::LinesWithEndings;
use syntect::html::highlighted_html_for_string;
use std::path::Path;

#[get("/<repo>/blob/<branch>/<location..>", rank=2)]
pub fn raw(repo: String, branch: String, location: PathBufWithDotfiles) -> Option<Vec<u8>> {
    match file(repo.clone(), branch.clone(), location.get().display().to_string()) {
        Some(file) => {
            Some(file.2) 
        },
        None => { 
            None
        }
    }
}