feat: show post link title for comments on user page (#169)

This commit is contained in:
Pim 2024-07-01 23:15:50 +02:00 committed by GitHub
parent d9e7681004
commit 366bc17f97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 3 deletions

View File

@ -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,
@ -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,
@ -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,

View File

@ -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;

View File

@ -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>