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>
This commit is contained in:
parent
c8e33e4ecd
commit
96e5142826
10 changed files with 529 additions and 131 deletions
|
|
@ -48,10 +48,24 @@ by itself. If GitHub is unreachable, the link leads to the releases page.
|
|||
|
||||
## Statistics
|
||||
|
||||
`/stats` (basic auth `STATS_USER` / `STATS_PASSWORD`): totals for today, 7 and 30 days and
|
||||
all time, by platform, version, country, region and city, language, a 30-day chart and the
|
||||
latest downloads. `/stats.csv` exports every row. Each row: UTC time, platform, version,
|
||||
file, country, region, city, page language, referrer host.
|
||||
`/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.
|
||||
|
||||
## Development
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
//! The ChessPenguin website: serves the static page, answers "which release is the
|
||||
//! latest" from the GitHub API (cached), counts downloads and redirects them to the
|
||||
//! release files on GitHub (the visitor stays on the site), and shows the download
|
||||
//! statistics behind a password.
|
||||
//! release files on GitHub (the visitor stays on the site), counts page views, and
|
||||
//! shows the statistics behind a password.
|
||||
//!
|
||||
//! Nothing personal is stored: a download keeps its time, platform, version, the
|
||||
//! country/region/city looked up from the IP (DB-IP Lite) and the browser language; the
|
||||
//! IP itself is not written anywhere.
|
||||
//! Nothing personal is stored: a row keeps its time, the country/region/city looked up
|
||||
//! from the IP (DB-IP Lite), the browser language and user agent, and a visitor key —
|
||||
//! a hash of IP and user agent with a random salt that lives only in memory and changes
|
||||
//! every day, so visitors can be told apart within a day but the IP cannot be recovered.
|
||||
//! Each row is classified: `human`, `bot`, `owner` (the browser that opened /stats) or
|
||||
//! `local` (the local network); the statistics count only `human`.
|
||||
|
||||
mod site;
|
||||
|
||||
|
|
@ -18,7 +21,7 @@ use std::time::{Duration, Instant};
|
|||
use axum::extract::{ConnectInfo, Path, Query, State};
|
||||
use axum::http::{HeaderMap, HeaderValue, StatusCode, header};
|
||||
use axum::response::{Html, IntoResponse, Redirect, Response};
|
||||
use axum::routing::get;
|
||||
use axum::routing::{get, post};
|
||||
use axum::{Json, Router};
|
||||
use base64::Engine as _;
|
||||
use serde::Serialize;
|
||||
|
|
@ -102,6 +105,8 @@ struct AppState {
|
|||
geoip: Vec<maxminddb::Reader<Vec<u8>>>,
|
||||
http: reqwest::Client,
|
||||
release: tokio::sync::Mutex<Option<(Instant, Release)>>,
|
||||
/// The visitor-key salt and the local day it belongs to.
|
||||
salt: Mutex<(String, u64)>,
|
||||
}
|
||||
|
||||
type Shared = Arc<AppState>;
|
||||
|
|
@ -127,9 +132,24 @@ async fn main() {
|
|||
lang TEXT, -- first browser language
|
||||
referrer TEXT -- host of the referring page
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS downloads_ts ON downloads (ts);",
|
||||
CREATE INDEX IF NOT EXISTS downloads_ts ON downloads (ts);
|
||||
CREATE TABLE IF NOT EXISTS pageviews (
|
||||
id INTEGER PRIMARY KEY,
|
||||
ts TEXT NOT NULL, -- UTC, RFC 3339
|
||||
page TEXT NOT NULL, -- page language
|
||||
country TEXT,
|
||||
region TEXT,
|
||||
city TEXT,
|
||||
lang TEXT,
|
||||
referrer TEXT, -- host of the page the visitor came from
|
||||
visitor TEXT NOT NULL,
|
||||
kind TEXT NOT NULL,
|
||||
ua TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS pageviews_ts ON pageviews (ts);",
|
||||
)
|
||||
.expect("create the table");
|
||||
.expect("create the tables");
|
||||
migrate(&db);
|
||||
let geoip: Vec<_> = config
|
||||
.geoip_paths
|
||||
.iter()
|
||||
|
|
@ -161,6 +181,7 @@ async fn main() {
|
|||
.build()
|
||||
.expect("http client"),
|
||||
release: tokio::sync::Mutex::new(None),
|
||||
salt: Mutex::new((String::new(), 0)),
|
||||
});
|
||||
let mut app = Router::new()
|
||||
.route("/", get(home))
|
||||
|
|
@ -185,6 +206,7 @@ async fn main() {
|
|||
let app = app
|
||||
.route("/api/release", get(api_release))
|
||||
.route("/download/{platform}", get(download))
|
||||
.route("/hit", post(hit))
|
||||
.route("/stats", get(stats))
|
||||
.route("/stats.csv", get(stats_csv))
|
||||
.route("/healthz", get(|| async { "ok" }))
|
||||
|
|
@ -205,6 +227,184 @@ async fn main() {
|
|||
.expect("serve");
|
||||
}
|
||||
|
||||
/// Adds the visitor key and class columns to a database from before them and
|
||||
/// classifies those old downloads after the fact: no browser language → bot; three or
|
||||
/// more files in the same minute from the same place → bot; from the local network →
|
||||
/// local.
|
||||
fn migrate(db: &rusqlite::Connection) {
|
||||
if db.prepare("SELECT kind FROM downloads LIMIT 0").is_ok() {
|
||||
return;
|
||||
}
|
||||
if let Err(e) = db.execute_batch(
|
||||
"BEGIN;
|
||||
ALTER TABLE downloads ADD COLUMN visitor TEXT;
|
||||
ALTER TABLE downloads ADD COLUMN kind TEXT NOT NULL DEFAULT 'human';
|
||||
ALTER TABLE downloads ADD COLUMN ua TEXT;
|
||||
UPDATE downloads SET kind = 'local'
|
||||
WHERE referrer LIKE '192.168.%' OR referrer LIKE '10.%' OR referrer LIKE 'localhost%';
|
||||
UPDATE downloads SET kind = 'bot' WHERE kind = 'human' AND COALESCE(lang, '') = '';
|
||||
UPDATE downloads SET kind = 'bot' WHERE kind = 'human' AND substr(ts, 1, 16) || COALESCE(city, '') IN (
|
||||
SELECT substr(ts, 1, 16) || COALESCE(city, '') FROM downloads
|
||||
GROUP BY 1 HAVING COUNT(DISTINCT platform) >= 3);
|
||||
COMMIT;",
|
||||
) {
|
||||
eprintln!("database migration failed: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// What is known about the visitor of a request.
|
||||
struct Client {
|
||||
country: Option<String>,
|
||||
region: Option<String>,
|
||||
city: Option<String>,
|
||||
lang: Option<String>,
|
||||
ua: String,
|
||||
visitor: String,
|
||||
kind: &'static str,
|
||||
}
|
||||
|
||||
/// User agents of crawlers, link previews, scanners and scripts (lowercase).
|
||||
const BOT_MARKS: &[&str] = &[
|
||||
"bot", "crawl", "spider", "slurp", "preview", "fetch", "scan", "curl", "wget", "python",
|
||||
"go-http", "java/", "okhttp", "libwww", "httpclient", "headless", "phantom", "selenium",
|
||||
"puppeteer", "playwright", "facebookexternalhit", "whatsapp", "telegram", "discord",
|
||||
"slack", "embedly", "axios", "aiohttp", "httpx", "postman", "monitor", "lighthouse",
|
||||
"pingdom", "uptime", "validator", "archive",
|
||||
];
|
||||
|
||||
fn is_local(ip: IpAddr) -> bool {
|
||||
match ip {
|
||||
IpAddr::V4(v4) => v4.is_private() || v4.is_loopback() || v4.is_link_local(),
|
||||
IpAddr::V6(v6) => {
|
||||
v6.is_loopback()
|
||||
|| (v6.segments()[0] & 0xfe00) == 0xfc00
|
||||
|| (v6.segments()[0] & 0xffc0) == 0xfe80
|
||||
|| v6.to_ipv4_mapped().is_some_and(|v4| is_local(IpAddr::V4(v4)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Real browsers send `Mozilla/5.0 …` and a language; crawlers often do not.
|
||||
fn looks_like_bot(ua: &str, lang: Option<&str>) -> bool {
|
||||
let lower = ua.to_lowercase();
|
||||
lang.is_none() || !lower.starts_with("mozilla/") || BOT_MARKS.iter().any(|m| lower.contains(m))
|
||||
}
|
||||
|
||||
fn client(state: &AppState, peer: SocketAddr, headers: &HeaderMap) -> Client {
|
||||
let ip = client_ip(&state.config, peer, headers);
|
||||
let (country, region, city) = locate(state, ip);
|
||||
let text = |h| headers.get(h).and_then(|v: &HeaderValue| v.to_str().ok()).unwrap_or("");
|
||||
let lang = text(header::ACCEPT_LANGUAGE)
|
||||
.split([',', ';'])
|
||||
.next()
|
||||
.map(|s| s.trim().chars().take(16).collect::<String>())
|
||||
.filter(|s| !s.is_empty());
|
||||
let ua: String = text(header::USER_AGENT).chars().take(200).collect();
|
||||
let owner = text(header::COOKIE).split(';').any(|c| c.trim() == "cp_owner=1");
|
||||
let kind = if owner {
|
||||
"owner"
|
||||
} else if is_local(ip) {
|
||||
"local"
|
||||
} else if looks_like_bot(&ua, lang.as_deref()) {
|
||||
"bot"
|
||||
} else {
|
||||
"human"
|
||||
};
|
||||
Client {
|
||||
country,
|
||||
region,
|
||||
city,
|
||||
lang,
|
||||
visitor: visitor_key(state, ip, &ua),
|
||||
ua,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
|
||||
/// A key that is the same for one IP and browser during one local day.
|
||||
fn visitor_key(state: &AppState, ip: IpAddr, ua: &str) -> String {
|
||||
use std::hash::{Hash, Hasher};
|
||||
let today = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||
let salt = {
|
||||
let mut s = state.salt.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if s.0 != today {
|
||||
*s = (today, random_u64());
|
||||
}
|
||||
s.1
|
||||
};
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
salt.hash(&mut h);
|
||||
ip.hash(&mut h);
|
||||
ua.hash(&mut h);
|
||||
format!("{:016x}", h.finish())
|
||||
}
|
||||
|
||||
fn random_u64() -> u64 {
|
||||
use std::io::Read;
|
||||
let mut b = [0u8; 8];
|
||||
match std::fs::File::open("/dev/urandom").and_then(|mut f| f.read_exact(&mut b)) {
|
||||
Ok(()) => u64::from_le_bytes(b),
|
||||
// Not expected on Linux; still differs between runs.
|
||||
Err(_) => std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos() as u64,
|
||||
}
|
||||
}
|
||||
|
||||
fn now_utc() -> String {
|
||||
chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true)
|
||||
}
|
||||
|
||||
fn ago_utc(minutes: i64) -> String {
|
||||
(chrono::Utc::now() - chrono::Duration::minutes(minutes))
|
||||
.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)
|
||||
}
|
||||
|
||||
/// `POST /hit`: the page reports that it was shown. site.js sends it, so only visitors
|
||||
/// that run JavaScript are counted: nearly all people and few crawlers.
|
||||
async fn hit(
|
||||
State(state): State<Shared>,
|
||||
ConnectInfo(peer): ConnectInfo<SocketAddr>,
|
||||
headers: HeaderMap,
|
||||
body: String,
|
||||
) -> StatusCode {
|
||||
let v: serde_json::Value = serde_json::from_str(&body).unwrap_or_default();
|
||||
let page = v["p"].as_str().unwrap_or("/").trim_matches('/');
|
||||
let page = if page.is_empty() { "en" } else { page };
|
||||
if !state.site.has_lang(page) {
|
||||
return StatusCode::NO_CONTENT;
|
||||
}
|
||||
// Where the visitor came from; moving between our own pages is not a source.
|
||||
let own = state.site.url.split('/').nth(2).unwrap_or("");
|
||||
let host = headers.get(header::HOST).and_then(|v| v.to_str().ok()).unwrap_or("");
|
||||
let referrer = v["r"]
|
||||
.as_str()
|
||||
.and_then(|r| r.split('/').nth(2))
|
||||
.filter(|h| !h.is_empty() && *h != own && *h != host)
|
||||
.map(|h| h.chars().take(64).collect::<String>());
|
||||
let c = client(&state, peer, &headers);
|
||||
if let Ok(db) = state.db.lock() {
|
||||
let _ = db.execute(
|
||||
"INSERT INTO pageviews (ts, page, country, region, city, lang, referrer, visitor, kind, ua)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)",
|
||||
rusqlite::params![
|
||||
now_utc(),
|
||||
page,
|
||||
c.country,
|
||||
c.region,
|
||||
c.city,
|
||||
c.lang,
|
||||
referrer,
|
||||
c.visitor,
|
||||
c.kind,
|
||||
c.ua
|
||||
],
|
||||
);
|
||||
}
|
||||
StatusCode::NO_CONTENT
|
||||
}
|
||||
|
||||
/// `/`: English, or `?lang=xx` → `/xx/`.
|
||||
async fn home(state: State<Shared>, Query(q): Query<HashMap<String, String>>) -> Response {
|
||||
if let Some(lang) = q.get("lang")
|
||||
|
|
@ -329,32 +529,49 @@ async fn download(
|
|||
let Some(asset) = release.assets.iter().find(|a| a.platform == platform) else {
|
||||
return Redirect::to(&fallback).into_response();
|
||||
};
|
||||
let ip = client_ip(&state.config, peer, &headers);
|
||||
let (country, region, city) = locate(&state, ip);
|
||||
let lang = headers
|
||||
.get(header::ACCEPT_LANGUAGE)
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.and_then(|v| v.split([',', ';']).next())
|
||||
.map(|s| s.trim().chars().take(16).collect::<String>());
|
||||
let c = client(&state, peer, &headers);
|
||||
let referrer = headers
|
||||
.get(header::REFERER)
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.and_then(|v| v.split('/').nth(2))
|
||||
.map(|s| s.chars().take(64).collect::<String>());
|
||||
if let Ok(db) = state.db.lock() {
|
||||
let mut kind = c.kind;
|
||||
// A crawler following every download link: three or more different files from
|
||||
// one visitor within ten minutes. Its earlier downloads are reclassified too.
|
||||
if kind == "human" && asset.platform != "checksums" {
|
||||
let others: i64 = db
|
||||
.query_row(
|
||||
"SELECT COUNT(DISTINCT platform) FROM downloads
|
||||
WHERE visitor = ?1 AND platform NOT IN ('checksums', ?2) AND ts >= ?3",
|
||||
rusqlite::params![c.visitor, asset.platform, ago_utc(10)],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap_or(0);
|
||||
if others >= 2 {
|
||||
kind = "bot";
|
||||
let _ = db.execute(
|
||||
"UPDATE downloads SET kind = 'bot' WHERE visitor = ?1 AND ts >= ?2 AND kind = 'human'",
|
||||
rusqlite::params![c.visitor, ago_utc(10)],
|
||||
);
|
||||
}
|
||||
}
|
||||
let _ = db.execute(
|
||||
"INSERT INTO downloads (ts, platform, version, asset, country, region, city, lang, referrer)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
|
||||
"INSERT INTO downloads (ts, platform, version, asset, country, region, city, lang, referrer, visitor, kind, ua)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)",
|
||||
rusqlite::params![
|
||||
chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
|
||||
now_utc(),
|
||||
asset.platform,
|
||||
release.version,
|
||||
asset.name,
|
||||
country,
|
||||
region,
|
||||
city,
|
||||
lang,
|
||||
referrer
|
||||
c.country,
|
||||
c.region,
|
||||
c.city,
|
||||
c.lang,
|
||||
referrer,
|
||||
c.visitor,
|
||||
kind,
|
||||
c.ua
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
@ -441,13 +658,8 @@ fn pairs(db: &rusqlite::Connection, sql: &str) -> Vec<(String, i64)> {
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn count(db: &rusqlite::Connection, filter: &str) -> i64 {
|
||||
db.query_row(
|
||||
&format!("SELECT COUNT(*) FROM downloads WHERE platform <> 'checksums' {filter}"),
|
||||
[],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap_or(0)
|
||||
fn number(db: &rusqlite::Connection, sql: &str) -> i64 {
|
||||
db.query_row(sql, [], |r| r.get(0)).unwrap_or(0)
|
||||
}
|
||||
|
||||
fn esc(s: &str) -> String {
|
||||
|
|
@ -462,7 +674,7 @@ fn table(title: &str, rows: &[(String, i64)]) -> String {
|
|||
let max = rows.iter().map(|r| r.1).max().unwrap_or(1).max(1);
|
||||
let mut out = format!("<section><h2>{}</h2><table>", esc(title));
|
||||
if rows.is_empty() {
|
||||
out.push_str("<tr><td class=muted>No downloads yet</td></tr>");
|
||||
out.push_str("<tr><td class=muted>Пока пусто</td></tr>");
|
||||
}
|
||||
for (label, n) in rows {
|
||||
let w = (*n as f64 / max as f64 * 100.0).round();
|
||||
|
|
@ -475,6 +687,19 @@ fn table(title: &str, rows: &[(String, i64)]) -> String {
|
|||
out
|
||||
}
|
||||
|
||||
/// SQL conditions for the periods of the summary (`ts` is UTC RFC 3339, the days follow
|
||||
/// the server's time zone, TZ in the environment).
|
||||
const PERIODS: &[(&str, &str)] = &[
|
||||
("Сегодня", "date(ts, 'localtime') = date('now', 'localtime')"),
|
||||
("7 дней", "ts >= strftime('%Y-%m-%dT%H:%M:%SZ', 'now', '-7 days')"),
|
||||
("30 дней", "ts >= strftime('%Y-%m-%dT%H:%M:%SZ', 'now', '-30 days')"),
|
||||
("Всё время", "1"),
|
||||
];
|
||||
|
||||
/// Human downloads of the program (the checksum file is not a download).
|
||||
const HUMAN_DL: &str = "FROM downloads WHERE kind = 'human' AND platform <> 'checksums'";
|
||||
const HUMAN_PV: &str = "FROM pageviews WHERE kind = 'human'";
|
||||
|
||||
async fn stats(State(state): State<Shared>, headers: HeaderMap) -> Response {
|
||||
if !authorized(&state.config, &headers) {
|
||||
return ask_password();
|
||||
|
|
@ -482,57 +707,152 @@ async fn stats(State(state): State<Shared>, headers: HeaderMap) -> Response {
|
|||
let Ok(db) = state.db.lock() else {
|
||||
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
||||
};
|
||||
// "Today" and the days follow the server's time zone (TZ in the environment).
|
||||
let total = count(&db, "");
|
||||
let today = count(&db, "AND date(ts, 'localtime') = date('now', 'localtime')");
|
||||
let week = count(&db, "AND ts >= datetime('now', '-7 days')");
|
||||
let month = count(&db, "AND ts >= datetime('now', '-30 days')");
|
||||
let base = "FROM downloads WHERE platform <> 'checksums'";
|
||||
let by_platform = pairs(&db, &format!("SELECT platform, COUNT(*) {base} GROUP BY 1 ORDER BY 2 DESC"));
|
||||
let by_version = pairs(&db, &format!("SELECT version, COUNT(*) {base} GROUP BY 1 ORDER BY 2 DESC LIMIT 15"));
|
||||
let by_country = pairs(&db, &format!("SELECT country, COUNT(*) {base} GROUP BY 1 ORDER BY 2 DESC LIMIT 30"));
|
||||
let by_region = pairs(
|
||||
&db,
|
||||
&format!(
|
||||
"SELECT country || ' · ' || COALESCE(region, '—') || COALESCE(' · ' || city, ''), COUNT(*) {base} GROUP BY 1 ORDER BY 2 DESC LIMIT 30"
|
||||
),
|
||||
|
||||
// Summary: visitors (one per browser and day), who of them downloaded, downloads.
|
||||
let mut summary = String::from(
|
||||
"<section class=wide><table class=summary><tr><th></th>",
|
||||
);
|
||||
let by_lang = pairs(&db, &format!("SELECT lang, COUNT(*) {base} GROUP BY 1 ORDER BY 2 DESC LIMIT 15"));
|
||||
let days: HashMap<String, i64> = pairs(
|
||||
&db,
|
||||
&format!(
|
||||
"SELECT date(ts, 'localtime'), COUNT(*) {base} AND ts >= datetime('now', '-31 days') GROUP BY 1"
|
||||
),
|
||||
)
|
||||
.into_iter()
|
||||
.collect();
|
||||
let mut daily = Vec::new();
|
||||
for back in (0..30).rev() {
|
||||
let day = (chrono::Local::now() - chrono::Duration::days(back))
|
||||
.format("%Y-%m-%d")
|
||||
.to_string();
|
||||
let n = days.get(&day).copied().unwrap_or(0);
|
||||
daily.push((day, n));
|
||||
for (name, _) in PERIODS {
|
||||
summary.push_str(&format!("<th class=num>{name}</th>"));
|
||||
}
|
||||
let max_day = daily.iter().map(|d| d.1).max().unwrap_or(1).max(1);
|
||||
let mut chart = String::from("<section class=wide><h2>Last 30 days</h2><div class=chart>");
|
||||
for (day, n) in &daily {
|
||||
let h = (*n as f64 / max_day as f64 * 100.0).round();
|
||||
summary.push_str("</tr>");
|
||||
let mut rows: Vec<(&str, &str, Vec<String>)> = vec![
|
||||
("Посетители", "открыли страницу; один браузер за день — один посетитель", vec![]),
|
||||
("Скачали", "посетители, которые после этого что-то скачали", vec![]),
|
||||
("Конверсия", "скачали / посетители", vec![]),
|
||||
("Скачивания", "все скачивания людьми, включая прямые ссылки и повторы", vec![]),
|
||||
];
|
||||
for (_, cond) in PERIODS {
|
||||
let visitors = number(
|
||||
&db,
|
||||
&format!("SELECT COUNT(DISTINCT substr(ts, 1, 10) || visitor) {HUMAN_PV} AND {cond}"),
|
||||
);
|
||||
let converted = number(
|
||||
&db,
|
||||
&format!(
|
||||
"SELECT COUNT(DISTINCT substr(d.ts, 1, 10) || d.visitor) FROM downloads d
|
||||
WHERE d.kind = 'human' AND d.platform <> 'checksums' AND {}
|
||||
AND EXISTS (SELECT 1 FROM pageviews p WHERE p.visitor = d.visitor
|
||||
AND substr(p.ts, 1, 10) = substr(d.ts, 1, 10) AND p.ts <= d.ts)",
|
||||
cond.replace("ts", "d.ts")
|
||||
),
|
||||
);
|
||||
let downloads = number(&db, &format!("SELECT COUNT(*) {HUMAN_DL} AND {cond}"));
|
||||
let rate = if visitors > 0 {
|
||||
format!("{:.1}%", converted as f64 * 100.0 / visitors as f64)
|
||||
} else {
|
||||
"—".into()
|
||||
};
|
||||
rows[0].2.push(visitors.to_string());
|
||||
rows[1].2.push(converted.to_string());
|
||||
rows[2].2.push(rate);
|
||||
rows[3].2.push(downloads.to_string());
|
||||
}
|
||||
for (name, hint, cells) in &rows {
|
||||
summary.push_str(&format!(
|
||||
"<tr><td><b>{name}</b><br><small class=muted>{hint}</small></td>"
|
||||
));
|
||||
for c in cells {
|
||||
summary.push_str(&format!("<td class=\"num big\">{c}</td>"));
|
||||
}
|
||||
summary.push_str("</tr>");
|
||||
}
|
||||
summary.push_str("</table></section>");
|
||||
|
||||
// What was left out, all time.
|
||||
let left_out = |table: &str| -> HashMap<String, i64> {
|
||||
pairs(
|
||||
&db,
|
||||
&format!("SELECT kind, COUNT(*) FROM {table} WHERE kind <> 'human' GROUP BY 1"),
|
||||
)
|
||||
.into_iter()
|
||||
.collect()
|
||||
};
|
||||
let (dl_out, pv_out) = (left_out("downloads"), left_out("pageviews"));
|
||||
let get = |m: &HashMap<String, i64>, k: &str| m.get(k).copied().unwrap_or(0);
|
||||
let excluded = format!(
|
||||
"<p class=muted>Не учтено за всё время (скачивания / просмотры): боты {} / {}, вы {} / {}, локальная сеть {} / {}.</p>",
|
||||
get(&dl_out, "bot"),
|
||||
get(&pv_out, "bot"),
|
||||
get(&dl_out, "owner"),
|
||||
get(&pv_out, "owner"),
|
||||
get(&dl_out, "local"),
|
||||
get(&pv_out, "local"),
|
||||
);
|
||||
|
||||
// The last 30 days: visitors and downloads.
|
||||
let by_day = |sql: String| -> HashMap<String, i64> { pairs(&db, &sql).into_iter().collect() };
|
||||
let since = "ts >= strftime('%Y-%m-%dT%H:%M:%SZ', 'now', '-31 days')";
|
||||
let visits = by_day(format!(
|
||||
"SELECT date(ts, 'localtime'), COUNT(DISTINCT visitor) {HUMAN_PV} AND {since} GROUP BY 1"
|
||||
));
|
||||
let downloads = by_day(format!(
|
||||
"SELECT date(ts, 'localtime'), COUNT(*) {HUMAN_DL} AND {since} GROUP BY 1"
|
||||
));
|
||||
let days: Vec<String> = (0..30)
|
||||
.rev()
|
||||
.map(|back| {
|
||||
(chrono::Local::now() - chrono::Duration::days(back))
|
||||
.format("%Y-%m-%d")
|
||||
.to_string()
|
||||
})
|
||||
.collect();
|
||||
let max = days
|
||||
.iter()
|
||||
.map(|d| visits.get(d).copied().unwrap_or(0).max(downloads.get(d).copied().unwrap_or(0)))
|
||||
.max()
|
||||
.unwrap_or(1)
|
||||
.max(1);
|
||||
let mut chart = String::from(
|
||||
"<section class=wide><h2>30 дней <span class=legend><i class=v></i>посетители <i class=d></i>скачивания</span></h2><div class=chart>",
|
||||
);
|
||||
for day in &days {
|
||||
let (v, d) = (
|
||||
visits.get(day).copied().unwrap_or(0),
|
||||
downloads.get(day).copied().unwrap_or(0),
|
||||
);
|
||||
let h = |n: i64| (n as f64 / max as f64 * 100.0).round();
|
||||
chart.push_str(&format!(
|
||||
"<div title=\"{day}: {n}\"><span style=\"height:{h}%\"></span><small>{}</small></div>",
|
||||
"<div title=\"{day}: посетителей {v}, скачиваний {d}\"><p><span class=v style=\"height:{}%\"></span><span class=d style=\"height:{}%\"></span></p><small>{}</small></div>",
|
||||
h(v),
|
||||
h(d),
|
||||
&day[8..]
|
||||
));
|
||||
}
|
||||
chart.push_str("</div></section>");
|
||||
|
||||
let by_platform = pairs(&db, &format!("SELECT platform, COUNT(*) {HUMAN_DL} GROUP BY 1 ORDER BY 2 DESC"));
|
||||
let by_version = pairs(&db, &format!("SELECT version, COUNT(*) {HUMAN_DL} GROUP BY 1 ORDER BY 2 DESC LIMIT 15"));
|
||||
let by_country = pairs(&db, &format!("SELECT country, COUNT(*) {HUMAN_DL} GROUP BY 1 ORDER BY 2 DESC LIMIT 30"));
|
||||
let by_region = pairs(
|
||||
&db,
|
||||
&format!(
|
||||
"SELECT COALESCE(country, '—') || ' · ' || COALESCE(region, '—') || COALESCE(' · ' || city, ''), COUNT(*) {HUMAN_DL} GROUP BY 1 ORDER BY 2 DESC LIMIT 30"
|
||||
),
|
||||
);
|
||||
let visitors_by_country = pairs(
|
||||
&db,
|
||||
&format!("SELECT country, COUNT(DISTINCT substr(ts, 1, 10) || visitor) {HUMAN_PV} GROUP BY 1 ORDER BY 2 DESC LIMIT 30"),
|
||||
);
|
||||
let by_page = pairs(
|
||||
&db,
|
||||
&format!("SELECT page, COUNT(DISTINCT substr(ts, 1, 10) || visitor) {HUMAN_PV} GROUP BY 1 ORDER BY 2 DESC"),
|
||||
);
|
||||
let by_referrer = pairs(
|
||||
&db,
|
||||
&format!("SELECT COALESCE(referrer, 'напрямую'), COUNT(DISTINCT substr(ts, 1, 10) || visitor) {HUMAN_PV} GROUP BY 1 ORDER BY 2 DESC LIMIT 20"),
|
||||
);
|
||||
|
||||
let mut recent = String::from(
|
||||
"<section class=wide><h2>Latest downloads</h2><table><tr><th>Time (UTC)</th><th>Platform</th><th>Version</th><th>Where</th><th>Language</th><th>From</th></tr>",
|
||||
"<section class=wide><h2>Последние скачивания (все, включая отсеянные)</h2><table><tr><th>Время (UTC)</th><th>Файл</th><th>Версия</th><th>Где</th><th>Язык</th><th>Откуда</th><th>Кто</th></tr>",
|
||||
);
|
||||
if let Ok(mut stmt) = db.prepare(
|
||||
"SELECT ts, platform, version, country, region, city, lang, referrer FROM downloads ORDER BY id DESC LIMIT 50",
|
||||
"SELECT ts, platform, version, country, region, city, lang, referrer, kind, ua FROM downloads ORDER BY id DESC LIMIT 50",
|
||||
) {
|
||||
let rows = stmt.query_map([], |r| {
|
||||
let s = |i| r.get::<_, Option<String>>(i).map(|v| v.unwrap_or_default());
|
||||
Ok([s(0)?, s(1)?, s(2)?, s(3)?, s(4)?, s(5)?, s(6)?, s(7)?])
|
||||
(0..10)
|
||||
.map(|i| r.get::<_, Option<String>>(i).map(|v| v.unwrap_or_default()))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
});
|
||||
for row in rows.into_iter().flatten().flatten() {
|
||||
let place = [&row[3], &row[4], &row[5]]
|
||||
|
|
@ -541,68 +861,102 @@ async fn stats(State(state): State<Shared>, headers: HeaderMap) -> Response {
|
|||
.map(|s| esc(s))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" · ");
|
||||
let who = match row[8].as_str() {
|
||||
"human" => "человек",
|
||||
"bot" => "бот",
|
||||
"owner" => "вы",
|
||||
"local" => "локальная сеть",
|
||||
other => other,
|
||||
};
|
||||
let class = if row[8] == "human" { "" } else { " class=muted" };
|
||||
recent.push_str(&format!(
|
||||
"<tr><td>{}</td><td>{}</td><td>{}</td><td>{place}</td><td>{}</td><td>{}</td></tr>",
|
||||
"<tr{class}><td>{}</td><td>{}</td><td>{}</td><td>{place}</td><td>{}</td><td>{}</td><td title=\"{}\">{who}</td></tr>",
|
||||
esc(&row[0].replace('T', " ").replace('Z', "")),
|
||||
esc(&row[1]),
|
||||
esc(&row[2]),
|
||||
esc(&row[6]),
|
||||
esc(&row[7])
|
||||
esc(&row[7]),
|
||||
esc(&row[9]),
|
||||
));
|
||||
}
|
||||
}
|
||||
recent.push_str("</table></section>");
|
||||
let tile = |label: &str, n: i64| format!("<div class=tile><b>{n}</b><span>{label}</span></div>");
|
||||
|
||||
let page = format!(
|
||||
r#"<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<meta name=robots content=noindex><title>ChessPenguin · downloads</title><style>
|
||||
:root{{color-scheme:light dark;--bg:#f6f7f9;--fg:#1b1f24;--muted:#6b7280;--card:#fff;--line:#e5e7eb;--accent:#1f6fa8}}
|
||||
@media(prefers-color-scheme:dark){{:root{{--bg:#16181b;--fg:#e6e8eb;--muted:#9aa1ab;--card:#1f2226;--line:#2c3036;--accent:#4a9be0}}}}
|
||||
r#"<!doctype html><html lang=ru><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<meta name=robots content=noindex><title>ChessPenguin · статистика</title><style>
|
||||
:root{{color-scheme:light dark;--bg:#f6f7f9;--fg:#1b1f24;--muted:#6b7280;--card:#fff;--line:#e5e7eb;--accent:#1f6fa8;--soft:#a9c8e2}}
|
||||
@media(prefers-color-scheme:dark){{:root{{--bg:#16181b;--fg:#e6e8eb;--muted:#9aa1ab;--card:#1f2226;--line:#2c3036;--accent:#4a9be0;--soft:#2f4b63}}}}
|
||||
body{{margin:0;font:15px/1.45 system-ui,sans-serif;background:var(--bg);color:var(--fg)}}
|
||||
main{{max-width:1100px;margin:0 auto;padding:24px 16px}} h1{{font-size:22px;margin:0 0 16px}}
|
||||
.tiles{{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin-bottom:20px}}
|
||||
.tile{{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:14px}}
|
||||
.tile b{{display:block;font-size:28px}} .tile span{{color:var(--muted)}}
|
||||
.grid{{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px}}
|
||||
.grid{{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px;margin-top:16px}}
|
||||
section{{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:14px;overflow-x:auto}}
|
||||
section.wide{{margin-top:16px}} h2{{font-size:15px;margin:0 0 10px}}
|
||||
table{{border-collapse:collapse;width:100%}} td,th{{padding:4px 6px;border-bottom:1px solid var(--line);text-align:left;white-space:nowrap}}
|
||||
.num{{text-align:right;width:60px}} .bar{{width:40%}} .bar span{{display:block;height:8px;border-radius:4px;background:var(--accent)}}
|
||||
.muted{{color:var(--muted)}} .chart{{display:flex;align-items:flex-end;gap:3px;height:140px}}
|
||||
.chart div{{flex:1;display:flex;flex-direction:column;justify-content:flex-end;height:100%;text-align:center}}
|
||||
.chart span{{background:var(--accent);border-radius:3px 3px 0 0;min-height:1px}} .chart small{{color:var(--muted);font-size:10px}}
|
||||
.summary td{{padding:10px 8px}} .summary td:first-child{{white-space:normal}} .big{{font-size:24px;font-weight:600}}
|
||||
.grid td:first-child{{max-width:230px;overflow:hidden;text-overflow:ellipsis}} .num{{text-align:right;width:60px}} .bar{{width:40%}} .bar span{{display:block;height:8px;border-radius:4px;background:var(--accent)}}
|
||||
.muted{{color:var(--muted)}} .chart{{display:flex;gap:3px;height:150px}}
|
||||
.chart div{{flex:1;display:flex;flex-direction:column;text-align:center}}
|
||||
.chart p{{flex:1;margin:0;display:flex;align-items:flex-end;justify-content:center;gap:1px}}
|
||||
.chart p span{{flex:1;max-width:10px;border-radius:2px 2px 0 0;min-height:1px}}
|
||||
.v{{background:var(--soft)}} .d{{background:var(--accent)}} .chart small{{color:var(--muted);font-size:10px}}
|
||||
.legend{{font-weight:400;color:var(--muted);margin-left:12px}} .legend i{{display:inline-block;width:10px;height:10px;border-radius:2px;margin:0 4px 0 10px;vertical-align:-1px}}
|
||||
a{{color:var(--accent)}}</style></head><body><main>
|
||||
<h1>ChessPenguin downloads</h1>
|
||||
<div class=tiles>{}{}{}{}</div>
|
||||
<div class=grid>{}{}{}{}{}</div>{chart}{recent}
|
||||
<p class=muted>Checksum downloads are not counted. <a href="/stats.csv">Download all as CSV</a> · IP geolocation by <a href="https://db-ip.com">DB-IP</a></p>
|
||||
<h1>ChessPenguin · статистика</h1>
|
||||
{summary}{excluded}{chart}
|
||||
<div class=grid>{}{}{}{}{}{}{}</div>{recent}
|
||||
<p class=muted>Считаются только люди: боты, ваши визиты (браузер, открывший эту страницу) и локальная сеть отсеиваются. Посетители считаются по странице, выполнившей JavaScript. IP не хранится.
|
||||
<a href="/stats.csv">Скачивания в CSV</a> · <a href="/stats.csv?t=visits">Просмотры в CSV</a> · Геолокация по IP: <a href="https://db-ip.com">DB-IP</a></p>
|
||||
</main></body></html>"#,
|
||||
tile("today", today),
|
||||
tile("last 7 days", week),
|
||||
tile("last 30 days", month),
|
||||
tile("all time", total),
|
||||
table("By platform", &by_platform),
|
||||
table("By version", &by_version),
|
||||
table("By country", &by_country),
|
||||
table("By region and city", &by_region),
|
||||
table("By browser language", &by_lang),
|
||||
table("Скачивания по платформам", &by_platform),
|
||||
table("Скачивания по версиям", &by_version),
|
||||
table("Скачивания по странам", &by_country),
|
||||
table("Скачивания по регионам и городам", &by_region),
|
||||
table("Посетители по странам", &visitors_by_country),
|
||||
table("Посетители по языку страницы", &by_page),
|
||||
table("Откуда пришли посетители", &by_referrer),
|
||||
);
|
||||
Html(page).into_response()
|
||||
// Marks this browser as the owner's, so its own visits are left out of the counts.
|
||||
(
|
||||
[(
|
||||
header::SET_COOKIE,
|
||||
"cp_owner=1; Max-Age=31536000; Path=/; HttpOnly; SameSite=Lax",
|
||||
)],
|
||||
Html(page),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
async fn stats_csv(State(state): State<Shared>, headers: HeaderMap) -> Response {
|
||||
/// `/stats.csv`: every download; `/stats.csv?t=visits`: every page view.
|
||||
async fn stats_csv(
|
||||
State(state): State<Shared>,
|
||||
Query(q): Query<HashMap<String, String>>,
|
||||
headers: HeaderMap,
|
||||
) -> Response {
|
||||
if !authorized(&state.config, &headers) {
|
||||
return ask_password();
|
||||
}
|
||||
let Ok(db) = state.db.lock() else {
|
||||
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
||||
};
|
||||
let mut out = String::from("time_utc,platform,version,asset,country,region,city,language,referrer\n");
|
||||
if let Ok(mut stmt) = db.prepare(
|
||||
"SELECT ts, platform, version, asset, country, region, city, lang, referrer FROM downloads ORDER BY id",
|
||||
) {
|
||||
let (head, sql, name) = if q.get("t").map(String::as_str) == Some("visits") {
|
||||
(
|
||||
"time_utc,page,country,region,city,language,referrer,visitor,kind,user_agent",
|
||||
"SELECT ts, page, country, region, city, lang, referrer, visitor, kind, ua FROM pageviews ORDER BY id",
|
||||
"chesspenguin-visits.csv",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
"time_utc,platform,version,asset,country,region,city,language,referrer,visitor,kind,user_agent",
|
||||
"SELECT ts, platform, version, asset, country, region, city, lang, referrer, visitor, kind, ua FROM downloads ORDER BY id",
|
||||
"chesspenguin-downloads.csv",
|
||||
)
|
||||
};
|
||||
let columns = head.split(',').count();
|
||||
let mut out = format!("{head}\n");
|
||||
if let Ok(mut stmt) = db.prepare(sql) {
|
||||
let rows = stmt.query_map([], |r| {
|
||||
(0..9)
|
||||
(0..columns)
|
||||
.map(|i| r.get::<_, Option<String>>(i).map(|v| v.unwrap_or_default()))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
});
|
||||
|
|
@ -617,13 +971,35 @@ async fn stats_csv(State(state): State<Shared>, headers: HeaderMap) -> Response
|
|||
}
|
||||
(
|
||||
[
|
||||
(header::CONTENT_TYPE, "text/csv; charset=utf-8"),
|
||||
(header::CONTENT_TYPE, "text/csv; charset=utf-8".to_string()),
|
||||
(
|
||||
header::CONTENT_DISPOSITION,
|
||||
"attachment; filename=\"chesspenguin-downloads.csv\"",
|
||||
format!("attachment; filename=\"{name}\""),
|
||||
),
|
||||
],
|
||||
out,
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bots_and_local_addresses() {
|
||||
let chrome = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0 Safari/537.36";
|
||||
assert!(!looks_like_bot(chrome, Some("ru-RU")));
|
||||
assert!(looks_like_bot(chrome, None));
|
||||
assert!(looks_like_bot("curl/8.10", Some("en")));
|
||||
assert!(looks_like_bot("Mozilla/5.0 (compatible; Googlebot/2.1)", Some("en")));
|
||||
assert!(looks_like_bot("Mozilla/5.0 HeadlessChrome/141.0", Some("en")));
|
||||
assert!(looks_like_bot("TelegramBot (like TwitterBot)", Some("en")));
|
||||
for local in ["192.168.8.20", "10.0.0.1", "127.0.0.1", "::1", "fd00::1", "::ffff:192.168.1.2"] {
|
||||
assert!(is_local(local.parse().unwrap()), "{local}");
|
||||
}
|
||||
for public in ["8.8.8.8", "77.88.8.8", "2a00:1450:4001:830::200e"] {
|
||||
assert!(!is_local(public.parse().unwrap()), "{public}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
"support_issues": "Sie können auch ein Issue auf GitHub eröffnen:",
|
||||
"support_hint": "Geben Sie bei einem Problem bitte Ihre ChessPenguin-Version und Ihr System an und hängen Sie die PGN-Datei an, wenn es um eine Partie geht.",
|
||||
"footer_license": "Freie Software unter GPL-3.0-or-later",
|
||||
"footer_privacy": "Keine Cookies, keine Tracker. Download-Zahlen und Länder werden nur auf dem Server erfasst.",
|
||||
"footer_privacy": "Keine Cookies, keine Tracker. Besuche, Downloads und Länder werden nur auf dem Server gezählt, ohne IP-Adressen zu speichern.",
|
||||
"footer_geo": "IP-Geolokalisierung von",
|
||||
"nf_title": "Seite nicht gefunden",
|
||||
"nf_text": "Die gesuchte Seite oder Datei gibt es hier nicht.",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
"support_issues": "You can also open an issue on GitHub:",
|
||||
"support_hint": "When reporting a problem, please mention your ChessPenguin version and system, and attach the PGN file if the problem is with a game.",
|
||||
"footer_license": "Free software under GPL-3.0-or-later",
|
||||
"footer_privacy": "No cookies, no trackers. Download counts and country statistics are collected on the server only.",
|
||||
"footer_privacy": "No cookies, no trackers. Visits, downloads and countries are counted on the server only, without storing IP addresses.",
|
||||
"footer_geo": "IP geolocation by",
|
||||
"nf_title": "Page not found",
|
||||
"nf_text": "The page or file you were looking for isn't here.",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
"support_issues": "También puedes abrir una incidencia en GitHub:",
|
||||
"support_hint": "Al informar de un problema, indica tu versión de ChessPenguin y tu sistema, y adjunta el archivo PGN si el problema es con una partida.",
|
||||
"footer_license": "Software libre bajo GPL-3.0-or-later",
|
||||
"footer_privacy": "Sin cookies ni rastreadores. Las descargas y los países se cuentan solo en el servidor.",
|
||||
"footer_privacy": "Sin cookies ni rastreadores. Las visitas, descargas y países se cuentan solo en el servidor, sin guardar direcciones IP.",
|
||||
"footer_geo": "Geolocalización IP por",
|
||||
"nf_title": "Página no encontrada",
|
||||
"nf_text": "La página o el archivo que buscabas no está aquí.",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
"support_issues": "Vous pouvez aussi ouvrir un ticket sur GitHub :",
|
||||
"support_hint": "Pour signaler un problème, indiquez votre version de ChessPenguin et votre système, et joignez le fichier PGN si le problème concerne une partie.",
|
||||
"footer_license": "Logiciel libre sous GPL-3.0-or-later",
|
||||
"footer_privacy": "Sans cookies ni traceurs. Les nombres de téléchargements et les pays sont comptés uniquement sur le serveur.",
|
||||
"footer_privacy": "Sans cookies ni traceurs. Les visites, téléchargements et pays sont comptés uniquement sur le serveur, sans conserver les adresses IP.",
|
||||
"footer_geo": "Géolocalisation IP par",
|
||||
"nf_title": "Page introuvable",
|
||||
"nf_text": "La page ou le fichier que vous cherchiez n'est pas ici.",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
"support_issues": "Puoi anche aprire una segnalazione su GitHub:",
|
||||
"support_hint": "Quando segnali un problema, indica la versione di ChessPenguin e il sistema, e allega il file PGN se il problema riguarda una partita.",
|
||||
"footer_license": "Software libero sotto GPL-3.0-or-later",
|
||||
"footer_privacy": "Niente cookie né tracker. Download e paesi sono contati solo sul server.",
|
||||
"footer_privacy": "Niente cookie né tracker. Visite, download e paesi sono contati solo sul server, senza conservare gli indirizzi IP.",
|
||||
"footer_geo": "Geolocalizzazione IP di",
|
||||
"nf_title": "Pagina non trovata",
|
||||
"nf_text": "La pagina o il file che cercavi non è qui.",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
"support_issues": "Можно также открыть задачу на GitHub:",
|
||||
"support_hint": "Сообщая о проблеме, укажите версию ChessPenguin и систему, а если проблема с партией — приложите файл PGN.",
|
||||
"footer_license": "Свободная программа под GPL-3.0-or-later",
|
||||
"footer_privacy": "Без cookie и трекеров. Число загрузок и страны считаются только на сервере.",
|
||||
"footer_privacy": "Без cookie и трекеров. Посещения, загрузки и страны считаются только на сервере, IP-адреса не хранятся.",
|
||||
"footer_geo": "Геолокация по IP —",
|
||||
"nf_title": "Страница не найдена",
|
||||
"nf_text": "Страницы или файла, который вы искали, здесь нет.",
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@
|
|||
<a href="https://github.com/vrubelroman/chessPenguin/releases/tag/v{version}" rel="noopener">{{t:whats_new}}</a>
|
||||
</p>
|
||||
<p class="links" id="hero-formats" hidden>{{t:other_formats}}
|
||||
<a href="/download/deb" data-platform="deb">.deb</a> ·
|
||||
<a href="/download/rpm" data-platform="rpm">.rpm</a> ·
|
||||
<a href="/download/arch" data-platform="arch">Arch</a> ·
|
||||
<a href="/download/appimage" data-platform="appimage">AppImage</a> ·
|
||||
<a href="/download/flatpak" data-platform="flatpak">Flatpak</a> ·
|
||||
<a rel="nofollow" href="/download/deb" data-platform="deb">.deb</a> ·
|
||||
<a rel="nofollow" href="/download/rpm" data-platform="rpm">.rpm</a> ·
|
||||
<a rel="nofollow" href="/download/arch" data-platform="arch">Arch</a> ·
|
||||
<a rel="nofollow" href="/download/appimage" data-platform="appimage">AppImage</a> ·
|
||||
<a rel="nofollow" href="/download/flatpak" data-platform="flatpak">Flatpak</a> ·
|
||||
<a href="#download-linux">{{t:more}}</a>
|
||||
</p>
|
||||
<div class="mobile" id="hero-mobile" hidden>
|
||||
|
|
@ -134,7 +134,7 @@
|
|||
<div class="panel" role="tabpanel" id="download-windows" aria-labelledby="tab-windows">
|
||||
<h3 class="panel-h">Windows</h3>
|
||||
<div class="row" id="download-windows-zip">
|
||||
<div class="row-h"><h4>{{t:win_title}}</h4><span class="fmt">.zip · {size:windows}</span><a class="btn btn-small btn-accent" href="/download/windows" data-platform="windows">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:win_title}}</h4><span class="fmt">.zip · {size:windows}</span><a class="btn btn-small btn-accent" rel="nofollow" href="/download/windows" data-platform="windows">{{t:row_download}}</a></div>
|
||||
<ol class="steps"><li>{{t:win_step1}}</li><li>{{t:win_step2}}</li></ol>
|
||||
<p class="hint">{{t:win_note}}</p>
|
||||
</div>
|
||||
|
|
@ -143,7 +143,7 @@
|
|||
<div class="panel" role="tabpanel" id="download-macos" aria-labelledby="tab-macos">
|
||||
<h3 class="panel-h">macOS</h3>
|
||||
<div class="row" id="download-macos-dmg">
|
||||
<div class="row-h"><h4>{{t:mac_title}}</h4><span class="fmt">.dmg · {size:macos}</span><a class="btn btn-small btn-accent" href="/download/macos" data-platform="macos">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:mac_title}}</h4><span class="fmt">.dmg · {size:macos}</span><a class="btn btn-small btn-accent" rel="nofollow" href="/download/macos" data-platform="macos">{{t:row_download}}</a></div>
|
||||
<ol class="steps"><li>{{t:mac_step1}}</li><li>{{t:mac_step2}}</li></ol>
|
||||
<h5>{{t:mac15_title}}</h5>
|
||||
<ol class="steps"><li>{{t:mac15_step1}}</li><li>{{t:mac15_step2}}</li><li>{{t:mac15_step3}}</li></ol>
|
||||
|
|
@ -159,37 +159,37 @@
|
|||
<p class="hint">{{t:linux_intro}}</p>
|
||||
<div class="linux-rows">
|
||||
<div class="row" id="download-linux-appimage" data-os="other">
|
||||
<div class="row-h"><h4>{{t:lx_appimage}}</h4><span class="fmt">.AppImage · {size:appimage}</span><a class="btn btn-small btn-secondary" href="/download/appimage" data-platform="appimage">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:lx_appimage}}</h4><span class="fmt">.AppImage · {size:appimage}</span><a class="btn btn-small btn-secondary" rel="nofollow" href="/download/appimage" data-platform="appimage">{{t:row_download}}</a></div>
|
||||
<div class="cmd"><code>chmod +x ~/Downloads/{file:appimage}</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
<div class="cmd"><code>~/Downloads/{file:appimage}</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
</div>
|
||||
<div class="row" id="download-linux-deb" data-os="deb">
|
||||
<div class="row-h"><h4>{{t:lx_deb}}</h4><span class="fmt">.deb · {size:deb}</span><a class="btn btn-small btn-secondary" href="/download/deb" data-platform="deb">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:lx_deb}}</h4><span class="fmt">.deb · {size:deb}</span><a class="btn btn-small btn-secondary" rel="nofollow" href="/download/deb" data-platform="deb">{{t:row_download}}</a></div>
|
||||
<div class="cmd"><code>sudo apt install ~/Downloads/{file:deb}</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
</div>
|
||||
<div class="row" id="download-linux-rpm" data-os="rpm">
|
||||
<div class="row-h"><h4>{{t:lx_rpm}}</h4><span class="fmt">.rpm · {size:rpm}</span><a class="btn btn-small btn-secondary" href="/download/rpm" data-platform="rpm">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:lx_rpm}}</h4><span class="fmt">.rpm · {size:rpm}</span><a class="btn btn-small btn-secondary" rel="nofollow" href="/download/rpm" data-platform="rpm">{{t:row_download}}</a></div>
|
||||
<div class="cmd"><code>sudo dnf install ~/Downloads/{file:rpm}</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
<p class="hint">{{t:lx_rpm_suse}} <code>sudo zypper install ~/Downloads/{file:rpm}</code></p>
|
||||
</div>
|
||||
<div class="row" id="download-linux-arch" data-os="arch">
|
||||
<div class="row-h"><h4>{{t:lx_arch}}</h4><span class="fmt">.pkg.tar.zst · {size:arch}</span><a class="btn btn-small btn-secondary" href="/download/arch" data-platform="arch">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:lx_arch}}</h4><span class="fmt">.pkg.tar.zst · {size:arch}</span><a class="btn btn-small btn-secondary" rel="nofollow" href="/download/arch" data-platform="arch">{{t:row_download}}</a></div>
|
||||
<div class="cmd"><code>sudo pacman -U ~/Downloads/{file:arch}</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
</div>
|
||||
<div class="row" id="download-linux-flatpak" data-os="flatpak">
|
||||
<div class="row-h"><h4>{{t:lx_flatpak}}</h4><span class="fmt">.flatpak · {size:flatpak}</span><a class="btn btn-small btn-secondary" href="/download/flatpak" data-platform="flatpak">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:lx_flatpak}}</h4><span class="fmt">.flatpak · {size:flatpak}</span><a class="btn btn-small btn-secondary" rel="nofollow" href="/download/flatpak" data-platform="flatpak">{{t:row_download}}</a></div>
|
||||
<div class="cmd"><code>flatpak install --user ~/Downloads/{file:flatpak}</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
<div class="cmd"><code>flatpak run io.github.vrubelroman.chessPenguin</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
<p class="hint">{{t:lx_flatpak_note}}</p>
|
||||
</div>
|
||||
<div class="row quiet" id="download-linux-tar" data-os="tar">
|
||||
<div class="row-h"><h4>{{t:lx_tar}}</h4><span class="fmt">.tar.gz · {size:tarball}</span><a class="btn btn-small btn-secondary" href="/download/tarball" data-platform="tarball">{{t:row_download}}</a></div>
|
||||
<div class="row-h"><h4>{{t:lx_tar}}</h4><span class="fmt">.tar.gz · {size:tarball}</span><a class="btn btn-small btn-secondary" rel="nofollow" href="/download/tarball" data-platform="tarball">{{t:row_download}}</a></div>
|
||||
<p class="hint">{{t:lx_tar_text}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="verify">{{t:verify}} <a href="/download/checksums">SHA256SUMS.txt</a> · <a href="https://github.com/vrubelroman/chessPenguin/releases" rel="noopener">{{t:all_releases}} ↗</a> · <a href="https://github.com/vrubelroman/chessPenguin" rel="noopener">{{t:source_code}} ↗</a></p>
|
||||
<p class="verify">{{t:verify}} <a rel="nofollow" href="/download/checksums">SHA256SUMS.txt</a> · <a href="https://github.com/vrubelroman/chessPenguin/releases" rel="noopener">{{t:all_releases}} ↗</a> · <a href="https://github.com/vrubelroman/chessPenguin" rel="noopener">{{t:source_code}} ↗</a></p>
|
||||
<details class="verify-how"><summary>{{t:how_verify}}</summary>
|
||||
<p>{{t:how_verify_text}}</p>
|
||||
<p class="hint">Linux</p><div class="cmd"><code>sha256sum -c --ignore-missing SHA256SUMS.txt</code><button type="button" class="copy" aria-label="{{t:copy_aria}}">{{t:copy}}</button></div>
|
||||
|
|
|
|||
|
|
@ -312,4 +312,12 @@
|
|||
history.replaceState(null, "", location.pathname);
|
||||
open(Math.min(parseInt(m[1], 10), shots.length) - 1);
|
||||
}
|
||||
|
||||
// Page view for the statistics (no cookies): the server counts only pages that ran
|
||||
// this script, which leaves out most crawlers.
|
||||
try {
|
||||
if (navigator.sendBeacon) {
|
||||
navigator.sendBeacon("/hit", JSON.stringify({ p: location.pathname, r: document.referrer }));
|
||||
}
|
||||
} catch (e) { /* statistics are optional */ }
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue