This is the codebase for Data Rights Finder by IF and Open Rights Group.
Code is licenced under the MIT Licence. Please use the Google JavaScript style guide when contributing.
Local installation has been tested on macOS High Sierra, with Node.js 8.9.4, npm 6.0.0 and PostgreSQL 10 installed using postgres.app.
Make sure a local PostgreSQL server running, you've created a database called datarightsfinder
and you know the DSN for that database. If you're using postgress.app and your macOS username is foo
, your DSN will be:
postgres://foo@localhost:5432/datarightsfinder
In Terminal, clone this repository with git clone git@github.com:datarightsfinder/website.git
Run cd website
Create a new file called .env
and paste in the following template:
DATABASE_URL=CHANGEME
GITHUB_TOKEN=CHANGEME
WEBHOOK_KEY=foobar
CHANGES_KEY=foobar
DATABASE_URL
with your PostgreSQL DSNGITHUB_TOKEN
with a personal access token from GitHub. This token should have the public_repo
scope onlyWEBHOOK_KEY
can have a dummy value, unless you need to configure the webhookCHANGES_KEY
can have a dummy value during developmentIn settings.yaml
, make sure repository_path
points to a GitHub repository with some privacy notice JSON files. Use the format <organisation name>/<repository name>
. By default, this is datarightsfinder/data
Run npm install
to install dependencies
Run node seed.js
to populate the empty database
Run gulp
to start the app. (If this fails, run sudo npm install -g gulp-cli
and try again)
Go to http://localhost:3000
in your browser
If you need to test the GitHub sync webhook, read Configuring the webhook
Set up the GitHub sync webhook by reading Configuring the webhook
Make sure the Heroku CLI is installed and you are logged in with heroku login
Create a new Heroku app in the CLI or on heroku.com. To deploy a repository to an existing Heroku app, add the remote with heroku git:remote -a <name of heroku app>
In the control panel for the app on Heroku.com, click the Resources tab and add the Heroku Postgres addon
Also add the Heroku Scheduler addon. Go into the addon settings, then create a new daily job that runs node update_hashes.js
Back on your CLI, add the GitHub webhook secret with heroku config:set WEBHOOK_KEY=<key>
Add a GitHub personal access token with heroku config:set GITHUB_TOKEN=<token>
. This personal access token should have the public_repo
scope only
Configure an access key for the /changes page with heroku config:set CHANGES_KEY
. See updates to privacy notices for more information.
Push the app with git push heroku master
Populate the database with heroku run node seed.js
The data for this app comes from the datarightsfinder/data repository on GitHub.
Whenever a push to master is made in this repository, GitHub will send information about what has changed to this app. It will then update the internal database to reflect the modifications in this GitHub repository.
Install ngrok
Follow the instructions to install Data Rights Finder locally
Run the app with gulp
In another Terminal tab, run ngrok with ./ngrok http 3000 -region eu
Go to https://github.com/datarightsfinder/data/settings/hooks and click "Add Webhook".
In "Payload URL", paste in the http forwarding address from ngrok, and add /webhook/incoming
to the end. For example, http://abcd1234.eu.ngrok.io/webhook/incoming
In "Content Type", choose application/json
In "Secret", use a password manager to generate a long, random password. Paste this in, and store it somewhere safe
In "Which events would you like to trigger this webhook?" choose "Just the push
event"
Click "Add Webhook"
Follow steps 5 to 10 for configuring the webhook locally.
/settings.yaml
This file contains the main settings for the app, including its name, URL and references to email addresses and GitHub repositories
/config/message_templates.js
This file contains the templates used when clicking email links for exercising rights
Data Rights Finder is configured to run a script once a day that hashes the text contents of a privacy policy. If the hash has changed since it was last checked, it will appear on the changes page.
The changes page is only accessible with the correct key. This is set in Heroku and locally with an environment variable called CHANGES_KEY
. When configuring it for the first time, use a password manager to generate an alphanumeric string.
To access the page, go to https://datarightsfinder.org/changes?key=<KEY>
.
To resolve a change, make an edit to its corresponding JSON file and commit it to the data repository or click Ignore on the changes page.
To run this script manually, run node update_hashes.js
locally or heroku run node update_hashes.js
remotely.
node seed.js
This command is automatically run when installing this project for the first time. If you need to reset the data in your local database with data from GitHub, run this command.
node update_hashes.js
This command checks each privacy notice and lists any content changes at https://datarightsfinder.org/changes.