Do not link to authors of deleted entities

This commit is contained in:
StevenNMeza 2020-12-14 15:08:38 +01:00
parent d7ab5e1552
commit 6d6f7a0a44
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-left: 3px;
padding-right: 3px; padding-right: 3px;
} }
#links .link .entry .meta .deleted {
margin-left: 0 !important;
padding-left: 5px;
padding-right: 3px;
}
#links .link .entry .meta p { #links .link .entry .meta p {
float: inherit; float: inherit;
overflow-wrap: anywhere; overflow-wrap: anywhere;
@ -805,7 +810,8 @@ input[type="submit"]:hover,
font-size: small; font-size: small;
color: #686868; color: #686868;
} }
#post .submitted a { #post .submitted a,
#post .submitted span {
margin-left: 5px; margin-left: 5px;
} }
#post .comments { #post .comments {
@ -815,7 +821,8 @@ input[type="submit"]:hover,
#post .comment .meta p.stickied { #post .comment .meta p.stickied {
color: green; color: green;
} }
#post .comment .meta p.author a { #post .comment .meta p.author a,
#post .comment .meta p.author span {
font-weight: initial; font-weight: initial;
margin-left: 10px; margin-left: 10px;
} }

View File

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

View File

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

View File

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

View File

@ -108,7 +108,12 @@ html
a(href="" + post.permalink + "") #{cleanTitle(post.title)} a(href="" + post.permalink + "") #{cleanTitle(post.title)}
.meta .meta
p.submitted(title="" + toUTCString(post.created) + "") submitted #{timeDifference(post.created)} by 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 | to
a(href="/r/" + post.subreddit + "", class="subreddit") r/#{post.subreddit} a(href="/r/" + post.subreddit + "", class="subreddit") r/#{post.subreddit}
a.comments(href="" + post.permalink + "") #{post.num_comments} comments a.comments(href="" + post.permalink + "") #{post.num_comments} comments

View File

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

View File

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