From 22846c85b33b95787e7d16549f3ed86dcbf9e989 Mon Sep 17 00:00:00 2001 From: Leonard Lorenz Date: Fri, 23 Oct 2020 22:50:55 +0200 Subject: [PATCH] convert newlines in blogposts to
tags --- site/src/routes.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/site/src/routes.rs b/site/src/routes.rs index ab7d090..5c1fbe5 100644 --- a/site/src/routes.rs +++ b/site/src/routes.rs @@ -63,7 +63,7 @@ async fn blog_permalink(web::Path(post_id): web::Path) -> i .unwrap_or_else(|e| panic!("Error, couldn't load blog template.\n{}", e)) .as_str()), &context, - true, + false, ) .unwrap_or_else(|e| panic!("Error, couldn't render blog template.\n{}", e)); HttpResponse::Ok().content_type("text/html").body(result) @@ -82,8 +82,10 @@ struct NewPostForm { async fn blog_new_post(form: Form) -> impl Responder { let token = config::get_from_env("SUBMIT_TOKEN", true); + let replace_newlines = |x: &String| x.replace("\n", "
"); + if form.token == token { - add_post(&form.title.as_str(), &form.body.as_str()); + add_post(&form.title.as_str(), replace_newlines(&form.body).as_str()); println!("New blog post created."); } else { println!("Unauthorized new blog post");