diff --git a/src/routes/comments.rs b/src/routes/comments.rs index 4e956646..b51fb55f 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -11,23 +11,27 @@ use models::users::User; fn new(_blog: String, slug: String, _user: User, conn: DbConn) -> Template { let post = Post::find_by_slug(&*conn, slug).unwrap(); Template::render("comments/new", json!({ - "post": post + "post": post, })) } #[derive(FromForm)] -struct NewCommentForm { - pub content: String, - pub respond_to: Option +struct CommentQuery { + responding_to: Option } -#[post("/~///comment", data = "")] -fn create(blog: String, slug: String, data: Form, user: User, conn: DbConn) -> Redirect { +#[derive(FromForm)] +struct NewCommentForm { + pub content: String +} + +#[post("/~///comment?", data = "")] +fn create(blog: String, slug: String, query: CommentQuery, data: Form, user: User, conn: DbConn) -> Redirect { let post = Post::find_by_slug(&*conn, slug.clone()).unwrap(); let form = data.get(); let comment = Comment::insert(&*conn, NewComment { content: form.content.clone(), - in_response_to_id: form.respond_to, + in_response_to_id: query.responding_to, post_id: post.id, author_id: user.id, ap_url: None, diff --git a/templates/comments/new.tera b/templates/comments/new.tera index 0536a437..2dc14487 100644 --- a/templates/comments/new.tera +++ b/templates/comments/new.tera @@ -9,11 +9,6 @@ Comment "{{ post.title }}"
- - {% if responding_to %} - - {% endif %} -
{% endblock content %} diff --git a/templates/posts/details.tera b/templates/posts/details.tera index ea7570ea..0c62d14f 100644 --- a/templates/posts/details.tera +++ b/templates/posts/details.tera @@ -18,7 +18,8 @@
{{ comment.author.display_name }}
{{ comment.content | safe }}
+ Respond
{% endfor %} - Comment + Comment {% endblock content %}