Readme is now up to date

This commit is contained in:
JubbeArt 2018-07-29 03:59:04 +02:00
parent f6ab190081
commit dbe55b9b2c
7 changed files with 21 additions and 170 deletions

118
README.md
View file

@ -1,112 +1,34 @@
# Removeddit
[Removeddit](https://removeddit.com) is a site for viewing removed stuff from [Reddit](https://www.reddit.com).
Just go to a reddit thread and change the `reddit` in the URL to `removeddit` to see all removed comments.
[Removeddit](https://removeddit.com) is a site for viewing removed comments / threads from [Reddit](https://www.reddit.com).
Just go to any reddit thread and change the `reddit` in the URL to `removeddit` to see all removed comments.
This is a done by comparing the comments found from Reddit API and comments being stored in [Jason Baumgartners](https://pushshift.io/) [Pushshift Reddit API](https://github.com/pushshift/api). The frontend is written in react with redux for state management. There's also a seperate [backend](https://github.com/JubbeArt/removeddit-api) used for storing removed threads and banned subreddits.
This is a done by comparing the comments being stored in [Jason Baumgartners](https://pushshift.io/) [Pushshift Reddit API](https://github.com/pushshift/api) and the ones from Reddit API. The frontend is written in React and uses Sass as the CSS Preprocessor. There is also a seperate [backend](https://github.com/JubbeArt/removeddit-api) used for storing what threads that have been removed by mods.
# Development
Get lastest version of [Node](https://nodejs.org/en/download/current/)
Download either [Yarn](https://yarnpkg.com/en/docs/install) (the one I use) or [npm](https://www.npmjs.com/get-npm)
```
```bash
sudo git clone https://github.com/JubbeArt/removeddit.git && cd removeddit
# npm...
npm install
npm start
# or yarn
yarn
yarn start
```
Visit http://localhost:8080 and make sure the site is running. Subreddits and the banned subreddit list will not work unless you also set up a backend. This might change in the future if I decide to open up my backend on removeddit.com/api. Contact me if you want this feature and we can discuss it.
This will build the Javascript files and launch a local server for development. Visit http://localhost:8080 and make sure the site is running.
# Production (basic setup)
**THIS WILL BE UPDATED LATER WHEN THE PROJECT IN REWRITTEN**
The CSS is build seperatly (to keep the build steps / configs very simple) by running
```bash
# npm
npm run build-sass
Using [Ubuntu 16.04](http://releases.ubuntu.com/16.04/) and [nginx](https://www.nginx.com/resources/wiki/)
```
cd /srv
sudo git clone https://github.com/JubbeArt/removeddit.git /srv/removeddit/site
chown -R www-data:www-data /srv/removeddit
sudo apt install -y nginx
sudo cp /srv/removeddit/site/production/nginx-basic /etc/nginx/sites-available/default
# yarn
yarn run build-sass
```
Create a reddit app [here](https://www.reddit.com/prefs/apps/), select **installed app**. For "redirect url" it doesn't really matter in this case, you can pick `http://localhost`.
Copy the **client ID** for your app set it as a variable in `id.js`, e.g. with
```
sudo nano /srv/removeddit/site/..../id.js
# Insert with ctrl-shift-v
# Save with ctrl-o, exit with ctrl-x
```
Restart nginx and visit "localhost"
```
sudo service nginx restart
```
# The "I care about HTTPS and security" guide
In this part we'll set up [nginx](https://www.nginx.com/resources/wiki/) with SSL and set up a free renewing SSL certificates with [Let's Encrypt](https://letsencrypt.org/). I assume you've already done the guide above.
## Nginx.conf
Add the following to `/etc/nginx/nginx.conf` in the **http-block** (you can read about them [here](https://gist.github.com/plentz/6737338))
```
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
```
## Nginx server config
Copy the ssl config and create a soft link. Create folder for logs and also remove the default config
```
sudo cp /srv/removeddit/site/production/nginx-ssl /etc/nginx/sites-available/removeddit.com
sudo ln -s /etc/nginx/sites-available/removeddit.com /etc/nginx/sites-enabled/removeddit.com
sudo mkdir /var/log/nginx/removeddit
sudo rm /etc/nginx/sites-enabled/default
```
Change the "server_name" for both server blocks in the config to your own 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/)
```
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install -y python-certbot-nginx
```
Copy the Let's Encrypt config file for our site
```
sudo mkdir /etc/letsencrypt/configs
cp /srv/removeddit/site/production/letsencrypt.conf /etc/letsencrypt/configs/removeddit.com.conf
```
In this config file change the domains and the email address for your own. The emails tells you when the certificates are close to expiring.
Pray to God and do this
```
sudo certbot --config /etc/letsencrypt/configs/removeddit.com.conf certonly
```
You'll now have a valid SSL certificate (hopefully)! You now have to uncomment the `ssl_certificate` and `ssl_certificate_key` in `/etc/nginx/sites-available/removeddit.com` and maybe change the path depending on where the certs are located (check in `/etc/letsencrypt/live/`).
## Automated renewal of certs
The certificate expires after 90 days so we want a way to atomatically update the certs.
There are multiple ways of doing this but I find the easiest to be [cron jobs](https://en.wikipedia.org/wiki/Cron).
First we'll test if renewing atcutally works with
```
sudo certbot renew --dry-run
```
If everything works fine we can create a cron with ```sudo crontab -e``` and select an editor your comfortable with (I like *nano*).
Add the following lines at the bottom
```
# Let's Encrypt cert renewal for all sites (runs every day at 04:30)
30 4 * * * certbot renew --post-hook "systemctl reload nginx"
```
Then just restart nginx and that should do it!
This guide was mostly written for myself, you learn a shitton writing guides, highly recommended. Hopefully you learned something too.
## Linting
The linter I use is called [standard](https://standardjs.com/) and you can find plugins for different editors [here](https://standardjs.com/#are-there-text-editor-plugins). Currently I'm using VSCode.

4
TODO
View file

@ -1,9 +1,5 @@
update readme
update header links active (NavLinks)
make sort/filter state local
old.removeddit.com
gzip on server

View file

@ -1,9 +0,0 @@
# Things to change
domains = removeddit.com, www.removeddit.com
email = removeddit@gmail.com
# These defaults are fine (could use 4096 instead of 2048)
rsa-key-size = 2048
text = True
authenticator = webroot
webroot-path = /srv/removeddit/site/

View file

@ -1,20 +0,0 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
root /srv/removeddit/site;
index index.html;
server_name _;
error_page 404 /index.html
#location /api/ {
# include uwsgi_params;
# uwsgi_pass unix:/srv/removeddit-api/socket/uwsgi.sock;
#}
location / {
try_files $uri $uri/ /index.html =404;
}
}

View file

@ -1,38 +0,0 @@
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
root /srv/removeddit/site;
index index.html;
server_name removeddit.com www.removeddit.com;
access_log /var/log/nginx/removeddit/access.log;
error_log /var/log/nginx/removeddit/error.log;
# Uncomment these after you've received the certificates
#ssl_certificate /etc/letsencrypt/live/removeddit.com/fullchain.pem;
#ssl_certificate_key /etc/letsencrypt/live/removeddit.com/privkey.pem;
location / {
try_files $uri $uri/ /index.html =404;
}
#location /api/ {
# include uwsgi_params;
# uwsgi_pass unix:/srv/removeddit-api/socket/uwsgi.sock;
#}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name removeddit.com www.removeddit.com;
location / {
return 301 https://$host$request_uri;
}
location ~ /.well-known {
allow all;
}
}

View file

@ -1,6 +1,6 @@
import React from 'react'
import { Subscribe, Container } from 'unstated'
import { get, put } from '../utils'
import { get, put } from './utils'
// Sort types for comments
export const sort = {