diff options
Diffstat (limited to 'src/modules/blog/module.rs')
| -rw-r--r-- | src/modules/blog/module.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs index 8ffff90..2fda040 100644 --- a/src/modules/blog/module.rs +++ b/src/modules/blog/module.rs @@ -39,7 +39,7 @@ pub fn module(router: &mut windmark::router::Router) { if std::path::Path::new(&entry_key) .extension() - .map_or(false, |extension| extension.eq_ignore_ascii_case("gmi")) + .is_some_and(|extension| extension.eq_ignore_ascii_case("gmi")) { entry_key.truncate(entry_key.len() - 4); } @@ -99,11 +99,12 @@ pub fn module(router: &mut windmark::router::Router) { .map(|(blog, entries)| { ( blog, - *entries + entries .get("blog.json") .and_then(|content| Blog::from_string(content).ok()) .unwrap_or_default() - .priority(), + .priority() + .copied(), entries, ) }) @@ -125,11 +126,11 @@ pub fn module(router: &mut windmark::router::Router) { .and_then(|content| Blog::from_string(content).ok()); let name = config .as_ref() - .and_then(|c| c.name().as_ref()) + .and_then(|c| c.name()) .cloned() .unwrap_or_else(|| title.clone()); let description = - config.as_ref().and_then(|c| c.description().as_ref()).cloned(); + config.as_ref().and_then(|c| c.description()).cloned(); format!( "=> {} {}{}", @@ -158,11 +159,10 @@ pub fn module(router: &mut windmark::router::Router) { let entries_clone = entries.clone(); let name = config .as_ref() - .and_then(|c| c.name().as_ref()) + .and_then(|c| c.name()) .cloned() .unwrap_or_else(|| blog.clone()); - let description = - config.as_ref().and_then(|c| c.description().as_ref()).cloned(); + let description = config.as_ref().and_then(|c| c.description()).cloned(); let config_clone = config.clone(); let mut xml = XmlWriter::builder(); @@ -197,13 +197,13 @@ pub fn module(router: &mut windmark::router::Router) { {0}'s RSS feed\n\n=> {} here!", blog, entries_clone.len(), - description.as_deref().unwrap_or(""), + description.as_deref().map_or("", |v| v), entries_clone .keys() .map(|title| { let postish = config_clone .as_ref() - .and_then(|c| c.posts().as_ref()) + .and_then(|c| c.posts()) .and_then(|posts| posts.get(title)) .cloned() .unwrap_or_default(); @@ -215,10 +215,10 @@ pub fn module(router: &mut windmark::router::Router) { fixed_blog_name, title.to_lowercase() ), - { postish.name().clone().unwrap_or_else(|| title.clone()) }, + { postish.name().cloned().unwrap_or_else(|| title.clone()) }, { let post = - postish.description().clone().unwrap_or_default(); + postish.description().cloned().unwrap_or_default(); if post.is_empty() { String::new() @@ -238,7 +238,7 @@ pub fn module(router: &mut windmark::router::Router) { ); for (title, contents) in entries { - let header = construct_header(&config, &title) + let header = construct_header(config.as_ref(), &title) .unwrap_or_else(|()| (String::new(), String::new())); let fixed_blog_name = fixed_blog_name_clone_2.clone(); let mut real_title = "Unknown"; @@ -326,11 +326,11 @@ pub fn module(router: &mut windmark::router::Router) { } fn construct_header( - config: &Option<Blog>, + config: Option<&Blog>, name: &str, ) -> Result<(String, String), ()> { let post = - if let Some(posts) = config.clone().unwrap_or_default().posts().clone() { + if let Some(posts) = config.cloned().unwrap_or_default().posts().cloned() { if let Some(post) = posts.get(name) { post.clone() } else { @@ -359,7 +359,7 @@ fn construct_header( Ok(( format!( "# {}\n{}{}{}{}{}", - post.name().clone().unwrap_or_else(|| name.to_string()), + post.name().cloned().unwrap_or_else(|| name.to_string()), if any_is_some![author, created, last_modified, description] { "\n" } else { @@ -370,6 +370,6 @@ fn construct_header( field!(last_modified, " (last modified on {})\n"), field!(description, "\n{}\n"), ), - post.description().clone().unwrap_or_default(), + post.description().cloned().unwrap_or_default(), )) } |