mirror of
https://codeberg.org/tacerus/teddit.git
synced 2025-01-09 12:52:32 +01:00
add [score hidden] feature for comments
This commit is contained in:
parent
f27f27041e
commit
ad125a592b
@ -19,18 +19,23 @@ module.exports = function() {
|
|||||||
moderator_badge = ` <span class="green" title="moderator of this subreddit">[M]</span>`
|
moderator_badge = ` <span class="green" title="moderator of this subreddit">[M]</span>`
|
||||||
moderator = true
|
moderator = true
|
||||||
}
|
}
|
||||||
|
if(comments.score_hidden) {
|
||||||
|
ups = `<span class="score-hidden">[score hidden]</span>`
|
||||||
|
} else {
|
||||||
|
ups = `${kFormatter(comments.ups)} points`
|
||||||
|
}
|
||||||
comments_html = `
|
comments_html = `
|
||||||
<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>
|
<a href="/u/${comments.author}">${comments.author}${moderator ? moderator_badge : ''}</a>
|
||||||
<p class="ups">${kFormatter(comments.ups)} points</p>
|
<p class="ups">${ups}</p>
|
||||||
<p class="created" title="${toUTCString(comments.created)}">${timeDifference(comments.created)}</p>
|
<p class="created" title="${toUTCString(comments.created)}">${timeDifference(comments.created)}</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"><a href="/u/${comments.author}" class="${classlist.join(' ')}">${comments.author}</a>${submitter ? submitter_link : ''}${moderator ? moderator_badge : ''}</p>
|
||||||
<p class="ups">${kFormatter(comments.ups)} points</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)}</a>
|
<a href="${comments.permalink}">${timeDifference(comments.created)}</a>
|
||||||
</p>
|
</p>
|
||||||
@ -84,29 +89,35 @@ module.exports = function() {
|
|||||||
let submitter_link = ''
|
let submitter_link = ''
|
||||||
let moderator = false
|
let moderator = false
|
||||||
let submitter = false
|
let submitter = false
|
||||||
|
let ups = ''
|
||||||
|
|
||||||
if(post_author === comment.author) {
|
if(post_author === comment.author) {
|
||||||
classlist.push('submitter')
|
classlist.push('submitter')
|
||||||
submitter_link = `<a href="${post_url}" title="submitter">[S]</a>`
|
submitter_link = `<a href="${post_url}" title="submitter">[S]</a>`
|
||||||
submitter = true
|
submitter = true
|
||||||
}
|
}
|
||||||
if(comments.distinguished === 'moderator') {
|
if(comment.distinguished === 'moderator') {
|
||||||
classlist.push('green')
|
classlist.push('green')
|
||||||
moderator_badge = ` <span class="green" title="moderator of this subreddit">[M]</span>`
|
moderator_badge = ` <span class="green" title="moderator of this subreddit">[M]</span>`
|
||||||
moderator = true
|
moderator = true
|
||||||
}
|
}
|
||||||
|
if(comment.score_hidden) {
|
||||||
|
ups = `<span class="score-hidden">[score hidden]</span>`
|
||||||
|
} else {
|
||||||
|
ups = `${kFormatter(comment.ups)} points`
|
||||||
|
}
|
||||||
comments_html += `
|
comments_html += `
|
||||||
<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>
|
<a href="/u/${comment.author}">${comment.author}${moderator ? moderator_badge : ''}</a>
|
||||||
<p class="ups">${kFormatter(comment.ups)} points</p>
|
<p class="ups">${ups}</p>
|
||||||
<p class="created" title="${toUTCString(comment.created)}">${timeDifference(comment.created)}</p>
|
<p class="created" title="${toUTCString(comment.created)}">${timeDifference(comment.created)}</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"><a href="/u/${comment.author}" class="${classlist.join(' ')}">${comment.author}</a>${submitter ? submitter_link : ''}${moderator ? moderator_badge : ''}</p>
|
||||||
<p class="ups">${kFormatter(comment.ups)} points</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)}</a>
|
<a href="${comment.permalink}">${timeDifference(comment.created)}</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -138,6 +138,7 @@ module.exports = function(fetch) {
|
|||||||
permalink: comment.permalink,
|
permalink: comment.permalink,
|
||||||
stickied: comment.stickied,
|
stickied: comment.stickied,
|
||||||
distinguished: comment.distinguished,
|
distinguished: comment.distinguished,
|
||||||
|
score_hidden: comment.score_hidden,
|
||||||
replies: []
|
replies: []
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -212,6 +213,7 @@ module.exports = function(fetch) {
|
|||||||
permalink: reply.permalink,
|
permalink: reply.permalink,
|
||||||
stickied: reply.stickied,
|
stickied: reply.stickied,
|
||||||
distinguished: reply.distinguished,
|
distinguished: reply.distinguished,
|
||||||
|
score_hidden: reply.score_hidden,
|
||||||
replies: []
|
replies: []
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -243,6 +245,8 @@ module.exports = function(fetch) {
|
|||||||
ups: comment.ups,
|
ups: comment.ups,
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
permalink: comment.permalink,
|
permalink: comment.permalink,
|
||||||
|
score_hidden: comment.score_hidden,
|
||||||
|
distinguished: comment.distinguished,
|
||||||
replies: []
|
replies: []
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -342,7 +342,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let key = `${subreddit}:${after}:${before}:sort:${sortby}:past:${past}`
|
let key = `${subreddit.toLowerCase()}:${after}:${before}:sort:${sortby}:past:${past}`
|
||||||
redis.get(key, (error, json) => {
|
redis.get(key, (error, json) => {
|
||||||
if(error) {
|
if(error) {
|
||||||
console.error(`Error getting the ${subreddit} key from redis.`, error)
|
console.error(`Error getting the ${subreddit} key from redis.`, error)
|
||||||
|
Loading…
Reference in New Issue
Block a user