aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-19 23:24:10 -0700
committerFuwn <[email protected]>2022-04-19 23:24:10 -0700
commit817688de7b5b0ae1f2d06791569dd708164cabd6 (patch)
treeaca46dbe0a90a1314354f77f212d10af7685cfea /src/modules
parentrefactor(modules): move modules to module (diff)
downloadlocus-817688de7b5b0ae1f2d06791569dd708164cabd6.tar.xz
locus-817688de7b5b0ae1f2d06791569dd708164cabd6.zip
refactor(modules): move sitemap to modules module
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/mod.rs1
-rw-r--r--src/modules/multi_blog.rs6
-rw-r--r--src/modules/sitemap.rs38
3 files changed, 41 insertions, 4 deletions
diff --git a/src/modules/mod.rs b/src/modules/mod.rs
index bab3cb1..b24e0ab 100644
--- a/src/modules/mod.rs
+++ b/src/modules/mod.rs
@@ -17,3 +17,4 @@
// SPDX-License-Identifier: GPL-3.0-only
pub mod multi_blog;
+pub mod sitemap;
diff --git a/src/modules/multi_blog.rs b/src/modules/multi_blog.rs
index 4831493..3278e13 100644
--- a/src/modules/multi_blog.rs
+++ b/src/modules/multi_blog.rs
@@ -22,12 +22,10 @@ use std::{
io::Read,
};
-use windmark::Response;
-
-use crate::{success, track_mount, Main};
+use crate::{success, track_mount};
#[allow(clippy::too_many_lines)]
-pub fn multi_blog(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::Router) {
let paths = read_dir("content/pages/blog").unwrap();
let mut blogs: HashMap<String, HashMap<_, _>> = HashMap::new();
diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs
new file mode 100644
index 0000000..7e190aa
--- /dev/null
+++ b/src/modules/sitemap.rs
@@ -0,0 +1,38 @@
+// 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 fn module(router: &mut windmark::Router) {
+ crate::track_mount(
+ router,
+ "/sitemap",
+ "A map of all publicly available routes on this Gemini capsule",
+ Box::new(|context| {
+ crate::success!(
+ format!(
+ "# SITEMAP\n\n{}",
+ (*crate::ROUTES.lock().unwrap())
+ .iter()
+ .map(|(r, d)| format!("=> {} {}", r, d.description))
+ .collect::<Vec<_>>()
+ .join("\n")
+ ),
+ context
+ )
+ }),
+ );
+}