aboutsummaryrefslogtreecommitdiff
path: root/src/modules/blog/module.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-06 00:02:11 -0700
committerFuwn <[email protected]>2023-04-06 00:02:11 -0700
commit039acf58ac5a4b16fdb896634affb637b1bdeaad (patch)
tree46caa813e140c5baae75a48268f6a997a5e9951c /src/modules/blog/module.rs
parentfix(docker): copy syntax warning (diff)
downloadlocus-039acf58ac5a4b16fdb896634affb637b1bdeaad.tar.xz
locus-039acf58ac5a4b16fdb896634affb637b1bdeaad.zip
deps(windmark): bump 0.2.5 -> 0.3.1
Diffstat (limited to 'src/modules/blog/module.rs')
-rw-r--r--src/modules/blog/module.rs82
1 files changed, 37 insertions, 45 deletions
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs
index dbdf7ed..41fcf86 100644
--- a/src/modules/blog/module.rs
+++ b/src/modules/blog/module.rs
@@ -105,29 +105,25 @@ pub fn module(router: &mut windmark::Router) {
let blog_clone = blogs.clone();
- track_mount(
- router,
- "/blog",
- "Fuwn's blogs",
- Box::new(move |context| {
- success!(
- &format!(
- "# Blogs ({})\n\n{}",
- blog_clone.len(),
- blog_clone
- .iter()
- .map(|(title, entries)| (title.clone(), entries.clone()))
- .collect::<Vec<(_, _)>>()
- .into_iter()
- .map(|(title, entries)| {
- let config: Option<Blog> =
- entries.get("blog.json").and_then(|content| {
- if let Ok(config) = Blog::from_string(content) {
- Some(config)
- } else {
- None
- }
- });
+ track_mount(router, "/blog", "Fuwn's blogs", move |context| {
+ success!(
+ &format!(
+ "# Blogs ({})\n\n{}",
+ blog_clone.len(),
+ blog_clone
+ .iter()
+ .map(|(title, entries)| (title.clone(), entries.clone()))
+ .collect::<Vec<(_, _)>>()
+ .into_iter()
+ .map(|(title, entries)| {
+ let config: Option<Blog> =
+ entries.get("blog.json").and_then(|content| {
+ if let Ok(config) = Blog::from_string(content) {
+ Some(config)
+ } else {
+ None
+ }
+ });
let name = config
.clone()
.unwrap_or_default()
@@ -140,23 +136,19 @@ pub fn module(router: &mut windmark::Router) {
.clone()
.unwrap_or_else(|| "One of Fuwn's blogs".to_string());
- format!(
- "=> {} {} ― {}",
- format_args!(
- "/blog/{}",
- name.replace(' ', "_").to_lowercase(),
- ),
- name,
+ format!(
+ "=> {} {} ― {}",
+ format_args!("/blog/{}", name.replace(' ', "_").to_lowercase(),),
+ name,
description
- )
- })
- .collect::<Vec<_>>()
- .join("\n")
- ),
- context
- )
- }),
- );
+ )
+ })
+ .collect::<Vec<_>>()
+ .join("\n")
+ ),
+ context
+ )
+ });
for (blog, mut entries) in blogs {
let fixed_blog_name = blog.replace(' ', "_").to_lowercase();
@@ -200,7 +192,7 @@ pub fn module(router: &mut windmark::Router) {
router,
&format!("/blog/{}", fixed_blog_name),
&format!("{} ― {}", name, description),
- Box::new(move |context| {
+ move |context| {
let fixed_blog_name = fixed_blog_name_clone.clone();
success!(
@@ -252,7 +244,7 @@ pub fn module(router: &mut windmark::Router) {
),
context
)
- }),
+ },
);
for (title, contents) in entries {
@@ -311,9 +303,9 @@ pub fn module(router: &mut windmark::Router) {
header.1
}
),
- Box::new(move |context| {
+ move |context| {
success!(format!("{}\n{}", header.0, contents,), context)
- }),
+ },
);
}
@@ -321,11 +313,11 @@ pub fn module(router: &mut windmark::Router) {
router,
&format!("/blog/{}.xml", fixed_blog_name),
&format!("Really Simple Syndication for the {} blog", name),
- Box::new(move |_| {
+ move |_| {
windmark::Response::success(xml.to_string())
.with_mime("text/rss+xml")
.clone()
- }),
+ },
);
}
}