View remote profiles locally

Add a link to the profile on the real instance
This commit is contained in:
Bat 2018-06-13 18:48:37 +01:00
parent 51c598a0fc
commit 1c287c6dfe
3 changed files with 14 additions and 2 deletions

View file

@ -41,7 +41,9 @@ fn details(name: String, conn: DbConn, account: Option<User>) -> Template {
let n_followers = user.get_followers(&*conn).len(); let n_followers = user.get_followers(&*conn).len();
Template::render("users/details", json!({ Template::render("users/details", json!({
"user": serde_json::to_value(user).unwrap(), "user": serde_json::to_value(user.clone()).unwrap(),
"instance_url": user.get_instance(&*conn).public_domain,
"is_remote": user.instance_id != Instance::local_id(&*conn),
"account": account, "account": account,
"recents": recents.into_iter().map(|p| { "recents": recents.into_iter().map(|p| {
json!({ json!({
@ -116,6 +118,8 @@ fn followers(name: String, conn: DbConn, account: Option<User>) -> Template {
Template::render("users/followers", json!({ Template::render("users/followers", json!({
"user": serde_json::to_value(user.clone()).unwrap(), "user": serde_json::to_value(user.clone()).unwrap(),
"instance_url": user.get_instance(&*conn).public_domain,
"is_remote": user.instance_id != Instance::local_id(&*conn),
"followers": user.get_followers(&*conn).into_iter().map(|f| { "followers": user.get_followers(&*conn).into_iter().map(|f| {
let fqn = f.get_fqn(&*conn); let fqn = f.get_fqn(&*conn);
let mut json = serde_json::to_value(f).unwrap(); let mut json = serde_json::to_value(f).unwrap();

View file

@ -27,6 +27,10 @@
{% if is_self %} {% if is_self %}
<a href="edit" class="button inline-block">Edit your profile</a> <a href="edit" class="button inline-block">Edit your profile</a>
{% endif %} {% endif %}
{% if is_remote %}
<a class="inline-block button" href="{{ user.ap_url }}">Open on {{ instance_url }}</a>
{% endif %}
</div> </div>
<div> <div>

View file

@ -22,6 +22,10 @@
<span class="badge">It is you</span> <span class="badge">It is you</span>
{% endif %} {% endif %}
</h1> </h1>
{% if is_remote %}
<a class="inline-block button" href="{{ user.ap_url }}">Open on {{ instance_url }}</a>
{% endif %}
</div> </div>
<h2>Followers</h2> <h2>Followers</h2>
@ -33,7 +37,7 @@
{% set follower_name = follower.username %} {% set follower_name = follower.username %}
{% endif %} {% endif %}
<div class="card"> <div class="card">
<h3><a href="{{ follower.ap_url }}/">{{ follower_name }}</a> &mdash; @{{ follower.fqn }}</h3> <h3><a href="/@/{{ follower.fqn }}/">{{ follower_name }}</a> &mdash; @{{ follower.fqn }}</h3>
<main><p>{{ follower.summary | safe }}</p></main> <main><p>{{ follower.summary | safe }}</p></main>
</div> </div>
{% endfor %} {% endfor %}