diff options
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, } } |