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/modules/blog/module.rs | |
| parent | chore(amenadiel): remove unused feature flag (diff) | |
| download | locus-55167fafb1cd292fe3c42e5c4066a474d05be1f3.tar.xz locus-55167fafb1cd292fe3c42e5c4066a474d05be1f3.zip | |
style: rewrite formatter
Diffstat (limited to 'src/modules/blog/module.rs')
| -rw-r--r-- | src/modules/blog/module.rs | 44 |
1 files changed, 19 insertions, 25 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(&{ |