2026-10-19 11:00:10 +03:00
|
|
|
# ChessPenguin website
|
|
|
|
|
|
2026-10-24 12:48:03 +03:00
|
|
|
One page in nine languages (`/`, `/ru/`, `/fr/`, `/de/`, `/es/`, `/it/`, `/pt/`, `/uz/`, `/kk/`), downloads that go
|
2026-10-19 11:00:10 +03:00
|
|
|
through this server to the latest GitHub release, and download statistics at `/stats`.
|
|
|
|
|
Internal: kept in Forgejo only (excluded from the GitHub mirror by `scripts/publish-github.sh`).
|
|
|
|
|
|
|
|
|
|
## Run
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cp .env.example .env # set SITE_URL, STATS_PASSWORD, TZ
|
|
|
|
|
docker compose up -d --build
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The server listens on `127.0.0.1:${HOST_PORT}` (8080). `data/` keeps the statistics
|
|
|
|
|
(`downloads.sqlite`) and the geolocation databases, which the container downloads on start
|
|
|
|
|
when they are missing or older than 35 days (DB-IP Lite City, CC BY 4.0; the footer credits
|
|
|
|
|
DB-IP as the licence requires). Update the site: `git pull && docker compose up -d --build`.
|
|
|
|
|
|
|
|
|
|
## nginx
|
|
|
|
|
|
|
|
|
|
```nginx
|
|
|
|
|
server {
|
|
|
|
|
listen 443 ssl;
|
|
|
|
|
http2 on;
|
|
|
|
|
server_name chesspenguin.example.org;
|
|
|
|
|
# ssl_certificate ...; ssl_certificate_key ...;
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The visitor address is read from `X-Forwarded-For` / `X-Real-IP` (`TRUST_PROXY=1`) only to
|
|
|
|
|
look up the country, region and city; the address itself is never stored.
|
|
|
|
|
|
|
|
|
|
## Downloads
|
|
|
|
|
|
|
|
|
|
`/download/<platform>` (`windows`, `macos`, `deb`, `rpm`, `arch`, `appimage`, `flatpak`,
|
|
|
|
|
`tarball`, `checksums`) records the download and answers with a redirect to the asset of
|
|
|
|
|
the latest release, so the browser starts downloading at once and the visitor stays on the
|
|
|
|
|
site. The release list is cached for 10 minutes; a new GitHub release appears on the site
|
|
|
|
|
by itself. If GitHub is unreachable, the link leads to the releases page.
|
|
|
|
|
|
|
|
|
|
## Statistics
|
|
|
|
|
|
Website stats: page visitors, conversion, bots filtered out
site.js reports page views (POST /hit), so crawlers that do not run JavaScript are
not visitors. Downloads and views are classified as human, bot (no language, not a
browser, crawler user agent, or three files within ten minutes), owner (the browser
that opened /stats) or local network; only people are counted. Visitors are told
apart by a daily-salted hash, the IP is still not stored. Old rows are reclassified.
The stats page is in Russian: visitors, downloaders, conversion, downloads by period.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 11:45:24 +03:00
|
|
|
`/stats` (basic auth `STATS_USER` / `STATS_PASSWORD`, in Russian): visitors, visitors who
|
|
|
|
|
downloaded, conversion and downloads for today, 7 and 30 days and all time; a 30-day chart;
|
|
|
|
|
downloads by platform, version, country, region and city; visitors by country, page
|
|
|
|
|
language and source; the latest downloads with their class. `/stats.csv` exports every
|
|
|
|
|
download, `/stats.csv?t=visits` every page view.
|
|
|
|
|
|
|
|
|
|
Only people are counted. A page view comes from site.js (`POST /hit`), so crawlers that do
|
|
|
|
|
not run JavaScript never appear as visitors. Every row is classified:
|
|
|
|
|
|
|
|
|
|
- `bot` — no browser language, a user agent that is not a browser or names a crawler,
|
|
|
|
|
link preview or script, or three different files from one visitor within ten minutes
|
|
|
|
|
(crawlers follow every download link);
|
|
|
|
|
- `owner` — the browser that opened `/stats` (it gets a `cp_owner` cookie for a year);
|
|
|
|
|
- `local` — the local network;
|
|
|
|
|
- `human` — everything else.
|
|
|
|
|
|
|
|
|
|
No IP is stored: visitors are told apart by a hash of IP and user agent with a salt that
|
|
|
|
|
lives only in memory and changes every day.
|
2026-10-19 11:00:10 +03:00
|
|
|
|
2026-10-24 13:45:15 +03:00
|
|
|
## Installations
|
|
|
|
|
|
|
|
|
|
The programs (desktop and Android, from 1.0.1) check for updates through `GET /api/update?install=<id>&version=<v>&platform=<p>`
|
|
|
|
|
instead of GitHub: the answer is GitHub's latest release (the fields the programs read:
|
|
|
|
|
`tag_name`, `html_url`, `assets[].name/browser_download_url/size`), and the call is counted
|
|
|
|
|
in the `launches` table — one row per installation and local day: the random id the
|
2026-10-24 14:08:05 +03:00
|
|
|
program made up (32 hex digits), its version, platform (`windows`, `macos`, `deb`, `rpm`,
|
|
|
|
|
`arch`, `aur`, `appimage`, `flatpak`, `tarball`, `other`, `android`, `android-noengine`) and
|
2026-10-24 14:58:38 +03:00
|
|
|
the country of the address (the address is not kept). The local network and the big clouds (Microsoft, Amazon, Google, Oracle, Alibaba,
|
|
|
|
|
Tencent, IBM — by the DB-IP Lite ASN database: security scanners run new programs there)
|
|
|
|
|
are not counted,
|
2026-10-24 14:08:05 +03:00
|
|
|
nor more than 5 new installations a day from one address. `/stats`
|
2026-10-24 13:45:15 +03:00
|
|
|
shows installations that ran today, in 7 and 30 days, in all, and new ones in 7 days, by
|
|
|
|
|
platform, and the versions of the last 7 days. A program that cannot reach the site asks
|
2026-10-24 14:08:05 +03:00
|
|
|
GitHub (uncounted); one with the update check at start turned off is counted only when
|
|
|
|
|
the user checks by hand.
|
2026-10-24 13:45:15 +03:00
|
|
|
|
2026-10-24 13:57:07 +03:00
|
|
|
## Telegram
|
|
|
|
|
|
|
|
|
|
With `TELEGRAM_TOKEN` (the owner's bot) and `TELEGRAM_CHAT` (the owner's chat id) in
|
2026-10-24 14:26:51 +03:00
|
|
|
`.env`, the site writes to the owner (with the country and city of the address, which
|
|
|
|
|
is not kept): «⬇️ Скачали …» for a
|
2026-10-24 14:08:05 +03:00
|
|
|
person's download (not crawlers, the owner or the local network; once a day per file and
|
|
|
|
|
visitor), «🆕 Новая установка №N» for an installation's
|
2026-10-24 13:57:07 +03:00
|
|
|
first run, «⬆️ Обновилась …» when it runs a new version, «▶️ Запуск …» when it runs on a
|
|
|
|
|
new day (once a day at most). `/stat` answers with today and all time: downloads,
|
|
|
|
|
installations that ran and new ones, active in 7 and 30 days, by platform. Only the
|
|
|
|
|
owner's chat is listened to (long polling: one server per bot).
|
|
|
|
|
|
2026-10-19 11:00:10 +03:00
|
|
|
## Development
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
cd server && cargo build
|
|
|
|
|
STATIC_DIR=../static SITE_DIR=../site DB_PATH=../data-dev/d.sqlite \
|
|
|
|
|
GEOIP_DB=../data-dev/dbip-city-ipv4.mmdb STATS_PASSWORD=secret PORT=18080 \
|
|
|
|
|
target/debug/chesspenguin-site
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Texts: `site/index.html` (template), `site/i18n/<lang>.json` (English is the fallback for a
|
|
|
|
|
missing key); translations are loaded at start, so restart after editing.
|
|
|
|
|
|
|
|
|
|
Screenshots: `shots/make-screenshots.sh` takes them with the release build of the app and
|
|
|
|
|
its dev hooks (`docs/dev/desktop.md`) into `shots/raw/` (not committed), then
|
|
|
|
|
`python3 -I shots/derive.py` makes the WebP/JPEG/PNG sizes and `static/og-image.png`. The
|
|
|
|
|
games are public domain with our own comments; the large database appears only as a table
|
|
|
|
|
of game data under a neutral name, never with its annotations.
|