Skip to content

Commit

Permalink
feat: show post link title for comments on user page (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie authored Jul 1, 2024
1 parent d9e7681 commit 366bc17
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ pub struct Post {
pub body: String,
pub author: Author,
pub permalink: String,
pub link_title: String,
pub poll: Option<Poll>,
pub score: (String, String),
pub upvote_ratio: i64,
Expand Down Expand Up @@ -411,6 +412,7 @@ impl Post {
stickied: data["stickied"].as_bool().unwrap_or_default() || data["pinned"].as_bool().unwrap_or_default(),
},
permalink: val(post, "permalink"),
link_title: val(post, "link_title"),
poll: Poll::parse(&data["poll_data"]),
rel_time,
created,
Expand Down Expand Up @@ -715,6 +717,7 @@ pub async fn parse_post(post: &Value) -> Post {
distinguished: val(post, "distinguished"),
},
permalink,
link_title: val(post, "link_title"),
poll,
score: format_num(score),
upvote_ratio: ratio as i64,
Expand Down
20 changes: 19 additions & 1 deletion static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1255,10 +1255,28 @@ a.search_subreddit:hover {
min-width: 0;
}

.comment_data > * {
.comment:has([id]) .comment_data > * {
margin-right: 5px;
}

.comment:not([id]) .comment_data {
display: inline-flex;
max-width: 100%;
}

.comment:not([id]) .comment_data > * {
flex: 0 0 auto;
}

.comment:not([id]) .comment_data > .comment_link {
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
word-break: break-all;
overflow: hidden;
flex: 0 1 auto;
}

.comment_image {
max-width: 500px;
align-self: center;
Expand Down
6 changes: 4 additions & 2 deletions templates/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
</div>
<details class="comment_right" open>
<summary class="comment_data">
<a class="comment_link" href="{{ post.permalink }}">Comment on r/{{ post.community }}</a>
<span class="created" title="{{ post.created }}">{{ post.rel_time }}</span>
<a class="comment_link" href="{{ post.permalink }}" title="{{ post.link_title }}">{{ post.link_title }}</a>
<span class="created">&nbsp;in&nbsp;</span>
<a href="/r/{{ post.community }}">r/{{ post.community }}</a>
<span class="created" title="{{ post.created }}">&nbsp;{{ post.rel_time }}</span>
</summary>
<p class="comment_body">{{ post.body|safe }}</p>
</details>
Expand Down

0 comments on commit 366bc17

Please sign in to comment.