From 81ba2b83430e97045b6066d2dc3e6885bd02d856 Mon Sep 17 00:00:00 2001 From: Jesper Wrang Date: Tue, 12 Sep 2017 00:22:59 +0200 Subject: [PATCH] Added error display for users --- README.md | 8 ++++---- config/ssl | 5 +++-- static/error.png | Bin 0 -> 3190 bytes static/script.js | 17 ++++++++++------- 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 static/error.png diff --git a/README.md b/README.md index d048538..30a606a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; ``` -In the same file you also want to change `gzip on` to `gzip off`. (read more [here](https://github.com/h5bp/server-configs-nginx/issues/72)) +In the same file you also want to change `gzip on` to `gzip off` (read more [here](https://github.com/h5bp/server-configs-nginx/issues/72)). ## Nginx server config Copy the ssl config and create a soft link. Create folder for logs and also remove the default config @@ -50,7 +50,7 @@ sudo mkdir /var/log/nginx/removeddit sudo rm /etc/nginx/sites-enabled/default ``` -Change the "server_name" in the config to your domain name. +Change both the "server_name" in the config to your domain name. ## SSL with Let's encrypt Read the full guide [here](https://certbot.eff.org/#ubuntutyakkety-nginx). Start of by installing the Let's Encrypt client [certbot](https://certbot.eff.org/) @@ -64,7 +64,7 @@ sudo apt install -y python-certbot-nginx Copy the Let's Encrypt config file for our site ``` sudo mkdir /etc/letsencrypt/configs -cp /var/www/removeddit/config/letsencrypt /etc/letsencrypt/config/removeddit.com.conf +cp /var/www/removeddit/config/letsencrypt /etc/letsencrypt/configs/removeddit.com.conf ``` In this config file you change the domains you want and a email for when the certificates are close to expiring. @@ -72,7 +72,7 @@ In this config file you change the domains you want and a email for when the cer This is when the webmasters start praying to God Almighty, for only He can deside the fate of the certbot. Forgive me, Father, for I have sinned. Just don't fuck up certs you asshole. ``` -sudo certbot --nginx certonly +sudo certbot --config /etc/letsencrypt/configs/removeddit.com.conf certonly ``` You'll now have a valid SSL certificate (hopefully)! You might have to edit the path for `ssl_certificate` and `ssl_certificate_key` in `/etc/nginx/sites-available/removeddit.com` depending on where the certs are located. (Should be in `/etc/letsencrypt/live/`) diff --git a/config/ssl b/config/ssl index 9362847..0d4add3 100644 --- a/config/ssl +++ b/config/ssl @@ -4,7 +4,7 @@ server { root /var/www/removeddit; index index.html; - server_name removeddit.com; + server_name removeddit.com www.removeddit.com; access_log /var/log/nginx/removeddit/access.log; error_log /var/log/nginx/removeddit/error.log; @@ -28,6 +28,7 @@ server { server { listen 80 default_server; listen [::]:80 default_server; + server_name removeddit.com www.removeddit.com; location / { return 301 https://$host$request_uri; @@ -36,4 +37,4 @@ server { location ~ /.well-known { allow all; } -} +} \ No newline at end of file diff --git a/static/error.png b/static/error.png new file mode 100644 index 0000000000000000000000000000000000000000..67c4c8bb5c5c31554ef1719bccc65cc0c7f6ae06 GIT binary patch literal 3190 zcmV-+42koJP)7;Se z?V{6f(2vp2(Oz|?7wx1MX+7?w(>AW#NxjOdZOM|gkrV}x0!V<^an`37q-ZG>WkLkR z&Q$+9Ea#l(`JZQhUX{Qjpqa$wE#zr=L8(J07s4I1RS*hM-5}FcNY;u zA`(G>6-599N~32Oc$x-Esj)u)02mJeBIpuHVbEu0(8rVrwOek9f=DU4xG{ zinv{`^B=3LT&h%Pdmfrnyt%NzcTSw37X*B8?;anO%hX&~ZY7e`Vm6^tiZO7YJ5K5^ z4t0lJ<&}t7QN)Dra;nqD)-+X2rEr6QuJ3~gno?N0PR?=otzwZkjvd3&b+!isu5WFz zJs9xD{5-!sH^*E$&33P+q}5ceQgjUy8G{uZo&ZpWh-5vNxqgSmL7!s6CLN2ZZP(?? zT8;PD*0@rw;)WqHT_>jNn3{%dnk?mVEah_CZ8j;lS{$F4pp;HiNG6$0rP%0nh+0j0 znoiF!M(zrSCO{XF*+Gv}{T>&Rj=ESZsvn;|t=^cQ=Ue$aC$m{{jzib?xwO8{)mn|F z>mnk=4THF0pex1Atu3})msg5KW|B#iQcT%4Gsz_P+im5yn)EfDzHW@v6%HK)?Jywg z4tQZAqyFIBI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9 zH3tLU+HGI0-6F;|P13O#bLlicI(-^92na=p83wW44$;uGk(z$j^Z3=>yOcW}*+?V_ z)xrA!7%RuTC+#qB0I z1qevT^LXdxP5ymlg*&>*T_=U7>q9;Csiwk8b~?ghzeg(Yu@Gh*hlR;WHJ?sXOrXS9ScxEs1yy;q8hVzeE%s-?oczqP}5XB7N;JIqeqd%!;p9w5|08BVIcK(hxO~% z8Th{XqopOx12#Nv7;?2*N&Y z!*ZFQU;m1)1_M?TNt%{Lq{h1-9ozW;4Ux3(Gi6!o#KZ)~J{_M@3O|bYq*CD@zWPdT z3FIp~v>%4NzqZETUA@YR>#^#j*tTLs&*V3WZUyF{4nJ2zxrPKzwU4;B}>SSkVR)$~2zmw&x; zN4<0NCS@;R%}H_Jc8>I%(C7#dktuIL&Kq!{P*6WUbLM{yNh$cI3kRO01=t; zT7Wh$BB_yK-%}onkKIli|AjUmjd8^r^B^c zjVg+!IsWQy7>tAfO$1XSrgux;2bQgrB8(!|S}pE0o6<5Z2HN3PV57!J2oR+Rm7?jo z$`8Xw(q6sa=SsE8{V=3un9r=jJ19m&0MOA*wp>>}s#NwySCI&7trq{iu|Z2W=^R0! z^Gz5{3{XmK#BJJ|&d;u1l`GXMB0{6z=iTLH%AP0nSPXvzE3i>xG$%y?M40eBIosN1 z+R*v-i4&^U?aD_R8&s?qcbxQC`}(KF=m^+F#&cz{+aeZ5h=MIE&T1lwKjgIbSz+V^ z0BBJpslX@PIpR99GkxR0SlZ!8(^S)njpNoM$N#;k^o;SGfTI@RsPUYDqZZ((@tlC8 c7T~DyKefeyW1hnOVgLXD07*qoM6N<$g8BapzyJUM literal 0 HcmV?d00001 diff --git a/static/script.js b/static/script.js index a3d941a..1d96eb7 100644 --- a/static/script.js +++ b/static/script.js @@ -3,6 +3,12 @@ const markdown = SnuOwnd.getParser() const htmlParser = new DOMParser(); +const mainDiv = document.getElementById("main") +const loadingText = document.getElementById("loading-text") +const statusImage = document.getElementById("loading-image") +const doneImageSrc = "/static/done.png" +const errorImageSrc = "/static/error.png" + const pathname = window.location.pathname.split("/") // Just fucking crach if the user is retarded @@ -20,12 +26,6 @@ const redditSingleCommentURL = `https://oauth.reddit.com/r/${subreddit}/api/info const pushshiftIDsURL = `https://api.pushshift.io/reddit/submission/comment_ids/${threadID}` const pushshiftCommentsURL = "https://api.pushshift.io/reddit/comment/search?ids=" -const mainDiv = document.getElementById("main") -const loadingText = document.getElementById("loading-text") -const statusImage = document.getElementById("loading-image") -const doneImageSrc = "/static/done.png" -const errorImageSrc = "/static/error.png" - // I actually haven't found a better way of doing this... // Imgur has image-links with no indication that they are actually images const imageHosts = ["i.redd.it", "flickr.com", "i.imgur.com", "imgur.com", "m.imgur.com"] @@ -57,7 +57,10 @@ let redditInit = { headers: { "Authorization": "" } } -loadPage() +// Start loading the page +if(threadID !== undefined) { + loadPage() +} // Maybe a little to long a function... async function loadPage() {