Make it possible to tag articles and display them
This commit is contained in:
@@ -19,6 +19,7 @@ use likes::Like;
|
||||
use mentions::Mention;
|
||||
use post_authors::*;
|
||||
use reshares::Reshare;
|
||||
use tags::Tag;
|
||||
use users::User;
|
||||
use schema::posts;
|
||||
use safe_string::SafeString;
|
||||
@@ -244,7 +245,8 @@ impl Post {
|
||||
"author": self.get_authors(conn)[0].to_json(conn),
|
||||
"url": format!("/~/{}/{}/", blog.get_fqn(conn), self.slug),
|
||||
"date": self.creation_date.timestamp(),
|
||||
"blog": blog.to_json(conn)
|
||||
"blog": blog.to_json(conn),
|
||||
"tags": Tag::for_post(&*conn, self.id)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use diesel::{self, PgConnection, ExpressionMethods, RunQueryDsl, QueryDsl};
|
||||
use schema::tags;
|
||||
|
||||
#[derive(Queryable)]
|
||||
#[derive(Serialize, Queryable)]
|
||||
pub struct Tag {
|
||||
pub id: i32,
|
||||
pub tag: String,
|
||||
@@ -20,4 +20,5 @@ pub struct NewTag {
|
||||
impl Tag {
|
||||
insert!(tags, NewTag);
|
||||
get!(tags);
|
||||
list_by!(tags, for_post, post_id as i32);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user