Remove the routes and the template for the comment form
This commit is contained in:
parent
461c26f159
commit
4c211b4308
3
po/en.po
3
po/en.po
@ -283,3 +283,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "{{ data }} mentioned you."
|
msgid "{{ data }} mentioned you."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Your comment"
|
||||||
|
msgstr ""
|
||||||
|
4
po/fr.po
4
po/fr.po
@ -282,3 +282,7 @@ msgstr "Vous n'êtes pas auteur dans ce blog."
|
|||||||
|
|
||||||
msgid "{{ data }} mentioned you."
|
msgid "{{ data }} mentioned you."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
msgid "Your comment"
|
||||||
|
msgstr "Envoyer le commentaire"
|
||||||
|
4
po/pl.po
4
po/pl.po
@ -289,5 +289,9 @@ msgstr ""
|
|||||||
msgid "{{ data }} mentioned you."
|
msgid "{{ data }} mentioned you."
|
||||||
msgstr "{{ data }} skomentował Twój artykuł"
|
msgstr "{{ data }} skomentował Twój artykuł"
|
||||||
|
|
||||||
|
#, fuzzy
|
||||||
|
msgid "Your comment"
|
||||||
|
msgstr "Wyślij komentarz"
|
||||||
|
|
||||||
#~ msgid "Logowanie"
|
#~ msgid "Logowanie"
|
||||||
#~ msgstr "Zaloguj się"
|
#~ msgstr "Zaloguj się"
|
||||||
|
@ -68,9 +68,6 @@ fn main() {
|
|||||||
routes::blogs::new_auth,
|
routes::blogs::new_auth,
|
||||||
routes::blogs::create,
|
routes::blogs::create,
|
||||||
|
|
||||||
routes::comments::new,
|
|
||||||
routes::comments::new_response,
|
|
||||||
routes::comments::new_auth,
|
|
||||||
routes::comments::create,
|
routes::comments::create,
|
||||||
routes::comments::create_response,
|
routes::comments::create_response,
|
||||||
|
|
||||||
@ -85,6 +82,7 @@ fn main() {
|
|||||||
routes::notifications::notifications_auth,
|
routes::notifications::notifications_auth,
|
||||||
|
|
||||||
routes::posts::details,
|
routes::posts::details,
|
||||||
|
routes::posts::details_response,
|
||||||
routes::posts::activity_details,
|
routes::posts::activity_details,
|
||||||
routes::posts::new,
|
routes::posts::new,
|
||||||
routes::posts::new_auth,
|
routes::posts::new_auth,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use rocket::{
|
use rocket::{
|
||||||
request::Form,
|
request::Form,
|
||||||
response::{Redirect, Flash}
|
response::Redirect
|
||||||
};
|
};
|
||||||
use rocket_contrib::Template;
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use activity_pub::{broadcast, inbox::Inbox};
|
use activity_pub::{broadcast, inbox::Inbox};
|
||||||
@ -15,36 +14,9 @@ use models::{
|
|||||||
users::User
|
users::User
|
||||||
};
|
};
|
||||||
|
|
||||||
use utils;
|
|
||||||
|
|
||||||
#[get("/~/<blog>/<slug>/comment")]
|
|
||||||
fn new(blog: String, slug: String, user: User, conn: DbConn) -> Template {
|
|
||||||
new_response(blog, slug, None, user, conn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
|
||||||
#[get("/~/<blog_name>/<slug>/comment?<query>")]
|
|
||||||
fn new_response(blog_name: String, slug: String, query: Option<CommentQuery>, user: User, conn: DbConn) -> Template {
|
|
||||||
may_fail!(Blog::find_by_fqn(&*conn, blog_name), "Couldn't find this blog", |blog| {
|
|
||||||
may_fail!(Post::find_by_slug(&*conn, slug, blog.id), "Couldn't find this post", |post| {
|
|
||||||
Template::render("comments/new", json!({
|
|
||||||
"post": post,
|
|
||||||
"account": user,
|
|
||||||
"previous": query.and_then(|q| q.responding_to.map(|r| Comment::get(&*conn, r).expect("Error retrieving previous comment").to_json(&*conn))),
|
|
||||||
"user_fqn": user.get_fqn(&*conn)
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/~/<blog>/<slug>/comment", rank = 2)]
|
|
||||||
fn new_auth(blog: String, slug: String) -> Flash<Redirect>{
|
|
||||||
utils::requires_login("You need to be logged in order to post a comment", uri!(new: blog = blog, slug = slug))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(FromForm)]
|
#[derive(FromForm)]
|
||||||
struct CommentQuery {
|
pub struct CommentQuery {
|
||||||
responding_to: Option<i32>
|
pub responding_to: Option<i32>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(FromForm)]
|
#[derive(FromForm)]
|
||||||
@ -71,7 +43,6 @@ fn create_response(blog_name: String, slug: String, query: Option<CommentQuery>,
|
|||||||
.author(user.clone())
|
.author(user.clone())
|
||||||
.create(&*conn);
|
.create(&*conn);
|
||||||
|
|
||||||
// Comment::notify(&*conn, new_comment, user.clone().into_id());
|
|
||||||
let instance = Instance::get_local(&*conn).unwrap();
|
let instance = Instance::get_local(&*conn).unwrap();
|
||||||
instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error"));
|
instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error"));
|
||||||
broadcast(&*conn, &user, new_comment, user.get_followers(&*conn));
|
broadcast(&*conn, &user, new_comment, user.get_followers(&*conn));
|
||||||
|
@ -14,11 +14,18 @@ use models::{
|
|||||||
posts::*,
|
posts::*,
|
||||||
users::User
|
users::User
|
||||||
};
|
};
|
||||||
|
use routes::comments::CommentQuery;
|
||||||
use safe_string::SafeString;
|
use safe_string::SafeString;
|
||||||
use utils;
|
use utils;
|
||||||
|
|
||||||
|
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
||||||
#[get("/~/<blog>/<slug>", rank = 4)]
|
#[get("/~/<blog>/<slug>", rank = 4)]
|
||||||
fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Template {
|
fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Template {
|
||||||
|
details_response(blog, slug, conn, user, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/~/<blog>/<slug>?<query>")]
|
||||||
|
fn details_response(blog: String, slug: String, conn: DbConn, user: Option<User>, query: Option<CommentQuery>) -> Template {
|
||||||
may_fail!(Blog::find_by_fqn(&*conn, blog), "Couldn't find this blog", |blog| {
|
may_fail!(Blog::find_by_fqn(&*conn, blog), "Couldn't find this blog", |blog| {
|
||||||
may_fail!(Post::find_by_slug(&*conn, slug, blog.id), "Couldn't find this post", |post| {
|
may_fail!(Post::find_by_slug(&*conn, slug, blog.id), "Couldn't find this post", |post| {
|
||||||
let comments = Comment::list_by_post(&*conn, post.id);
|
let comments = Comment::list_by_post(&*conn, post.id);
|
||||||
@ -33,7 +40,9 @@ fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Temp
|
|||||||
"n_reshares": post.get_reshares(&*conn).len(),
|
"n_reshares": post.get_reshares(&*conn).len(),
|
||||||
"has_reshared": user.clone().map(|u| u.has_reshared(&*conn, &post)).unwrap_or(false),
|
"has_reshared": user.clone().map(|u| u.has_reshared(&*conn, &post)).unwrap_or(false),
|
||||||
"account": user,
|
"account": user,
|
||||||
"date": &post.creation_date.timestamp()
|
"date": &post.creation_date.timestamp(),
|
||||||
|
"previous": query.and_then(|q| q.responding_to.map(|r| Comment::get(&*conn, r).expect("Error retrieving previous comment").to_json(&*conn))),
|
||||||
|
"user_fqn": user.map(|u| u.get_fqn(&*conn)).unwrap_or(String::new())
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
{% extends "base" %}
|
|
||||||
|
|
||||||
{% block title %}
|
|
||||||
{{ 'Comment "{{ post }}"' | _(post=post.title) }}
|
|
||||||
{% endblock title %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h1>{{ 'Comment "{{ post }}"' | _(post=post.title) }}</h1>
|
|
||||||
<form method="post">
|
|
||||||
<label for="content">{{ "Content" | _ }}</label>
|
|
||||||
{# Ugly, but we don't have the choice if we don't want weird paddings #}
|
|
||||||
<textarea id="content" name="content">{% filter trim %}{% if previous %}{% if previous.author.fqn != user_fqn %}@{{ previous.author.fqn }} {% endif %}{% for mention in previous.mentions %}{% if mention != user_fqn %}@{{ mention }} {% endif %}{% endfor %}{% endif %}{% endfilter %}</textarea>
|
|
||||||
<input type="submit" value="{{ "Submit comment" | _ }}" />
|
|
||||||
</form>
|
|
||||||
{% endblock content %}
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
|||||||
<span class="username">@{{ comment.author.username }}</span>
|
<span class="username">@{{ comment.author.username }}</span>
|
||||||
</a>
|
</a>
|
||||||
<div class="text">{{ comment.content | safe }}</div>
|
<div class="text">{{ comment.content | safe }}</div>
|
||||||
<a class="button" href="comment?responding_to={{ comment.id }}">{{ "Respond" | _ }}</a>
|
<a class="button" href="?responding_to={{ comment.id }}">{{ "Respond" | _ }}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user