diff options
author | metamuffin <metamuffin@disroot.org> | 2022-08-30 00:03:37 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-08-30 00:03:37 +0200 |
commit | 525baabe876c047a7367dae1f954148a52f190bc (patch) | |
tree | 005981e4773197075a17cfc1729c08284492f0a2 /code/src/main.rs | |
parent | 9fba4dc45d7319d03584fe10ead95d0ff7974234 (diff) | |
download | metamuffin-blog-525baabe876c047a7367dae1f954148a52f190bc.tar metamuffin-blog-525baabe876c047a7367dae1f954148a52f190bc.tar.bz2 metamuffin-blog-525baabe876c047a7367dae1f954148a52f190bc.tar.zst |
code block formatting
Diffstat (limited to 'code/src/main.rs')
-rw-r--r-- | code/src/main.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/code/src/main.rs b/code/src/main.rs index 83bcefe..0bd0169 100644 --- a/code/src/main.rs +++ b/code/src/main.rs @@ -10,6 +10,7 @@ use std::{ fs::File, io::{BufRead, BufReader, Write}, path::PathBuf, + process::{Command, Stdio}, }; pub const BLOG_BASE: &'static str = "s.metamuffin.org/temp/blog-preview"; @@ -72,11 +73,22 @@ pub fn get_articles(root: &str) -> Vec<ArticleMeta> { a } +pub fn file_history(filename: &str) -> String { + String::from_utf8( + Command::new("/usr/bin/git") + .args(&["log", "--follow", "--pretty=tformat:%as %h %s", filename]) + .stdout(Stdio::piped()) + .output() + .unwrap() + .stdout, + ) + .unwrap() +} + pub struct ArticleMeta { title: String, canonical_name: String, date: iso8601::Date, - path: PathBuf, } fn article_metadata(path: PathBuf) -> ArticleMeta { let f = File::open(&path).unwrap(); @@ -87,6 +99,5 @@ fn article_metadata(path: PathBuf) -> ArticleMeta { title: String::from(buf[2..].trim()), canonical_name: path.file_stem().unwrap().to_str().unwrap().to_string(), date: iso8601::date(&path.file_name().unwrap().to_str().unwrap()[0..10]).unwrap(), - path, } } |