diff options
| author | Fuwn <[email protected]> | 2023-04-17 23:17:50 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-17 23:17:50 -0700 |
| commit | 55167fafb1cd292fe3c42e5c4066a474d05be1f3 (patch) | |
| tree | 50a28cf249b0e59949899c53e54b3b3cdf4ca452 /src | |
| parent | chore(amenadiel): remove unused feature flag (diff) | |
| download | locus-55167fafb1cd292fe3c42e5c4066a474d05be1f3.tar.xz locus-55167fafb1cd292fe3c42e5c4066a474d05be1f3.zip | |
style: rewrite formatter
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/blog/module.rs | 44 | ||||
| -rw-r--r-- | src/modules/contact.rs | 5 | ||||
| -rw-r--r-- | src/modules/cryptocurrency.rs | 6 | ||||
| -rw-r--r-- | src/modules/interests.rs | 2 | ||||
| -rw-r--r-- | src/modules/remarks.rs | 9 | ||||
| -rw-r--r-- | src/modules/router/translate/module.rs | 16 | ||||
| -rw-r--r-- | src/modules/search.rs | 27 | ||||
| -rw-r--r-- | src/modules/sitemap.rs | 2 | ||||
| -rw-r--r-- | src/modules/skills.rs | 12 | ||||
| -rw-r--r-- | src/modules/static.rs | 1 | ||||
| -rw-r--r-- | src/modules/stocks.rs | 4 |
11 files changed, 60 insertions, 68 deletions
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs index 433a1f5..aad110a 100644 --- a/src/modules/blog/module.rs +++ b/src/modules/blog/module.rs @@ -24,8 +24,8 @@ use std::{ use crate::{ modules::blog::config::Blog, - route::track_mount, response::success, + route::track_mount, xml::{Item as XmlItem, Writer as XmlWriter}, }; @@ -89,8 +89,11 @@ pub fn module(router: &mut windmark::Router) { // https://gist.github.com/jpastuszek/2704f3c5a3864b05c48ee688d0fd21d7 let mut c = s.chars(); - c.next().map_or_else(String::new, |f| f.to_uppercase() - .chain(c.flat_map(char::to_lowercase)).collect()) + c.next().map_or_else(String::new, |f| { + f.to_uppercase() + .chain(c.flat_map(char::to_lowercase)) + .collect() + }) }) .collect::<Vec<_>>() .join(" "), @@ -111,10 +114,9 @@ pub fn module(router: &mut windmark::Router) { .collect::<Vec<(_, _)>>() .into_iter() .map(|(title, entries)| { - let config: Option<Blog> = - entries.get("blog.json").and_then(|content| { - Blog::from_string(content).ok() - }); + let config: Option<Blog> = entries + .get("blog.json") + .and_then(|content| Blog::from_string(content).ok()); let name = config .clone() .unwrap_or_default() @@ -137,7 +139,7 @@ pub fn module(router: &mut windmark::Router) { .collect::<Vec<_>>() .join("\n") ), - &context + &context, ) }); @@ -145,10 +147,9 @@ pub fn module(router: &mut windmark::Router) { let fixed_blog_name = blog.replace(' ', "_").to_lowercase(); let fixed_blog_name_clone = fixed_blog_name.clone(); let fixed_blog_name_clone_2 = fixed_blog_name.clone(); - let config: Option<Blog> = - entries.remove_entry("blog.json").and_then(|(_, content)| { - Blog::from_string(&content).ok() - }); + let config: Option<Blog> = entries + .remove_entry("blog.json") + .and_then(|(_, content)| Blog::from_string(&content).ok()); let entries_clone = entries.clone(); let name = config .clone() @@ -166,10 +167,7 @@ pub fn module(router: &mut windmark::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!("gemini://fuwn.me/blog/{fixed_blog_name}")); xml.add_field("description", &description); xml.add_field("generator", "locus"); xml.add_field("lastBuildDate", &chrono::Local::now().to_rfc2822()); @@ -212,10 +210,8 @@ pub fn module(router: &mut windmark::Router) { ), { postish.name().clone().unwrap_or_else(|| title.clone()) }, { - let post = postish - .description() - .clone() - .unwrap_or_default(); + let post = + postish.description().clone().unwrap_or_default(); if post.is_empty() { String::new() @@ -229,16 +225,14 @@ pub fn module(router: &mut windmark::Router) { .join("\n"), format_args!("/blog/{}.xml", fixed_blog_name), ), - &context + &context, ) }, ); for (title, contents) in entries { - let header = construct_header(&config, &title).map_or_else( - |_| (String::new(), String::new()), - |header| header, - ); + let header = construct_header(&config, &title) + .map_or_else(|_| (String::new(), String::new()), |header| header); let fixed_blog_name = fixed_blog_name_clone_2.clone(); xml.add_item(&{ diff --git a/src/modules/contact.rs b/src/modules/contact.rs index 76781b9..aaeba96 100644 --- a/src/modules/contact.rs +++ b/src/modules/contact.rs @@ -51,7 +51,10 @@ pub fn module(router: &mut windmark::Router) { "/contact", "A Few Skills of Fuwn", move |context| { - crate::response::success(&format!("# Contact\n\n{}", contacts.join("\n")), &context) + crate::response::success( + &format!("# Contact\n\n{}", contacts.join("\n")), + &context, + ) }, ); } diff --git a/src/modules/cryptocurrency.rs b/src/modules/cryptocurrency.rs index 87f6ca0..c0fc4b5 100644 --- a/src/modules/cryptocurrency.rs +++ b/src/modules/cryptocurrency.rs @@ -19,7 +19,7 @@ use once_cell::sync::Lazy; use serde::Deserialize; -use crate::{route::track_mount, response::success}; +use crate::{response::success, route::track_mount}; static REFERRALS: Lazy<Vec<Referral>> = Lazy::new(|| { serde_json::from_str(include_str!( @@ -55,7 +55,7 @@ pub fn module(router: &mut windmark::Router) { .collect::<Vec<String>>() .join("\n") ), - &context + &context, ) }, ); @@ -70,7 +70,7 @@ pub fn module(router: &mut windmark::Router) { "# Cryptocurrency\n\n=> /stocks Stock Market Dashboard\n=> \ /cryptocurrency/referrals Referrals", ), - &context + &context, ) }, ); diff --git a/src/modules/interests.rs b/src/modules/interests.rs index 90d96eb..3a797a6 100644 --- a/src/modules/interests.rs +++ b/src/modules/interests.rs @@ -57,7 +57,7 @@ pub fn module(router: &mut windmark::Router) { and I am considering using more in the future.\n\n{}", contacts.join("\n") ), - &context + &context, ) }, ); diff --git a/src/modules/remarks.rs b/src/modules/remarks.rs index 0b5fc26..60c4571 100644 --- a/src/modules/remarks.rs +++ b/src/modules/remarks.rs @@ -48,16 +48,15 @@ pub fn module(router: &mut windmark::Router) { "* \"{}\" {}{}", r.remark, r.created, - r.edited.as_ref().map_or_else( - String::new, - |edited| format!(" Edited {}", edited) - ) + r.edited.as_ref().map_or_else(String::new, |edited| { + format!(" Edited {}", edited) + }) ) }) .collect::<Vec<String>>() .join("\n") ), - &context + &context, ) }, ); diff --git a/src/modules/router/translate/module.rs b/src/modules/router/translate/module.rs index f6b2367..bb1e6a4 100644 --- a/src/modules/router/translate/module.rs +++ b/src/modules/router/translate/module.rs @@ -52,15 +52,13 @@ where format!( "=> {to}?translate={}{}", language.as_ref(), - text.clone().map_or_else( - String::new, - |text| { - format!( - " {}", - translate(&text, language.as_ref()).map_or(text, |text| text.text()), - ) - } - ) + text.clone().map_or_else(String::new, |text| { + format!( + " {}", + translate(&text, language.as_ref()) + .map_or(text, |text| text.text()), + ) + }) ), ); } diff --git a/src/modules/search.rs b/src/modules/search.rs index d5fdc1f..14a0f9e 100644 --- a/src/modules/search.rs +++ b/src/modules/search.rs @@ -121,21 +121,18 @@ pub(super) fn module(router: &mut windmark::Router) { .lines() .skip(2); - lines.next().map_or_else( - String::new, - |first_line| { - let mut context_lines = lines.skip_while(|l| { - !l.to_lowercase().contains(&query.0.to_string()) - }); - - format!( - "\n> ... {}\n> {}\n> {} ...", - first_line, - context_lines.next().unwrap_or(""), - context_lines.next().unwrap_or("") - ) - }, - ) + lines.next().map_or_else(String::new, |first_line| { + let mut context_lines = lines.skip_while(|l| { + !l.to_lowercase().contains(&query.0.to_string()) + }); + + format!( + "\n> ... {}\n> {}\n> {} ...", + first_line, + context_lines.next().unwrap_or(""), + context_lines.next().unwrap_or("") + ) + }) }) ); } diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs index 19c6b82..ec4fc63 100644 --- a/src/modules/sitemap.rs +++ b/src/modules/sitemap.rs @@ -32,7 +32,7 @@ pub fn module(router: &mut windmark::Router) { .collect::<Vec<_>>() .join("\n") ), - &context + &context, ) }, ); diff --git a/src/modules/skills.rs b/src/modules/skills.rs index 45b42d9..b6c8853 100644 --- a/src/modules/skills.rs +++ b/src/modules/skills.rs @@ -42,10 +42,9 @@ pub fn module(router: &mut windmark::Router) { format!( "* {}{}", item, - areas.clone().map_or_else( - String::new, - |known_areas| format!(": {}", known_areas.join(", ")) - ) + areas.clone().map_or_else(String::new, |known_areas| { + format!(": {}", known_areas.join(", ")) + }) ) }) .collect::<Vec<String>>() @@ -64,7 +63,10 @@ pub fn module(router: &mut windmark::Router) { "/skills", "A Few Skills of Fuwn", move |context| { - crate::response::success(&format!("# Skills\n\n{}", skills.join("\n")), &context) + crate::response::success( + &format!("# Skills\n\n{}", skills.join("\n")), + &context, + ) }, ); } diff --git a/src/modules/static.rs b/src/modules/static.rs index c451d76..e3294fd 100644 --- a/src/modules/static.rs +++ b/src/modules/static.rs @@ -47,7 +47,6 @@ macro_rules! batch_mount { }; } - pub fn module(router: &mut windmark::Router) { batch_mount!( "files", diff --git a/src/modules/stocks.rs b/src/modules/stocks.rs index 20ab850..afa1c5d 100644 --- a/src/modules/stocks.rs +++ b/src/modules/stocks.rs @@ -19,7 +19,7 @@ use once_cell::sync::Lazy; use serde::Deserialize; -use crate::{route::track_mount, response::success}; +use crate::{response::success, route::track_mount}; static REFERRALS: Lazy<Vec<Referral>> = Lazy::new(|| { serde_json::from_str(include_str!( @@ -126,7 +126,7 @@ pub fn module(router: &mut windmark::Router) { .collect::<Vec<String>>() .join("\n") ), - &context + &context, ) }, ); |