From 0c071f475f49c34cbff0098b378ad211ab03dc14 Mon Sep 17 00:00:00 2001 From: teddit Date: Fri, 1 Jan 2021 17:15:11 +0100 Subject: [PATCH] add theme to config file, fix #33 --- app.js | 2 ++ config.js.template | 1 + 2 files changed, 3 insertions(+) diff --git a/app.js b/app.js index ad1d719..37a0e6b 100644 --- a/app.js +++ b/app.js @@ -102,6 +102,8 @@ const preferencesMiddleware = (req, res, next) => { req.cookies.theme = themeOverride // this will set it for future requests res.cookie('theme', themeOverride, { maxAge: 31536000, httpOnly: true }) + } else if(!req.cookies.theme && req.cookies.theme !== '') { + req.cookies.theme = config.theme } let flairsOverride = req.query.flairs diff --git a/config.js.template b/config.js.template index 80db30e..062928b 100644 --- a/config.js.template +++ b/config.js.template @@ -2,6 +2,7 @@ const config = { domain: process.env.DOMAIN || '127.0.0.1', // Or for example 'teddit.net' use_reddit_oauth: process.env.USE_REDDIT_OAUTH === "true" || false, // If false, teddit uses Reddit's public API. If true, you need to have your own Reddit app ID (enter the app ID to the "reddit_app_id" config key). 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', '' flairs_enabled: process.env.FLAIRS_ENABLED !== "true" || true, // Enables the rendering of user and link flairs on teddit 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,