diff options
| author | Fuwn <[email protected]> | 2022-04-27 01:17:32 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-04-27 01:17:32 -0700 |
| commit | c81eab0c3b4fa8d8433505bd3d061f8de8e87d74 (patch) | |
| tree | 09451b5ebec415295d63504e9eaffecb37277a68 /src/macros.rs | |
| parent | refactor(modules): move search out of module (diff) | |
| download | locus-c81eab0c3b4fa8d8433505bd3d061f8de8e87d74.tar.xz locus-c81eab0c3b4fa8d8433505bd3d061f8de8e87d74.zip | |
refactor: restrict more
Diffstat (limited to 'src/macros.rs')
| -rw-r--r-- | src/macros.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/macros.rs b/src/macros.rs index c36a41f..3ac6463 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -22,13 +22,23 @@ pub static QUOTES: SyncLazy<Vec<String>> = SyncLazy::new(|| { serde_json::from_str(include_str!("../content/json/quotes.json")).unwrap() }); +#[derive(yarte::Template)] +#[template(path = "main")] +pub struct Main<'a> { + pub body: &'a str, + pub hits: &'a i32, + pub quote: &'a str, + pub commit: &'a str, + pub mini_commit: &'a str, +} + #[macro_export] macro_rules! success { ($body:expr, $context:ident) => {{ $crate::route::cache(&$context, &$body); windmark::Response::Success( - $crate::Main { + $crate::macros::Main { body: &$body, hits: &$crate::route::hits_from($context.url.path()), quote: { @@ -50,7 +60,7 @@ macro_rules! success { #[macro_export] macro_rules! mount_page { ($router:ident, $at:literal, $description:literal, $file:literal) => { - (*$crate::ROUTES.lock().unwrap()) + (*$crate::route::ROUTES.lock().unwrap()) .insert($at.to_string(), $crate::route::Route::new($description)); ($router).mount( @@ -69,7 +79,7 @@ macro_rules! mount_page { #[macro_export] macro_rules! mount_file { ($router:ident, $at:literal, $description:literal, $file:literal) => { - (*$crate::ROUTES.lock().unwrap()) + (*$crate::route::ROUTES.lock().unwrap()) .insert($at.to_string(), $crate::route::Route::new($description)); ($router).mount( |