From 8315ad3f16a0df6d7984bdf7a9fc77ccad6f11bb Mon Sep 17 00:00:00 2001 From: teddit Date: Tue, 21 Dec 2021 22:19:38 +0100 Subject: [PATCH] make the preference show_upvoted_percentage configurable via config.js #274 --- config.js.template | 1 + routes/overides.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/config.js.template b/config.js.template index 6d1baa3..d772794 100644 --- a/config.js.template +++ b/config.js.template @@ -34,6 +34,7 @@ const config = { : [], // Replacements for domains in outgoing links. Tuples with regular expressions to match, and replacement values. This is in addition to user-level configuration of privacyDomains. cache_control: process.env.CACHE_CONTROL !== 'true' || 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: process.env.SHOW_UPVOTED_PERCENTAGE === 'true' || true, post_media_max_heights: { /** * Sets the max-height value for images and videos in posts. diff --git a/routes/overides.js b/routes/overides.js index 4b5192f..68c0ece 100644 --- a/routes/overides.js +++ b/routes/overides.js @@ -68,6 +68,10 @@ overridingRoutes.all('*', (req, res, next) => { maxAge: 31536000, httpOnly: true, }); + } else if (!req.cookies.show_upvoted_percentage) { + if (config.show_upvoted_percentage) { + req.cookies.show_upvoted_percentage = 'true'; + } } let domainTwitter = req.query.domain_twitter;