Prevent query params in GoatCounter results

This commit is contained in:
Florine W. Dekker 2023-03-20 12:55:32 +01:00
parent 8655e8933c
commit f43c59c681
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
6 changed files with 75 additions and 39 deletions

View File

@ -17,52 +17,86 @@ This tool regularly checks if people are still alive according to Wikipedia, and
* [npm](https://www.npmjs.com/)
### Setting up
```shell script
# Install dependencies (only needed once)
$> composer.phar install
$> npm ci
Install the latest dependencies.
Run this after cloning the repo, and each time after pulling new commits.
```shell
composer.phar install
npm ci
```
### Building
```shell script
# Build the tool in `dist/` for development
$> npm run dev
# Same as above, but automatically rerun it whenever files are changed
$> npm run dev:server
# Build the tool in `dist/` for deployment
$> npm run deploy
```
* Build the tool in `dist/` for development
```shell
npm run dev
```
* Same as above, but automatically rebuild whenever source code is changed
```shell
npm run dev:server
```
* Build the tool in `dist/` for deployment
```shell
npm run deploy
```
### Pre-commit
```shell script
# Update lock files
$> composer.phar update
$> npm install
If you changed the version number or updated any dependencies, update the lock files:
```shell
composer.phar update
npm install
```
### Static analysis
```shell script
# Run static analysis
$> npm run analyze
# Run all tests
$> npm run test
# Run all tests in package
$> npm run test -- --test-target=com/fwdekker/deathnotifier/wikipedia/
# Run static analysis and tests
$> npm run check
```
* Run static analysis
```shell
npm run analyze
```
* Run all tests
```shell
npm run test
```
* Run all tests in package
```shell
npm run test -- --test-target=com/fwdekker/deathnotifier/wikipedia/
```
* Run static analysis and tests
```shell
npm run check
```
## Deployment
### Build
Build the software and move it to the right directory.
```shell script
$> npm run deploy # Build
$> mv dist/ /var/www/death-notifier/ # Move to public directory
```shell
npm run deploy
mv dist/ /var/www/death-notifier/
```
Then, add the following lines to your crontab using `sudo -u www crontab -e`:
### Configuration
Inside the installation directory, create `config.ini.php` and use it to override values from `config.default.ini.php`.
Make sure only the user that runs PHP can read/write `config.ini.php`.
### Cron jobs
You should run the `process-email-queue` and `update-all-trackings` actions regularly;
recommended is every minute and every five minutes, respectively.
For example, you can add the following lines to your crontab (e.g. using `sudo -u www crontab -e`):
```
* * * * * cd /var/www/death-notifier && php /var/www/death-notifier/api.php action=process-email-queue password=secret_password
*/5 * * * * cd /var/www/death-notifier && php /var/www/death-notifier/api.php action=update-all-trackings password=secret_password
```
Replace `secret_password` with the password you configured in `config.ini.php`.
### Logs
It is recommended to also use a tool such as `newsyslog` to manage log rotation.
For example, create the file `/etc/newsyslog.conf.d/death-notifier.conf` with the following contents:
```
/var/www/death-notifier/.death-notifier.log www:www 644 7 * @T00 JpE
```
### Initialize
Open `index.html` in an interactive browser to initialize the database.
Make sure only the user that runs PHP can read/write `.death-notifier.db`.
### Inspection
You can use a tool such as [VisiData](https://www.visidata.org/) to manually inspect the database contents on the
command line.

View File

@ -1,7 +1,7 @@
{
"name": "fwdekker/death-notifier",
"description": "Get notified when a famous person dies.",
"version": "1.0.0", "_comment_version": "Also update version in `package.json`!",
"version": "1.0.1", "_comment_version": "Also update version in `package.json`!",
"type": "project",
"license": "MIT",
"homepage": "https://git.fwdekker.com/tools/death-notifier",
@ -19,12 +19,12 @@
"composer/semver": "^3.3",
"ext-curl": "*",
"ext-pdo": "*",
"monolog/monolog": "^3.2",
"phpmailer/phpmailer": "^6.6"
"monolog/monolog": "^3.3",
"phpmailer/phpmailer": "^6.8"
},
"require-dev": {
"phpstan/phpstan": "^1.9.2",
"phpunit/phpunit": "^9.5.26"
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {

BIN
composer.lock generated

Binary file not shown.

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "death-notifier",
"version": "1.0.0", "_comment_version": "Also update version in `composer.json`!",
"version": "1.0.1", "_comment_version": "Also update version in `composer.json`!",
"description": "Get notified when a famous person dies.",
"author": "Florine W. Dekker",
"browser": "dist/bundle.js",
@ -19,7 +19,7 @@
"test": "grunt test"
},
"devDependencies": {
"grunt": "^1.5.3",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
@ -29,8 +29,8 @@
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^5.0.0",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"typescript": "^5.0.2",
"webpack": "^5.76.2",
"webpack-cli": "^5.0.1"
}
}

View File

@ -20,6 +20,8 @@
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/3.x.x/template.css?v=%%VERSION_NUMBER%%" />
<!--suppress HtmlUnknownTarget -->
<link rel="stylesheet" href="main.css?v=%%VERSION_NUMBER%%" />
<!-- Prevent sending query params to GoatCounter -->
<link rel="canonical" href="https://fwdekker.com/tools/death-notifier/">
<script async src="https://stats.fwdekker.com/count.js"
data-goatcounter="https://stats.fwdekker.com/count"></script>
</head>