aboutsummaryrefslogtreecommitdiff
path: root/src/macros.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-27 01:17:32 -0700
committerFuwn <[email protected]>2022-04-27 01:17:32 -0700
commitc81eab0c3b4fa8d8433505bd3d061f8de8e87d74 (patch)
tree09451b5ebec415295d63504e9eaffecb37277a68 /src/macros.rs
parentrefactor(modules): move search out of module (diff)
downloadlocus-c81eab0c3b4fa8d8433505bd3d061f8de8e87d74.tar.xz
locus-c81eab0c3b4fa8d8433505bd3d061f8de8e87d74.zip
refactor: restrict more
Diffstat (limited to 'src/macros.rs')
-rw-r--r--src/macros.rs16
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(