aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-19 23:17:52 -0700
committerFuwn <[email protected]>2022-04-19 23:17:52 -0700
commit784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5 (patch)
tree3d8dd3b0e562bac1becc3ccd70835259be34765f
parentfix(docker): permissions, cba (diff)
downloadlocus-784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5.tar.xz
locus-784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5.zip
refactor(modules): move modules to module
-rw-r--r--src/macros.rs15
-rw-r--r--src/main.rs2
-rw-r--r--src/modules/mod.rs19
-rw-r--r--src/modules/multi_blog.rs (renamed from src/modules.rs)0
4 files changed, 30 insertions, 6 deletions
diff --git a/src/macros.rs b/src/macros.rs
index bfaf9c2..7dd6048 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -16,6 +16,12 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+use std::lazy::SyncLazy;
+
+pub static QUOTES: SyncLazy<Vec<String>> = SyncLazy::new(|| {
+ serde_json::from_str(include_str!("../content/json/quotes.json")).unwrap()
+});
+
#[macro_export]
macro_rules! success {
($body:expr, $context:ident) => {{
@@ -28,11 +34,10 @@ macro_rules! success {
quote: {
use rand::seq::SliceRandom;
- let quotes: Vec<String> =
- serde_json::from_str(include_str!("../content/json/quotes.json"))
- .unwrap();
-
- &quotes.choose(&mut rand::thread_rng()).unwrap().to_string()
+ &$crate::macros::QUOTES
+ .choose(&mut rand::thread_rng())
+ .unwrap()
+ .to_string()
},
commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")),
mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"),
diff --git a/src/main.rs b/src/main.rs
index 044002e..bb17767 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -303,7 +303,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
);
time_mount = Instant::now();
- router.attach_stateless(modules::multi_blog);
+ router.attach_stateless(modules::multi_blog::multi_blog);
info!(
"blog mounts took {}ms",
diff --git a/src/modules/mod.rs b/src/modules/mod.rs
new file mode 100644
index 0000000..bab3cb1
--- /dev/null
+++ b/src/modules/mod.rs
@@ -0,0 +1,19 @@
+// This file is part of Locus <https://github.com/gemrest/locus>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-only
+
+pub mod multi_blog;
diff --git a/src/modules.rs b/src/modules/multi_blog.rs
index 4831493..4831493 100644
--- a/src/modules.rs
+++ b/src/modules/multi_blog.rs