diff --git a/src/domain/comment.rs b/src/domain/comment.rs index 532f4c9..7f800b2 100644 --- a/src/domain/comment.rs +++ b/src/domain/comment.rs @@ -13,6 +13,6 @@ pub struct CommentEntry { impl CommentEntry { pub fn formatted_date(&self) -> String { - self.published_at.format("%B %d, %Y").to_string() + self.published_at.format("%B %d, %Y %H:%M").to_string() } } diff --git a/src/domain/post.rs b/src/domain/post.rs index 62ffe62..8d80da1 100644 --- a/src/domain/post.rs +++ b/src/domain/post.rs @@ -5,6 +5,7 @@ pub struct PostEntry { pub post_id: Uuid, pub author_id: Uuid, pub author: String, + pub full_name: Option, pub title: String, pub content: String, pub published_at: DateTime, @@ -13,13 +14,9 @@ pub struct PostEntry { impl PostEntry { pub fn formatted_date(&self) -> String { - self.published_at.format("%B %d, %Y").to_string() + self.published_at.format("%B %d, %Y %H:%M").to_string() } - // pub fn last_modified(&self) -> String { - // if let Some(last_modified) = self.last_modi - // } - pub fn to_html(&self) -> anyhow::Result { match markdown::to_html_with_options(&self.content, &markdown::Options::gfm()) { Ok(content) => Ok(content), diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 2f9f137..90232a4 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -78,7 +78,7 @@ async fn get_posts( sqlx::query_as!( PostEntry, r#" - SELECT p.post_id, p.author_id, u.username AS author, + SELECT p.post_id, p.author_id, u.username AS author, u.full_name, p.title, p.content, p.published_at, p.last_modified FROM posts p LEFT JOIN users u ON p.author_id = u.user_id @@ -101,7 +101,7 @@ pub async fn get_posts_page( sqlx::query_as!( PostEntry, r#" - SELECT p.post_id, p.author_id, u.username AS author, + SELECT p.post_id, p.author_id, u.username AS author, u.full_name, p.title, p.content, p.published_at, p.last_modified FROM posts p LEFT JOIN users u ON p.author_id = u.user_id @@ -261,7 +261,7 @@ async fn get_post_data( sqlx::query_as!( PostEntry, r#" - SELECT p.post_id, p.author_id, u.username AS author, + SELECT p.post_id, p.author_id, u.username AS author, u.full_name, p.title, p.content, p.published_at, last_modified FROM posts p LEFT JOIN users u ON p.author_id = u.user_id diff --git a/src/routes/users.rs b/src/routes/users.rs index 4f575fa..bb1d06f 100644 --- a/src/routes/users.rs +++ b/src/routes/users.rs @@ -322,7 +322,7 @@ async fn fetch_user_posts( sqlx::query_as!( PostEntry, r#" - SELECT p.author_id, u.username as author, + SELECT p.author_id, u.username as author, u.full_name, p.post_id, p.title, p.content, p.published_at, p.last_modified FROM posts p INNER JOIN users u ON p.author_id = u.user_id diff --git a/templates/dashboard/comments/card.html b/templates/dashboard/comments/card.html index ae01d63..31bf2c8 100644 --- a/templates/dashboard/comments/card.html +++ b/templates/dashboard/comments/card.html @@ -5,7 +5,7 @@
{% if let Some(user_id) = comment.user_id %} + class="font-semibold text-blue-800 hover:text-blue-600 hover:underline"> {{ comment.username.as_ref().unwrap() }} {% else %} diff --git a/templates/posts/card.html b/templates/posts/card.html index 0615704..8707208 100644 --- a/templates/posts/card.html +++ b/templates/posts/card.html @@ -3,16 +3,17 @@
-

{{ - post.title }}

+

+ {{ + post.title }} +

- +
@@ -35,9 +41,9 @@ fill="none" viewBox="0 0 24 24" stroke="currentColor"> - +
- \ No newline at end of file + diff --git a/templates/posts/page.html b/templates/posts/page.html index 3ebab8a..2784103 100644 --- a/templates/posts/page.html +++ b/templates/posts/page.html @@ -17,7 +17,13 @@ {{ post.author }} + class="hover:text-blue-600 hover:underline font-medium"> + {% if let Some(full_name) = post.full_name %} + {{ full_name }} + {% else %} + {{ post.author }} + {% endif %} +
{% if let Some(modified) = post.last_modified %} - Last modified on {{ modified.format("%B %d, %Y") }}, at {{ modified.format("%H:%M") }} + Last modified on {{ modified.format("%B %d, %Y") }} at {{ modified.format("%H:%M") }} {% endif %} {% if session_user_id.as_ref() == Some(post.author_id) %}