mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-22 23:09:28 +01:00
Merge pull request '#91 added preference to highlight controversial comments' (#97) from juzz/teddit:controversial into main
Reviewed-on: https://codeberg.org/teddit/teddit/pulls/97
This commit is contained in:
commit
448a6798e9
6
app.js
6
app.js
@ -117,6 +117,12 @@ const preferencesMiddleware = (req, res, next) => {
|
|||||||
req.cookies.nsfw_enabled = nsfwEnabledOverride
|
req.cookies.nsfw_enabled = nsfwEnabledOverride
|
||||||
res.cookie('nsfw_enabled', nsfwEnabledOverride, { maxAge: 31536000, httpOnly: true })
|
res.cookie('nsfw_enabled', nsfwEnabledOverride, { maxAge: 31536000, httpOnly: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let highlightControversialOverride = req.query.highlight_controversial
|
||||||
|
if(highlightControversialOverride) {
|
||||||
|
req.cookies.highlight_controversial = highlightControversialOverride
|
||||||
|
res.cookie('highlight_controversial', highlightControversialOverride, { maxAge: 31536000, httpOnly: true })
|
||||||
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ const config = {
|
|||||||
cert_dir: process.env.CERT_DIR || '', // For example '/home/teddit/letsencrypt/live/teddit.net', if you are using https. No trailing slash.
|
cert_dir: process.env.CERT_DIR || '', // For example '/home/teddit/letsencrypt/live/teddit.net', if you are using https. No trailing slash.
|
||||||
theme: process.env.THEME || 'dark', // One of: 'dark', ''
|
theme: process.env.THEME || 'dark', // One of: 'dark', ''
|
||||||
flairs_enabled: process.env.FLAIRS_ENABLED !== 'true' || true, // Enables the rendering of user and link flairs on teddit
|
flairs_enabled: process.env.FLAIRS_ENABLED !== 'true' || true, // Enables the rendering of user and link flairs on teddit
|
||||||
|
highlight_controversial: process.env.HIGHLIGHT_CONTROVERSIAL !== 'true' || true, // Enables controversial comments to be indicated by a typographical dagger (†)
|
||||||
api_enabled: process.env.API_ENABLED !== 'true' || true, // Teddit API feature. Might increase loads significantly on your instance.
|
api_enabled: process.env.API_ENABLED !== 'true' || true, // Teddit API feature. Might increase loads significantly on your instance.
|
||||||
video_enabled: process.env.VIDEO_ENABLED !== 'true' || true,
|
video_enabled: process.env.VIDEO_ENABLED !== 'true' || true,
|
||||||
redis_enabled: process.env.REDIS_ENABLED !== 'true' || true, // If disabled, does not cache Reddit API calls
|
redis_enabled: process.env.REDIS_ENABLED !== 'true' || true, // If disabled, does not cache Reddit API calls
|
||||||
|
@ -17,6 +17,7 @@ module.exports = function() {
|
|||||||
let moderator = false
|
let moderator = false
|
||||||
let submitter = false
|
let submitter = false
|
||||||
let edited_span = ''
|
let edited_span = ''
|
||||||
|
let controversial_span = ''
|
||||||
|
|
||||||
if(post_author === comments.author) {
|
if(post_author === comments.author) {
|
||||||
classlist.push('submitter')
|
classlist.push('submitter')
|
||||||
@ -36,6 +37,9 @@ module.exports = function() {
|
|||||||
if(comments.edited) {
|
if(comments.edited) {
|
||||||
edited_span = `<span title="this comment is edited">*</span>`
|
edited_span = `<span title="this comment is edited">*</span>`
|
||||||
}
|
}
|
||||||
|
if(comments.controversiality > 0) {
|
||||||
|
controversial_span = `<span class="controversial">†</span>`
|
||||||
|
}
|
||||||
comments_html = `
|
comments_html = `
|
||||||
<div class="comment ${comments.depth % 2 === 0 ? 'even-depth' : 'odd-depth'}" id="${comments.id}">
|
<div class="comment ${comments.depth % 2 === 0 ? 'even-depth' : 'odd-depth'}" id="${comments.id}">
|
||||||
<details open>
|
<details open>
|
||||||
@ -48,7 +52,7 @@ module.exports = function() {
|
|||||||
<div class="meta">
|
<div class="meta">
|
||||||
<p class="author">${commentAuthor(comments, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
|
<p class="author">${commentAuthor(comments, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
|
||||||
<p>${comments.user_flair}</p>
|
<p>${comments.user_flair}</p>
|
||||||
<p class="ups">${ups}</p>
|
<p class="ups">${ups}${controversial_span}</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>
|
||||||
</p>
|
</p>
|
||||||
@ -109,6 +113,7 @@ module.exports = function() {
|
|||||||
let submitter = false
|
let submitter = false
|
||||||
let ups = ''
|
let ups = ''
|
||||||
let edited_span = ''
|
let edited_span = ''
|
||||||
|
let controversial_span = ''
|
||||||
|
|
||||||
if(post_author === comment.author) {
|
if(post_author === comment.author) {
|
||||||
classlist.push('submitter')
|
classlist.push('submitter')
|
||||||
@ -128,6 +133,9 @@ module.exports = function() {
|
|||||||
if(comment.edited) {
|
if(comment.edited) {
|
||||||
edited_span = `<span title="this comment is edited">*</span>`
|
edited_span = `<span title="this comment is edited">*</span>`
|
||||||
}
|
}
|
||||||
|
if(comment.controversiality > 0) {
|
||||||
|
controversial_span = `<span class="controversial">†</span>`
|
||||||
|
}
|
||||||
comments_html += `
|
comments_html += `
|
||||||
<div class="comment ${comment.depth % 2 === 0 ? 'even-depth' : 'odd-depth'}" id="${comment.id}">
|
<div class="comment ${comment.depth % 2 === 0 ? 'even-depth' : 'odd-depth'}" id="${comment.id}">
|
||||||
<details open>
|
<details open>
|
||||||
@ -140,7 +148,7 @@ module.exports = function() {
|
|||||||
<div class="meta">
|
<div class="meta">
|
||||||
<p class="author">${commentAuthor(comment, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
|
<p class="author">${commentAuthor(comment, classlist, submitter && submitter_link, moderator && moderator_badge)}</p>
|
||||||
<p>${comment.user_flair}</p>
|
<p>${comment.user_flair}</p>
|
||||||
<p class="ups">${ups}</p>
|
<p class="ups">${ups}${controversial_span}</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>
|
||||||
</p>
|
</p>
|
||||||
|
@ -153,7 +153,8 @@ module.exports = function(fetch) {
|
|||||||
edited: comment.edited,
|
edited: comment.edited,
|
||||||
replies: [],
|
replies: [],
|
||||||
depth: 0,
|
depth: 0,
|
||||||
user_flair: (user_preferences.flairs != 'false' ? await formatUserFlair(comment) : '')
|
user_flair: (user_preferences.flairs != 'false' ? await formatUserFlair(comment) : ''),
|
||||||
|
controversiality: (user_preferences.highlight_controversial != 'false' ? comment.controversiality : '')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obj = {
|
obj = {
|
||||||
@ -231,7 +232,8 @@ module.exports = function(fetch) {
|
|||||||
edited: reply.edited,
|
edited: reply.edited,
|
||||||
replies: [],
|
replies: [],
|
||||||
depth: depth,
|
depth: depth,
|
||||||
user_flair: (user_preferences.flairs != 'false' ? await formatUserFlair(reply) : '')
|
user_flair: (user_preferences.flairs != 'false' ? await formatUserFlair(reply) : ''),
|
||||||
|
controversiality: (user_preferences.highlight_controversial != 'false' ? reply.controversiality : '')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obj = {
|
obj = {
|
||||||
@ -267,7 +269,8 @@ module.exports = function(fetch) {
|
|||||||
distinguished: comment.edited,
|
distinguished: comment.edited,
|
||||||
replies: [],
|
replies: [],
|
||||||
depth: depth + 1,
|
depth: depth + 1,
|
||||||
user_flair: (user_preferences.flairs != 'false' ? await formatUserFlair(comment) : '')
|
user_flair: (user_preferences.flairs != 'false' ? await formatUserFlair(comment) : ''),
|
||||||
|
controversiality: (user_preferences.highlight_controversial != 'false' ? comment.controversiality : '')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
objct = {
|
objct = {
|
||||||
|
10
routes.js
10
routes.js
@ -22,6 +22,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||||||
res.clearCookie('theme')
|
res.clearCookie('theme')
|
||||||
res.clearCookie('flairs')
|
res.clearCookie('flairs')
|
||||||
res.clearCookie('nsfw_enabled')
|
res.clearCookie('nsfw_enabled')
|
||||||
|
res.clearCookie("highlight_controversial")
|
||||||
return res.redirect('/preferences')
|
return res.redirect('/preferences')
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -783,6 +784,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||||||
let theme = req.body.theme
|
let theme = req.body.theme
|
||||||
let flairs = req.body.flairs
|
let flairs = req.body.flairs
|
||||||
let nsfw_enabled = req.body.nsfw_enabled
|
let nsfw_enabled = req.body.nsfw_enabled
|
||||||
|
let highlight_controversial = req.body.highlight_controversial
|
||||||
|
|
||||||
res.cookie('theme', theme, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
res.cookie('theme', theme, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
||||||
|
|
||||||
@ -797,7 +799,13 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
|||||||
else
|
else
|
||||||
nsfw_enabled = 'false'
|
nsfw_enabled = 'false'
|
||||||
res.cookie('nsfw_enabled', nsfw_enabled, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
res.cookie('nsfw_enabled', nsfw_enabled, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
||||||
|
|
||||||
|
if(highlight_controversial === 'on')
|
||||||
|
highlight_controversial = 'true'
|
||||||
|
else
|
||||||
|
highlight_controversial = 'false'
|
||||||
|
res.cookie('highlight_controversial', highlight_controversial, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
||||||
|
|
||||||
return res.redirect('/preferences')
|
return res.redirect('/preferences')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -640,6 +640,13 @@ footer a {
|
|||||||
.comment .meta .created a {
|
.comment .meta .created a {
|
||||||
color: var(--graytext);
|
color: var(--graytext);
|
||||||
}
|
}
|
||||||
|
.comment .meta span.controversial {
|
||||||
|
font-size: var(--sm-font);
|
||||||
|
display:inline-block;
|
||||||
|
vertical-align: baseline;
|
||||||
|
position: relative;
|
||||||
|
top: -0.4em;
|
||||||
|
}
|
||||||
.comment .body {
|
.comment .body {
|
||||||
float: left;
|
float: left;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -25,6 +25,12 @@ html
|
|||||||
input(type="checkbox", name="flairs", id="flairs", checked="checked")
|
input(type="checkbox", name="flairs", id="flairs", checked="checked")
|
||||||
else
|
else
|
||||||
input(type="checkbox", name="flairs", id="flairs")
|
input(type="checkbox", name="flairs", id="flairs")
|
||||||
|
.setting
|
||||||
|
label(for="highlight_controversial") Show a dagger (†) on comments voted controversial:
|
||||||
|
if(!user_preferences.highlight_controversial || user_preferences.highlight_controversial == 'true')
|
||||||
|
input(type="checkbox", name="highlight_controversial", id="highlight_controversial", checked="checked")
|
||||||
|
else
|
||||||
|
input(type="checkbox", name="highlight_controversial", id="highlight_controversial")
|
||||||
.setting
|
.setting
|
||||||
label(for="nsfw_enabled") Show NSFW content:
|
label(for="nsfw_enabled") Show NSFW content:
|
||||||
if (instance_config.nsfw_enabled === false && user_preferences.nsfw_enabled != 'true') || user_preferences.nsfw_enabled === 'false'
|
if (instance_config.nsfw_enabled === false && user_preferences.nsfw_enabled != 'true') || user_preferences.nsfw_enabled === 'false'
|
||||||
|
Loading…
Reference in New Issue
Block a user