aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-05-17 02:12:20 -0700
committerFuwn <[email protected]>2023-05-17 02:12:20 -0700
commit0bc4ac8ba3a16aed491c3260d51406685cde2408 (patch)
tree164df292848c8ba9197ffb1607a7fa1ddcad37ed /src
parentchore(tasks): simplify formatter (diff)
downloadlocus-0bc4ac8ba3a16aed491c3260d51406685cde2408.tar.xz
locus-0bc4ac8ba3a16aed491c3260d51406685cde2408.zip
deps(windmark): bump to 0.3.9
Diffstat (limited to 'src')
-rw-r--r--src/main.rs4
-rw-r--r--src/modules/api/sydney.rs4
-rw-r--r--src/modules/blog/module.rs4
-rw-r--r--src/modules/contact.rs2
-rw-r--r--src/modules/cryptocurrency.rs2
-rw-r--r--src/modules/interests.rs2
-rw-r--r--src/modules/random.rs2
-rw-r--r--src/modules/remarks.rs2
-rw-r--r--src/modules/router/module.rs4
-rw-r--r--src/modules/router/translate/module.rs2
-rw-r--r--src/modules/search.rs4
-rw-r--r--src/modules/sitemap.rs2
-rw-r--r--src/modules/skills.rs2
-rw-r--r--src/modules/static.rs2
-rw-r--r--src/modules/stocks.rs4
-rw-r--r--src/modules/uptime.rs4
-rw-r--r--src/modules/web.rs11
-rw-r--r--src/response.rs6
-rw-r--r--src/route.rs4
19 files changed, 34 insertions, 33 deletions
diff --git a/src/main.rs b/src/main.rs
index 19c0cd7..9d623f3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -72,12 +72,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv::dotenv().ok();
let mut time_mount = Instant::now();
- let mut router = windmark::Router::new();
+ let mut router = windmark::router::Router::new();
router.set_private_key_file(".locus/locus_private.pem");
router.set_certificate_file(".locus/locus_public.pem");
router.set_error_handler(|_| {
- windmark::Response::not_found(ERROR_HANDLER_RESPONSE)
+ windmark::response::Response::not_found(ERROR_HANDLER_RESPONSE)
});
router.set_fix_path(true);
diff --git a/src/modules/api/sydney.rs b/src/modules/api/sydney.rs
index e66f91d..6125e59 100644
--- a/src/modules/api/sydney.rs
+++ b/src/modules/api/sydney.rs
@@ -21,7 +21,7 @@ mod tags;
use tags::Tags;
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
crate::route::track_mount(
router,
"/api/sydney/version",
@@ -54,7 +54,7 @@ pub fn module(router: &mut windmark::Router) {
crate::route::cache(&context, &content);
- windmark::Response::success(content)
+ windmark::response::Response::success(content)
.with_mime("text/plain")
.clone()
}
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs
index aad110a..140d918 100644
--- a/src/modules/blog/module.rs
+++ b/src/modules/blog/module.rs
@@ -30,7 +30,7 @@ use crate::{
};
#[allow(clippy::too_many_lines)]
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
let paths = read_dir("content/blogs").unwrap();
let mut blogs: HashMap<String, HashMap<_, _>> = HashMap::new();
@@ -294,7 +294,7 @@ pub fn module(router: &mut windmark::Router) {
&format!("/blog/{fixed_blog_name}.xml"),
&format!("Really Simple Syndication for the {name} blog"),
move |_| {
- windmark::Response::success(xml.to_string())
+ windmark::response::Response::success(xml.to_string())
.with_mime("text/rss+xml")
.clone()
},
diff --git a/src/modules/contact.rs b/src/modules/contact.rs
index 68b8100..c4ba49f 100644
--- a/src/modules/contact.rs
+++ b/src/modules/contact.rs
@@ -25,7 +25,7 @@ static CONTACT_MAP: LazyLock<ContactMap> = LazyLock::new(|| {
.unwrap()
});
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
let mut contacts = CONTACT_MAP
.iter()
.map(|(category, contacts)| {
diff --git a/src/modules/cryptocurrency.rs b/src/modules/cryptocurrency.rs
index 7f9f40c..5ab23ea 100644
--- a/src/modules/cryptocurrency.rs
+++ b/src/modules/cryptocurrency.rs
@@ -36,7 +36,7 @@ struct Referral {
url: String,
}
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
track_mount(
router,
"/cryptocurrency/referrals",
diff --git a/src/modules/interests.rs b/src/modules/interests.rs
index fcb8bf8..4c82fc3 100644
--- a/src/modules/interests.rs
+++ b/src/modules/interests.rs
@@ -25,7 +25,7 @@ static INTEREST_MAP: LazyLock<InterestMap> = LazyLock::new(|| {
.unwrap()
});
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
let mut contacts = INTEREST_MAP
.iter()
.map(|(category, contacts)| {
diff --git a/src/modules/random.rs b/src/modules/random.rs
index 889db73..4711a8d 100644
--- a/src/modules/random.rs
+++ b/src/modules/random.rs
@@ -18,7 +18,7 @@
use rand::prelude::SliceRandom;
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
crate::route::track_mount(
router,
"/random",
diff --git a/src/modules/remarks.rs b/src/modules/remarks.rs
index 03ede11..35b3295 100644
--- a/src/modules/remarks.rs
+++ b/src/modules/remarks.rs
@@ -31,7 +31,7 @@ struct Remark {
edited: Option<String>,
}
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
crate::route::track_mount(
router,
"/remarks",
diff --git a/src/modules/router/module.rs b/src/modules/router/module.rs
index cd7c862..76083b8 100644
--- a/src/modules/router/module.rs
+++ b/src/modules/router/module.rs
@@ -18,7 +18,7 @@
use windmark::context::HookContext;
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
router.set_pre_route_callback(move |context: HookContext| {
info!(
"accepted connection from {} to {}",
@@ -29,7 +29,7 @@ pub fn module(router: &mut windmark::Router) {
super::ticker::module(&context);
});
router.set_post_route_callback({
- |context: HookContext, response: &mut windmark::Response| {
+ |context: HookContext, response: &mut windmark::response::Response| {
info!(
"closed connection from {} to {}",
context.peer_address.unwrap().ip(),
diff --git a/src/modules/router/translate/module.rs b/src/modules/router/translate/module.rs
index bb1e6a4..78ab533 100644
--- a/src/modules/router/translate/module.rs
+++ b/src/modules/router/translate/module.rs
@@ -21,7 +21,7 @@ use crate::modules::router::translate::deepl::language_code_to_language_name;
pub fn module<S>(
context: &windmark::context::HookContext,
- response: &mut windmark::Response,
+ response: &mut windmark::response::Response,
language: S,
) -> Result<(), serde_json::Error>
where
diff --git a/src/modules/search.rs b/src/modules/search.rs
index 12a2c80..fa44382 100644
--- a/src/modules/search.rs
+++ b/src/modules/search.rs
@@ -54,7 +54,7 @@ static INDEX_WRITER: LazyLock<Mutex<tantivy::IndexWriter>> =
Mutex::new((*INDEX.lock().unwrap()).writer(SEARCH_INDEX_SIZE).unwrap())
});
-pub(super) fn module(router: &mut windmark::Router) {
+pub(super) fn module(router: &mut windmark::router::Router) {
crate::route::track_mount(
router,
"/search",
@@ -67,7 +67,7 @@ pub(super) fn module(router: &mut windmark::Router) {
if let Some(query) = context.url.query_pairs().next() {
if query.0 == "action" && query.1 == "go" {
- return windmark::Response::input(
+ return windmark::response::Response::input(
"What would you like to search for?",
);
}
diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs
index ec4fc63..6b27e45 100644
--- a/src/modules/sitemap.rs
+++ b/src/modules/sitemap.rs
@@ -16,7 +16,7 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
crate::route::track_mount(
router,
"/sitemap",
diff --git a/src/modules/skills.rs b/src/modules/skills.rs
index bf62a4d..4d3f9cf 100644
--- a/src/modules/skills.rs
+++ b/src/modules/skills.rs
@@ -24,7 +24,7 @@ static SKILL_TREE: LazyLock<SkillTree> = LazyLock::new(|| {
serde_json::from_str(include_str!("../../content/json/skills.json")).unwrap()
});
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
let mut skills = SKILL_TREE
.iter()
.map(|(category, skills)| {
diff --git a/src/modules/static.rs b/src/modules/static.rs
index 23e2674..94f2220 100644
--- a/src/modules/static.rs
+++ b/src/modules/static.rs
@@ -47,7 +47,7 @@ macro_rules! batch_mount {
};
}
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
batch_mount!(
"files",
router,
diff --git a/src/modules/stocks.rs b/src/modules/stocks.rs
index f3519f1..07c6d84 100644
--- a/src/modules/stocks.rs
+++ b/src/modules/stocks.rs
@@ -106,7 +106,7 @@ async fn symbol_to_string(symbol: &str) -> String {
)
}
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
track_mount(
router,
"/stocks/referrals",
@@ -173,7 +173,7 @@ pub fn module(router: &mut windmark::Router) {
if symbol != "Symbol Search" {
if let Some(query) = context.url.query_pairs().next() {
if query.0 == "action" && query.1 == "go" {
- return windmark::Response::input(
+ return windmark::response::Response::input(
"Which symbol would you like to explore?",
);
}
diff --git a/src/modules/uptime.rs b/src/modules/uptime.rs
index 365c234..64e1804 100644
--- a/src/modules/uptime.rs
+++ b/src/modules/uptime.rs
@@ -22,7 +22,7 @@ use tokio::time::Instant;
static UPTIME: LazyLock<Instant> = LazyLock::new(Instant::now);
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
UPTIME.elapsed();
crate::route::track_mount(
@@ -49,7 +49,7 @@ pub fn module(router: &mut windmark::Router) {
crate::route::cache(&context, &response);
- windmark::Response::success(response)
+ windmark::response::Response::success(response)
},
);
}
diff --git a/src/modules/web.rs b/src/modules/web.rs
index 09c6ac9..7551b2c 100644
--- a/src/modules/web.rs
+++ b/src/modules/web.rs
@@ -15,12 +15,11 @@
// Copyright (C) 2022-2023 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+use windmark::response::Response;
+
use crate::{response::success, route::track_mount};
-fn error(
- message: &str,
- context: &windmark::context::RouteContext,
-) -> windmark::Response {
+fn error(message: &str, context: &windmark::context::RouteContext) -> Response {
success(
&format!(
"# World Wide Web to Gemini Gateway\n\n{message}\n\n=> /web Go back"
@@ -29,7 +28,7 @@ fn error(
)
}
-pub fn module(router: &mut windmark::Router) {
+pub fn module(router: &mut windmark::router::Router) {
track_mount(
router,
"/web",
@@ -52,7 +51,7 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi
"/web/*url",
"World Wide Web to Gemini Gateway Visitor",
async move |context| {
- windmark::Response::success({
+ Response::success({
let Ok(url) = url::Url::parse(&format!(
"https://{}",
if let Some(url_choice) = context.parameters.get("url") {
diff --git a/src/response.rs b/src/response.rs
index a8f8848..b368ba1 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -17,6 +17,8 @@
use std::sync::LazyLock;
+use windmark::response::Response;
+
static QUOTES: LazyLock<Vec<String>> = LazyLock::new(|| {
serde_json::from_str(include_str!("../content/json/quotes.json")).unwrap()
});
@@ -34,10 +36,10 @@ struct Main<'a> {
pub fn success(
body: &impl ToString,
context: &windmark::context::RouteContext,
-) -> windmark::Response {
+) -> Response {
crate::route::cache(context, &body.to_string());
- windmark::Response::success(
+ Response::success(
Main {
body: &body.to_string(),
hits: &crate::route::hits_from(context.url.path()),
diff --git a/src/route.rs b/src/route.rs
index e32cd98..7237fec 100644
--- a/src/route.rs
+++ b/src/route.rs
@@ -56,13 +56,13 @@ pub fn hits_from(route: &str) -> i32 {
}
pub fn track_mount<F, R>(
- router: &mut windmark::Router,
+ router: &mut windmark::router::Router,
route: &str,
description: &str,
handler: F,
) where
F: FnMut(RouteContext) -> R + Send + Sync + 'static,
- R: IntoFuture<Output = windmark::Response> + Send + 'static,
+ R: IntoFuture<Output = windmark::response::Response> + Send + 'static,
<R as IntoFuture>::IntoFuture: Send,
{
(*ROUTES.lock().unwrap()).insert(route.to_string(), Route::new(description));