Add option to hide posts upvotes and comments points

This commit is contained in:
sartateme 2022-01-31 15:31:00 +01:00
parent 3ef2f004ea
commit 274a8be24e
7 changed files with 29 additions and 1605 deletions

View File

@ -36,6 +36,7 @@ const config = {
cache_control: !('CACHE_CONTROL' in process.env) || process.env.CACHE_CONTROL === 'true', // If true, teddit will automatically remove all cached static files. By default this is set to true.
cache_control_interval: process.env.CACHE_CONTROL_INTERVAL || 24, // How often the cache directory for static files is emptied (in hours). Requires cache_control to be true. Default is every 24 hours.
show_upvoted_percentage: !('SHOW_UPVOTED_PERCENTAGE' in process.env) || process.env.SHOW_UPVOTED_PERCENTAGE === 'true',
show_upvotes: !('SHOW_UPVOTES' in process.env) || process.env.SHOW_UPVOTES === 'true', // If true, teddit will show number of upvotes in posts and points in comments.
post_media_max_heights: {
/**
* Sets the max-height value for images and videos in posts.

1606
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ function resetPreferences(res) {
res.clearCookie('post_media_max_height');
res.clearCookie('collapse_child_comments');
res.clearCookie('show_upvoted_percentage');
res.clearCookie('show_upvotes')
res.clearCookie('subbed_subreddits');
res.clearCookie('domain_twitter');
res.clearCookie('domain_youtube');
@ -82,6 +83,7 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => {
let post_media_max_height = req.body.post_media_max_height;
let collapse_child_comments = req.body.collapse_child_comments;
let show_upvoted_percentage = req.body.show_upvoted_percentage;
let show_upvotes = req.body.show_upvotes;
let domain_twitter = req.body.domain_twitter;
let domain_youtube = req.body.domain_youtube;
let domain_instagram = req.body.domain_instagram;
@ -136,6 +138,13 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => {
httpOnly: true,
});
if (show_upvotes === 'on') show_upvotes = 'true';
else show_upvotes = 'false';
res.cookie('show_upvotes', show_upvotes, {
maxAge: 365 * 24 * 60 * 60 * 1000,
httpOnly: true,
});
if (videos_muted === 'on') videos_muted = 'true';
else videos_muted = 'false';
res.cookie('videos_muted', videos_muted, {

View File

@ -1,4 +1,9 @@
.link
if user_preferences.show_upvotes === 'false'
style.
.upvotes {
display: none;
}
.upvotes
.arrow
span #{kFormatter(link.ups)}

View File

@ -38,6 +38,7 @@ html
#intro
h1 Welcome to teddit
h2 the alternative, privacy respecting, front page of internet.
#links.sr
if sortby === 'top' || sortby === 'controversial'
details

View File

@ -46,6 +46,12 @@ html
video_muted = false
}
.info
if user_preferences.show_upvotes === 'false'
style.
.comment .meta .ups, #post .score, #user .upvotes {
display: none;
}
.score
div.arrow
span #{kFormatter(post.ups)}

View File

@ -96,6 +96,12 @@ html
input(type="checkbox", name="show_upvoted_percentage", id="show_upvoted_percentage", checked="checked")
else
input(type="checkbox", name="show_upvoted_percentage", id="show_upvoted_percentage")
.setting
label(for="show_upvotes") Show upvotes:
if (user_preferences.show_upvotes == 'true')
input(type="checkbox", name="show_upvotes", id="show_upvotes", checked="checked")
else
input(type="checkbox", name="show_upvotes", id="show_upvotes")
legend Media
.setting
label(for="videos_muted") Mute videos by default: