Add a link to author's profile on article card
Use a macro to render those cards too
This commit is contained in:
+5
-1
@@ -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
@@ -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()
|
||||
})
|
||||
|
||||
@@ -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
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user