From cd6750264b05ff5d05f269cc8035b2771edb28eb Mon Sep 17 00:00:00 2001 From: teddit Date: Fri, 15 Jan 2021 17:57:25 +0100 Subject: [PATCH 1/3] fix sidebar overflow #109 --- static/css/styles.css | 1 + 1 file changed, 1 insertion(+) diff --git a/static/css/styles.css b/static/css/styles.css index 89fe881..8eeee73 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -974,6 +974,7 @@ footer a { float: left; font-size: smaller; padding-right: 15px; + width: auto; } .subreddit-listing { margin: 8px 0px; From 19a281ebe49946978548ca5494ba0f2a6c856af2 Mon Sep 17 00:00:00 2001 From: teddit Date: Fri, 15 Jan 2021 18:02:50 +0100 Subject: [PATCH 2/3] scroll to infobar when viewing comment permalink #78 --- inc/compilePostComments.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/compilePostComments.js b/inc/compilePostComments.js index 3d25eba..1f0da40 100644 --- a/inc/compilePostComments.js +++ b/inc/compilePostComments.js @@ -54,7 +54,7 @@ module.exports = function() {

${comments.user_flair}

${ups}${controversial_span}

- ${timeDifference(comments.created)}${edited_span} + ${timeDifference(comments.created)}${edited_span}

${comments.stickied ? 'stickied comment' : ''}

@@ -150,7 +150,7 @@ module.exports = function() {

${comment.user_flair}

${ups}${controversial_span}

- ${timeDifference(comment.created)}${edited_span} + ${timeDifference(comment.created)}${edited_span}

${comment.stickied ? 'stickied comment' : ''}

From fff9c2d5b98c532341acb5dcf0bdd1ef229e80fb Mon Sep 17 00:00:00 2001 From: teddit Date: Sat, 16 Jan 2021 21:14:12 +0100 Subject: [PATCH 3/3] convert reddit.com links to instance domain --- config.js.template | 6 ++++++ inc/commons.js | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/config.js.template b/config.js.template index be8cac8..59a007d 100644 --- a/config.js.template +++ b/config.js.template @@ -40,6 +40,12 @@ const config = { shorts: 60 * 60 * 24 * 31, wikis: 60* 60 * 24 * 7 }, + convert_urls: { + /** + * When enabled, all the domains in the content (e.g. comments, sidebars, wikis etc.) will be replaced with a privacy respecting version. + */ + reddit: true, // old.reddit.com and reddit.com --> instance domain (config.domain) + }, valid_media_domains: ['preview.redd.it', 'external-preview.redd.it', 'i.redd.it', 'v.redd.it', 'a.thumbs.redditmedia.com', 'b.thumbs.redditmedia.com', 'emoji.redditmedia.com', 'thumbs.gfycat.com', 'i.ytimg.com'], reddit_api_error_text: `Seems like your instance is either blocked (e.g. due to API rate limiting), reddit is currently down, or your API key is expired and not renewd properly. This can also happen for other reasons.` }; diff --git a/inc/commons.js b/inc/commons.js index c532d2f..3e88ece 100644 --- a/inc/commons.js +++ b/inc/commons.js @@ -125,12 +125,15 @@ module.exports = function(request, fs) { } this.toUTCString = (time) => { - let d = new Date(); - d.setTime(time*1000); - return d.toUTCString(); + let d = new Date() + d.setTime(time*1000) + return d.toUTCString() } this.unescape = (s) => { + /* It would make much more sense to rename this function to something + * like "formatter". + */ if(s) { var re = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; var unescaped = { @@ -145,9 +148,18 @@ module.exports = function(request, fs) { '"': '"', '"': '"' } - return s.replace(re, (m) => { - return unescaped[m] - }) + if(config.convert_urls.reddit) { + let str = s.replace(re, (m) => { + return unescaped[m] + }) + let r = new RegExp('((www|old)\.)?reddit.com', 'g') + let result = str.replace(r, config.domain) + return result + } else { + return s.replace(re, (m) => { + return unescaped[m] + }) + } } else { return '' }