From b53a078b496306745a18ec2888366fe14f954687 Mon Sep 17 00:00:00 2001 From: Bat Date: Sat, 8 Sep 2018 12:05:22 +0100 Subject: [PATCH] Edit HTML for old articles without source --- src/routes/posts.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 1a40de4..976ef53 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -107,7 +107,12 @@ fn edit(blog: String, slug: String, user: User, conn: DbConn) -> Template { "error_message": "You are not author in this blog." })) } else { - println!("Source: {}", post.source.clone()); + let source = if post.source.clone().len() > 0 { + post.source.clone() + } else { + post.content.clone().get().clone() // fallback to HTML if the markdown was not stored + }; + Template::render("posts/new", json!({ "account": user.to_json(&*conn), "instance": Instance::get_local(&*conn), @@ -116,7 +121,7 @@ fn edit(blog: String, slug: String, user: User, conn: DbConn) -> Template { "form": NewPostForm { title: post.title.clone(), subtitle: post.subtitle.clone(), - content: post.source.clone(), + content: source, tags: Tag::for_post(&*conn, post.id) .into_iter() .map(|t| t.tag)