From 9da8449ee5c6da4d23ca7177f04295aa77ac337b Mon Sep 17 00:00:00 2001 From: StevenNMeza Date: Mon, 22 Mar 2021 19:06:57 +0100 Subject: [PATCH] Display profile icons --- config.js.template | 2 +- inc/downloadAndSave.js | 2 ++ inc/processJsonUser.js | 2 +- static/pics/.gitignore | 1 + views/user.pug | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.js.template b/config.js.template index 9c6ae4e..aaf4521 100644 --- a/config.js.template +++ b/config.js.template @@ -55,7 +55,7 @@ const config = { new_page: 60 }, }, - 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'], + 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', 'styles.redditmedia.com', 'www.redditstatic.com', 'thumbs.gfycat.com', 'i.ytimg.com'], valid_embed_video_domains: ['gfycat.com', 'youtube.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/downloadAndSave.js b/inc/downloadAndSave.js index 2afaaab..3126933 100644 --- a/inc/downloadAndSave.js +++ b/inc/downloadAndSave.js @@ -51,6 +51,8 @@ module.exports = function(tools) { dir = 'thumbs/' if(file_prefix === 'flair_') dir = 'flairs/' + if(file_prefix === 'icon_') + dir = 'icons/' if(valid_video_extensions.includes(file_ext) || gifmp4) { /* Is video. */ diff --git a/inc/processJsonUser.js b/inc/processJsonUser.js index e89300f..cff2180 100644 --- a/inc/processJsonUser.js +++ b/inc/processJsonUser.js @@ -99,7 +99,7 @@ module.exports = function() { let obj = { username: about.name, - icon_img: about.icon_img, + icon_img: await downloadAndSave(about.icon_img, "icon_"), created: about.created_utc, verified: about.verified, link_karma: about.link_karma, diff --git a/static/pics/.gitignore b/static/pics/.gitignore index ab98a6e..9830091 100644 --- a/static/pics/.gitignore +++ b/static/pics/.gitignore @@ -4,4 +4,5 @@ !.gitignore !flairs/ !thumbs/ +!icons/ diff --git a/views/user.pug b/views/user.pug index 284193b..520f826 100644 --- a/views/user.pug +++ b/views/user.pug @@ -70,6 +70,7 @@ html li(class=past === 'all' ? 'active' : '') a(href="?sort=" + sortby + "&t=all") all time .info + img(src=data.icon_img) h1 #{data.username} p(class="user-stat") #{kFormatter(data.link_karma)} post karma p(class="user-stat") #{kFormatter(data.comment_karma)} comment karma