diff --git a/src/models/users.rs b/src/models/users.rs index 1b58710..8677154 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -45,6 +45,7 @@ use models::{ posts::Post }; use schema::users; +use safe_string::SafeString; pub const AUTH_COOKIE: &'static str = "user_id"; @@ -56,7 +57,7 @@ pub struct User { pub outbox_url: String, pub inbox_url: String, pub is_admin: bool, - pub summary: String, + pub summary: SafeString, pub email: Option, pub hashed_password: Option, pub instance_id: i32, @@ -75,7 +76,7 @@ pub struct NewUser { pub outbox_url: String, pub inbox_url: String, pub is_admin: bool, - pub summary: String, + pub summary: SafeString, pub email: Option, pub hashed_password: Option, pub instance_id: i32, @@ -200,7 +201,7 @@ impl User { outbox_url: acct["outbox"].as_str().unwrap().to_string(), inbox_url: acct["inbox"].as_str().unwrap().to_string(), is_admin: false, - summary: acct["summary"].as_str().unwrap().to_string(), + summary: SafeString::new(&acct["summary"].as_str().unwrap().to_string()), email: None, hashed_password: None, instance_id: instance.id, @@ -371,7 +372,7 @@ impl APActor for User { } fn get_summary(&self) -> String { - self.summary.clone() + self.summary.get().clone() } fn get_instance(&self, conn: &PgConnection) -> Instance { @@ -561,7 +562,7 @@ impl NewUser { outbox_url: String::from(""), inbox_url: String::from(""), is_admin: is_admin, - summary: summary, + summary: SafeString::new(&summary), email: Some(email), hashed_password: Some(password), instance_id: instance_id, diff --git a/templates/macros.html.tera b/templates/macros.html.tera index 4943265..3cce728 100644 --- a/templates/macros.html.tera +++ b/templates/macros.html.tera @@ -1,7 +1,12 @@ {% macro post_card(article) %} + {% if article.author.display_name %} + {% set name = article.author.display_name %} + {% else %} + {% set name = article.author.username %} + {% endif %}

{{ article.post.title }}

{{ article.post.content | striptags | truncate(length=200) }}

-

By {{ article.author.display_name }} ⋅ {{ article.date | date(format="%B %e") }}

+

By {{ name }} ⋅ {{ article.date | date(format="%B %e") }}

{% endmacro post_card %} diff --git a/templates/posts/details.html.tera b/templates/posts/details.html.tera index 5c658d3..52e71b3 100644 --- a/templates/posts/details.html.tera +++ b/templates/posts/details.html.tera @@ -8,9 +8,15 @@ {{ blog.title }} {% endblock header %} +{% if author.display_name %} + {% set name = author.display_name %} +{% else %} + {% set name = author.username %} +{% endif %} + {% block content %}

- Written by {{ author.display_name }} + Written by {{ name }}{{ date | date(format="%B %e, %Y") }}

@@ -49,8 +55,13 @@

Comments

{% for comment in comments %} + {% if comment.author.display_name %} + {% set comment_author_name = comment.author.display_name %} + {% else %} + {% set comment_author_name = comment.author.username %} + {% endif %}
- {{ comment.author.display_name }} + {{ comment_author_name }}
{{ comment.content | safe }}
Respond
diff --git a/templates/users/details.html.tera b/templates/users/details.html.tera index ca681b2..51d6f94 100644 --- a/templates/users/details.html.tera +++ b/templates/users/details.html.tera @@ -1,14 +1,20 @@ {% extends "base" %} {% import "macros" as macros %} +{% if user.display_name %} + {% set name = user.display_name %} +{% else %} + {% set name = user.username %} +{% endif %} + {% block title %} -{{ user.display_name }} +{{ name }} {% endblock title %} {% block content %}

- {{ user.display_name }} + {{ name }} {% if user.is_admin %} Admin {% endif %} @@ -28,7 +34,7 @@

- {{ user.summary }} + {{ user.summary | safe }}
{% if recents | length != 0 %} diff --git a/templates/users/followers.html.tera b/templates/users/followers.html.tera index ed6a824..595f6ae 100644 --- a/templates/users/followers.html.tera +++ b/templates/users/followers.html.tera @@ -1,13 +1,19 @@ {% extends "base" %} +{% if user.display_name %} + {% set name = user.display_name %} +{% else %} + {% set name = user.username %} +{% endif %} + {% block title %} -{{ user.display_name }}'s Followers +{{ name }}'s Followers {% endblock title %} {% block content %}

- {{ user.display_name }} + {{ name }} {% if user.is_admin %} Admin {% endif %} @@ -21,9 +27,14 @@

Followers

{% for follower in followers %} + {% if follower.display_name %} + {% set follower_name = follower.display_name %} + {% else %} + {% set follower_name = follower.username %} + {% endif %}
-

{{ follower.display_name }} — @{{ follower.fqn }}

-

{{ follower.summary }}

+

{{ follower_name }} — @{{ follower.fqn }}

+

{{ follower.summary | safe }}

{% endfor %}