From bc3af7b6096ee644cf518525ee5039127bd4ba36 Mon Sep 17 00:00:00 2001 From: alan Date: Sat, 15 Oct 2022 06:23:48 +0200 Subject: [PATCH] Add Quetre option --- inc/commons.js | 5 +++++ routes/overides.js | 9 +++++++++ routes/preferences.js | 6 ++++++ views/preferences.pug | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/inc/commons.js b/inc/commons.js index 2ed4a82..ab3a0cf 100644 --- a/inc/commons.js +++ b/inc/commons.js @@ -193,6 +193,7 @@ module.exports = function(request, fs) { let youtubeRegex = /(?<=href=")(https?:\/\/)([A-z.]+\.)?youtu(be\.com|\.be)(?=.+")/gm; let twitterRegex = /(?<=href=")(https?:\/\/)(www\.)?twitter\.com(?=.+")/gm; let instagramRegex = /(?<=href=")(https?:\/\/)(www+\.)?instagram.com(?=.+")/gm; + let quoraRegex = /(?<=href=")(https?:\/\/)([A-z.]+\.)?quora\.com(?=.+")/gm; let protocol = config.https_enabled || config.api_force_https ? 'https://' : 'http://' @@ -260,6 +261,10 @@ module.exports = function(request, fs) { if(user_preferences.domain_instagram) str = str.replace(instagramRegex, protocol + user_preferences.domain_instagram) + if(typeof(user_preferences.domain_quora) != 'undefined') + if(user_preferences.domain_quora) + str = str.replace(quoraRegex, protocol + user_preferences.domain_quora) + return str } diff --git a/routes/overides.js b/routes/overides.js index 68c0ece..1e9072b 100644 --- a/routes/overides.js +++ b/routes/overides.js @@ -101,6 +101,15 @@ overridingRoutes.all('*', (req, res, next) => { }); } + let domainQuora = req.query.domain_quora; + if (domainQuora) { + req.cookies.domain_quora = domainQuora; + res.cookie('domain_quora', domainQuora, { + maxAge: 31536000, + httpOnly: true, + }); + } + let videosMuted = req.query.videos_muted; if (videosMuted) { req.cookies.videos_muted = videosMuted; diff --git a/routes/preferences.js b/routes/preferences.js index 6300a79..42dc1f5 100644 --- a/routes/preferences.js +++ b/routes/preferences.js @@ -15,6 +15,7 @@ function resetPreferences(res) { res.clearCookie('domain_twitter'); res.clearCookie('domain_youtube'); res.clearCookie('domain_instagram'); + res.clearCookie('domain_quora'); res.clearCookie('videos_muted'); res.clearCookie('prefer_frontpage'); res.clearCookie('show_large_gallery_images'); @@ -92,6 +93,7 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => { let domain_twitter = req.body.domain_twitter; let domain_youtube = req.body.domain_youtube; let domain_instagram = req.body.domain_instagram; + let domain_quora = req.body.domain_quora; let videos_muted = req.body.videos_muted; let prefer_frontpage = req.body.prefer_frontpage; let show_large_gallery_images = req.body.show_large_gallery_images; @@ -172,6 +174,10 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true, }); + res.cookie('domain_quora', domain_quora, { + maxAge: 365 * 24 * 60 * 60 * 1000, + httpOnly: true, + }); if (prefer_frontpage === 'on') prefer_frontpage = 'true'; res.cookie('prefer_frontpage', prefer_frontpage, { diff --git a/views/preferences.pug b/views/preferences.pug index c51ac20..45b169f 100644 --- a/views/preferences.pug +++ b/views/preferences.pug @@ -31,6 +31,12 @@ html input(type="text", name="domain_instagram", id="domain_instagram", value="" + user_preferences.domain_instagram + "", placeholder="e.g. bibliogram.art") else input(type="text", name="domain_instagram", id="domain_instagram", placeholder="e.g. bibliogram.art") + .setting + label(for="domain_quora") Replace Quora links with Quetre (blank to disable): + if(user_preferences.domain_quora != '' && typeof(user_preferences.domain_quora) != 'undefined') + input(type="text", name="domain_quora", id="domain_quora", value="" + user_preferences.domain_quora + "", placeholder="e.g. quetre.iket.me") + else + input(type="text", name="domain_quora", id="domain_quora", placeholder="e.g. quetre.iket.me") legend Display .setting label(for="theme") Theme: