diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/macros.rs | 24 | ||||
| -rw-r--r-- | src/main.rs | 9 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/macros.rs b/src/macros.rs index 9104f39..4882475 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -24,11 +24,16 @@ macro_rules! mount_page { Box::new(|context| { Response::Success( Main { - body: include_str!(concat!("../content/pages/", $file, ".gmi")) - .into(), - hits: &crate::hits_from_route(context.url.path()), - quote: QUOTES.choose(&mut rand::thread_rng()).unwrap(), - commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), + body: include_str!(concat!( + "../content/pages/", + $file, + ".gmi" + )) + .into(), + hits: &crate::hits_from_route(context.url.path()), + quote: QUOTES.choose(&mut rand::thread_rng()).unwrap(), + commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), + mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"), } .to_string(), ) @@ -57,10 +62,11 @@ macro_rules! success { ($body:expr, $context:ident) => { Response::Success( Main { - body: &$body, - hits: &crate::hits_from_route($context.url.path()), - quote: QUOTES.choose(&mut rand::thread_rng()).unwrap(), - commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), + body: &$body, + hits: &crate::hits_from_route($context.url.path()), + quote: QUOTES.choose(&mut rand::thread_rng()).unwrap(), + commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), + mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"), } .to_string(), ) diff --git a/src/main.rs b/src/main.rs index bd58794..ff9fbbf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,10 +65,11 @@ static DATABASE: SyncLazy<Mutex<PickleDb>> = SyncLazy::new(|| { #[derive(Template)] #[template(path = "main")] struct Main<'a> { - body: &'a str, - hits: &'a i32, - quote: &'a str, - commit: &'a str, + body: &'a str, + hits: &'a i32, + quote: &'a str, + commit: &'a str, + mini_commit: &'a str, } fn hits_from_route(route: &str) -> i32 { |