diff --git a/Cargo.lock b/Cargo.lock index 7c2ca10..7bcbca8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,6 +276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "md-pdf" version = "0.1.0" dependencies = [ + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)", "include_dir 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "mktemp 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 5d8b3ac..4eadad7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ serde_yaml = "0.7.1" wkhtmltopdf = "0.3.0" zip = "0.2.6" tera = "0.10.10" +chrono = "0.4.0" [build-dependencies] include_dir = "0.1.3" diff --git a/src/main.rs b/src/main.rs index 2669cdb..ba0e9da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ extern crate sciter; extern crate zip; extern crate mktemp; extern crate tera; +extern crate chrono; use std::io::{self, Write}; use std::process::exit; diff --git a/src/templating.rs b/src/templating.rs index c668c72..11a0f7a 100644 --- a/src/templating.rs +++ b/src/templating.rs @@ -1,12 +1,16 @@ use tera::{Tera, Context}; use config::Config; use tera::Result; +use chrono::{Local, DateTime}; const TEMP_TEMPLATE_FILENAME: &str = "index.html"; fn build_context(config: &Config) -> Context { let mut context = Context::new(); + let now: DateTime = Local::now(); context.add("config", &config); + context.add("now", &now.to_rfc3339()); + context.add("version", &String::from(crate_version!())); return context; }