Merge pull request 'Do not link to authors of deleted entities' (#67) from StevenNMeza/teddit:unclickable_deleted_user into main

Reviewed-on: https://codeberg.org/teddit/teddit/pulls/67
This commit is contained in:
teddit 2020-12-15 19:28:16 +01:00
commit d32a263e49
7 changed files with 53 additions and 18 deletions

11
dist/css/styles.css vendored
View File

@ -573,6 +573,11 @@ input[type="submit"]:hover,
padding-left: 3px;
padding-right: 3px;
}
#links .link .entry .meta .deleted {
margin-left: 0 !important;
padding-left: 5px;
padding-right: 3px;
}
#links .link .entry .meta p {
float: inherit;
overflow-wrap: anywhere;
@ -805,7 +810,8 @@ input[type="submit"]:hover,
font-size: small;
color: #686868;
}
#post .submitted a {
#post .submitted a,
#post .submitted span {
margin-left: 5px;
}
#post .comments {
@ -815,7 +821,8 @@ input[type="submit"]:hover,
#post .comment .meta p.stickied {
color: green;
}
#post .comment .meta p.author a {
#post .comment .meta p.author a,
#post .comment .meta p.author span {
font-weight: initial;
margin-left: 10px;
}

View File

@ -3,6 +3,15 @@ module.exports = function() {
return new Promise((resolve, reject) => {
(async () => {
let comments_html
function commentAuthor(comment, classlist, submitter, moderator) {
let classes = classlist.join(' ')
if (comment.author === '[deleted]')
return `<span class="${classes}">[deleted]</span>`
else
return `<a href="/u/${comment.author}" class="${classes}">${comment.author}</a>${submitter || ''}${moderator || ''}`
}
if(comments.author !== undefined && comments.body_html !== undefined) {
let classlist = []
let submitter_link = ''
@ -32,13 +41,13 @@ module.exports = function() {
<div class="comment" id="${comments.id}">
<details open>
<summary>
<a href="/u/${comments.author}">${comments.author}${moderator ? moderator_badge : ''}</a>
<p class="author">${commentAuthor(comments, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
<p class="ups">${ups}</p>
<p class="created" title="${toUTCString(comments.created)}">${timeDifference(comments.created)}${edited_span}</p>
<p class="stickied">${comments.stickied ? 'stickied comment' : ''}</p>
</summary>
<div class="meta">
<p class="author"><a href="/u/${comments.author}" class="${classlist.join(' ')}">${comments.author}</a>${submitter ? submitter_link : ''}${moderator ? moderator_badge : ''}</p>
<p class="author">${commentAuthor(comments, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
<p class="ups">${ups}</p>
<p class="created" title="${toUTCString(comments.created)}">
<a href="${comments.permalink}">${timeDifference(comments.created)}${edited_span}</a>
@ -118,13 +127,13 @@ module.exports = function() {
<div class="comment" id="${comment.id}">
<details open>
<summary>
<a href="/u/${comment.author}">${comment.author}${moderator ? moderator_badge : ''}</a>
<p class="author">${commentAuthor(comment, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
<p class="ups">${ups}</p>
<p class="created" title="${toUTCString(comment.created)}">${timeDifference(comment.created)}${edited_span}</p>
<p class="stickied">${comment.stickied ? 'stickied comment' : ''}</p>
</summary>
<div class="meta">
<p class="author"><a href="/u/${comment.author}" class="${classlist.join(' ')}">${comment.author}</a>${submitter ? submitter_link : ''}${moderator ? moderator_badge : ''}</p>
<p class="author">${commentAuthor(comment, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
<p class="ups">${ups}</p>
<p class="created" title="${toUTCString(comment.created)}">
<a href="${comment.permalink}">${timeDifference(comment.created)}${edited_span}</a>

View File

@ -88,8 +88,11 @@ html
.meta
p.submitted submitted
span(title="" + toUTCString(link.created) + "") #{timeDifference(link.created)} by
a(href="/u/" + link.author + "")
| #{link.author}
if link.author === '[deleted]'
span(class="deleted") [deleted]
else
a(href="/u/" + link.author + "")
| #{link.author}
span(class="to") to
a(href="/r/" + link.subreddit + "")
| #{link.subreddit}

View File

@ -28,8 +28,11 @@ html
span(class="domain") (#{post.domain})
p.submitted
span(title="" + toUTCString(post.created) + "") submitted #{timeDifference(post.created)} by
a(href="/u/" + post.author + "")
| #{post.author}
if post.author === '[deleted]'
span [deleted]
else
a(href="/u/" + post.author + "")
| #{post.author}
if post.crosspost.is_crosspost === true
.crosspost
.title
@ -44,8 +47,11 @@ html
div.arrow.down
p.submitted
span(title="" + toUTCString(post.crosspost.created) + "") submitted #{timeDifference(post.crosspost.created)} by
a(href="/u/" + post.crosspost.author + "")
| #{post.crosspost.author}
if post.crosspost.author === '[deleted]'
span [deleted]
else
a(href="/u/" + post.crosspost.author + "")
| #{post.crosspost.author}
p.to to
a(href="/r/" + post.crosspost.subreddit + "")
| #{post.crosspost.subreddit}
@ -129,3 +135,4 @@ html
p you are viewing a single comment's thread.
a(href="" + post_url + "") view the rest of the comments →
!= comments

View File

@ -108,7 +108,12 @@ html
a(href="" + post.permalink + "") #{cleanTitle(post.title)}
.meta
p.submitted(title="" + toUTCString(post.created) + "") submitted #{timeDifference(post.created)} by
a(href="/u/" + post.author + "") #{post.author}
//- I believe finding posts by deleted authors is impossible
if post.author === '[deleted]'
span [deleted]
else
a(href="/u/" + post.author + "")
| #{post.author}
| to
a(href="/r/" + post.subreddit + "", class="subreddit") r/#{post.subreddit}
a.comments(href="" + post.permalink + "") #{post.num_comments} comments

View File

@ -96,8 +96,11 @@ html
.meta
p.submitted submitted
span(title="" + toUTCString(link.created) + "") #{timeDifference(link.created)} by
a(href="/u/" + link.author + "")
| #{link.author}
if link.author === '[deleted]'
span(class="deleted") [deleted]
else
a(href="/u/" + link.author + "")
| #{link.author}
p.to to
a(href="/r/" + link.subreddit + "")
| #{link.subreddit}
@ -146,3 +149,4 @@ html
each subreddit in subreddits
li
a(href="/r/" + subreddit + "") #{subreddit}

View File

@ -92,10 +92,10 @@ html
a(href="" + post.url + "") #{cleanTitle(post.link_title)}
.author
p by
if post.link_author !== '[deleted]'
a(href="/u/" + post.link_author + "") #{post.link_author}
else
if post.link_author === '[deleted]'
| [deleted]
else
a(href="/u/" + post.link_author + "") #{post.link_author}
.subreddit
p in
a(href="/r/" + post.subreddit + "") #{post.subreddit}