From cb6c83ea22e36eb778a06f4bb92060166e11a94b Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 16 Jun 2024 16:21:58 -0700 Subject: fix(blog): use real title for xml title --- src/modules/blog/module.rs | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'src/modules') diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs index 6a36429..7c10b21 100644 --- a/src/modules/blog/module.rs +++ b/src/modules/blog/module.rs @@ -16,17 +16,18 @@ // Copyright (C) 2022-2022 Fuwn // SPDX-License-Identifier: GPL-3.0-only -use std::{ - collections::HashMap, - fs::{self, read_dir}, - io::Read, -}; - -use crate::{ - modules::blog::config::Blog, - response::success, - route::track_mount, - xml::{Item as XmlItem, Writer as XmlWriter}, +use { + crate::{ + modules::blog::config::Blog, + response::success, + route::track_mount, + xml::{Item as XmlItem, Writer as XmlWriter}, + }, + std::{ + collections::HashMap, + fs::{self, read_dir}, + io::Read, + }, }; #[allow(clippy::too_many_lines)] @@ -39,15 +40,11 @@ pub fn module(router: &mut windmark::router::Router) { let blog_paths = read_dir(&blog).unwrap(); let mut entries: HashMap<_, String> = HashMap::new(); - blog_paths - .map(|e| e.unwrap().path().display().to_string()) - .for_each(|file| { + blog_paths.map(|e| e.unwrap().path().display().to_string()).for_each( + |file| { let mut contents = String::new(); - fs::File::open(&file) - .unwrap() - .read_to_string(&mut contents) - .unwrap(); + fs::File::open(&file).unwrap().read_to_string(&mut contents).unwrap(); entries.insert( file.replace(&blog, "").replace(".gmi", "").replace( @@ -66,7 +63,8 @@ pub fn module(router: &mut windmark::router::Router) { ), contents, ); - }); + }, + ); blogs.insert( blog @@ -90,9 +88,7 @@ pub fn module(router: &mut windmark::router::Router) { let mut c = s.chars(); c.next().map_or_else(String::new, |f| { - f.to_uppercase() - .chain(c.flat_map(char::to_lowercase)) - .collect() + f.to_uppercase().chain(c.flat_map(char::to_lowercase)).collect() }) }) .collect::>() @@ -239,7 +235,6 @@ pub fn module(router: &mut windmark::router::Router) { xml.add_item(&{ let mut builder = XmlItem::builder(); - builder.add_field("title", &title); builder.add_field( "link", &format!( @@ -272,6 +267,8 @@ pub fn module(router: &mut windmark::router::Router) { } } + builder.add_field("title", real_title); + builder }); -- cgit v1.2.3