Add a link to author's profile on article card

Use a macro to render those cards too
This commit is contained in:
Bat
2018-05-13 18:19:23 +01:00
parent 5e7d513a7e
commit 91b19bccb5
8 changed files with 36 additions and 19 deletions
+5 -1
View File
@@ -227,7 +227,11 @@ impl User {
}
pub fn get_fqn(&self, conn: &PgConnection) -> String {
format!("{}@{}", self.username, self.get_instance(conn).public_domain)
if self.instance_id == Instance::local_id(conn) {
self.username.clone()
} else {
format!("{}@{}", self.username, self.get_instance(conn).public_domain)
}
}
pub fn get_followers(&self, conn: &PgConnection) -> Vec<User> {
+6 -1
View File
@@ -24,7 +24,12 @@ fn details(name: String, conn: DbConn, user: Option<User>) -> Template {
"recents": recents.into_iter().map(|p| {
json!({
"post": p,
"author": p.get_authors(&*conn)[0],
"author": ({
let author = &p.get_authors(&*conn)[0];
let mut json = serde_json::to_value(author).unwrap();
json["fqn"] = serde_json::Value::String(author.get_fqn(&*conn));
json
}),
"url": format!("/~/{}/{}/", p.get_blog(&*conn).actor_id, p.slug),
"date": p.creation_date.timestamp()
})
+6 -1
View File
@@ -21,7 +21,12 @@ fn index(conn: DbConn, user: Option<User>) -> Template {
"recents": recents.into_iter().map(|p| {
json!({
"post": p,
"author": p.get_authors(&*conn)[0],
"author": ({
let author = &p.get_authors(&*conn)[0];
let mut json = serde_json::to_value(author).unwrap();
json["fqn"] = serde_json::Value::String(author.get_fqn(&*conn));
json
}),
"url": format!("/~/{}/{}/", p.get_blog(&*conn).actor_id, p.slug),
"date": p.creation_date.timestamp()
})
+6 -1
View File
@@ -31,7 +31,12 @@ fn details(name: String, conn: DbConn, account: Option<User>) -> Template {
"recents": recents.into_iter().map(|p| {
json!({
"post": p,
"author": p.get_authors(&*conn)[0],
"author": ({
let author = &p.get_authors(&*conn)[0];
let mut json = serde_json::to_value(author).unwrap();
json["fqn"] = serde_json::Value::String(author.get_fqn(&*conn));
json
}),
"url": format!("/~/{}/{}/", p.get_blog(&*conn).actor_id, p.slug),
"date": p.creation_date.timestamp()
})