diff options
| author | Fuwn <[email protected]> | 2024-06-16 16:29:02 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-16 16:29:02 -0700 |
| commit | b8ad47f69d05356cf8dbb095a14c7cb9ea20c81b (patch) | |
| tree | 1a7188f95eb45bf36f45941ffeb9724400c66975 /src | |
| parent | fix(blog): use real title for xml title (diff) | |
| download | locus-b8ad47f69d05356cf8dbb095a14c7cb9ea20c81b.tar.xz locus-b8ad47f69d05356cf8dbb095a14c7cb9ea20c81b.zip | |
refactor: constants for root urls
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 1 | ||||
| -rw-r--r-- | src/modules/blog/module.rs | 9 | ||||
| -rw-r--r-- | src/modules/web.rs | 14 | ||||
| -rw-r--r-- | src/url.rs | 2 |
4 files changed, 18 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 447e37e..7031157 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,7 @@ mod modules; mod response; mod route; mod timing; +mod url; mod xml; #[macro_use] extern crate log; diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs index 7c10b21..2336fb4 100644 --- a/src/modules/blog/module.rs +++ b/src/modules/blog/module.rs @@ -21,6 +21,7 @@ use { modules::blog::config::Blog, response::success, route::track_mount, + url::ROOT_GEMINI_URL, xml::{Item as XmlItem, Writer as XmlWriter}, }, std::{ @@ -163,11 +164,11 @@ pub fn module(router: &mut windmark::router::Router) { let mut xml = XmlWriter::builder(); xml.add_field("title", &name); - xml.add_field("link", &format!("gemini://fuwn.me/blog/{fixed_blog_name}")); + xml.add_field("link", &format!("{ROOT_GEMINI_URL}/blog/{fixed_blog_name}")); xml.add_field("description", &description); xml.add_field("generator", "locus"); xml.add_field("lastBuildDate", &chrono::Local::now().to_rfc2822()); - xml.add_link(&format!("gemini://fuwn.me/blog/{fixed_blog_name}.xml")); + xml.add_link(&format!("{ROOT_GEMINI_URL}/blog/{fixed_blog_name}.xml")); track_mount( router, @@ -238,7 +239,7 @@ pub fn module(router: &mut windmark::router::Router) { builder.add_field( "link", &format!( - "gemini://fuwn.me/blog/{}/{}", + "{ROOT_GEMINI_URL}/blog/{}/{}", fixed_blog_name, title.to_lowercase() ), @@ -247,7 +248,7 @@ pub fn module(router: &mut windmark::router::Router) { builder.add_field( "guid", &format!( - "gemini://fuwn.me/blog/{}/{}", + "{ROOT_GEMINI_URL}/blog/{}/{}", fixed_blog_name, title.to_lowercase() ), diff --git a/src/modules/web.rs b/src/modules/web.rs index ccbf4fd..96cd93e 100644 --- a/src/modules/web.rs +++ b/src/modules/web.rs @@ -16,7 +16,11 @@ // SPDX-License-Identifier: GPL-3.0-only use { - crate::{response::success, route::track_mount}, + crate::{ + response::success, + route::track_mount, + url::{ROOT_GEMINI_URL, ROOT_HTTPS_URL}, + }, windmark::response::Response, }; @@ -32,13 +36,15 @@ fn error(message: &str, context: &windmark::context::RouteContext) -> Response { pub fn module(router: &mut windmark::router::Router) { track_mount(router, "/web", "World Wide Web to Gemini Gateway", |context| { success( - &r"# World Wide Web to Gemini Gateway + &format!( + r"# World Wide Web to Gemini Gateway To use this gateway, simply append the address of your target resource to the end of the current route, minus the protocol. -To visit the web version of this exact page, <https://fuwn.me/web>, you would visit <gemini://fuwn.me/web/fuwn.me/web>. +To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would visit <{ROOT_GEMINI_URL}/web/fuwn.me/web>. -=> /web/fuwn.me/web Try it!", +=> /web/fuwn.me/web Try it!" + ), &context, ) }); diff --git a/src/url.rs b/src/url.rs new file mode 100644 index 0000000..f818063 --- /dev/null +++ b/src/url.rs @@ -0,0 +1,2 @@ +pub const ROOT_GEMINI_URL: &str = "gemini://fuwn.me"; +pub const ROOT_HTTPS_URL: &str = "https://fuwn.me"; |