Repositories

grarr

(mirrored on github)

Modified build.rs

@@ -1,5 +1,32 @@
use std::env;
use std::io::Write;
use std::fs::File;
use std::path::Path;
use std::process::Command;
fn main() {
if let Ok("release") = std::env::var("PROFILE").as_ref().map(|s| &**s) {
if let Ok("release") = env::var("PROFILE").as_ref().map(|s| &**s) {
println!("cargo:rustc-cfg=feature=\"cache\"");
}
let rev = if let Ok(output) = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output() {
format!("Some(\"{}\")", String::from_utf8_lossy(&output.stdout).trim())
} else {
"None".to_owned()
};
let date = if let Ok(output) = Command::new("date").arg("+%F").output() {
format!("Some(\"{}\")", String::from_utf8_lossy(&output.stdout).trim())
} else {
"None".to_owned()
};
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("version.rs");
let mut f = File::create(&dest_path).unwrap();
f.write_all(format!("
static REVISION: Option<&'static str> = {};
static DATE: Option<&'static str> = {};
", rev, date).as_bytes()).unwrap();
}

Modified src/main.rs

@@ -55,6 +55,8 @@ use repository_context::inject_repository_context;
pub use repository_context::RepositoryContext;
pub use repository_extension::RepositoryExtension;
include!(concat!(env!("OUT_DIR"), "/version.rs"));
fn main() {
let root = env::args().nth(1).unwrap();

Modified src/render/about.rs

@@ -1,3 +1,4 @@
use { REVISION, DATE };
use maud_pulldown_cmark::Markdown;
renderers! {
@@ -8,5 +9,20 @@ renderers! {
^Markdown::from_string(include_str!("../../README.md"))
}
}
div.block {
div.block-header h3 "Version"
div.block-details {
"Website generated using "
a href="https://git.nemo157.com/grarr" "grarr"
" version "
^(env!("CARGO_PKG_VERSION"))
@match (REVISION, DATE) {
(Some(rev), None) => " (" a href={ "https://git.nemo157.com/grarr/commits/" ^rev } ^rev ")",
(None, Some(date)) => " (" ^date ")",
(Some(rev), Some(date)) => " (" a href={ "https://git.nemo157.com/grarr/commits/" ^rev } ^rev " " ^date ")",
(None, None) => {},
}
}
}
}
}