Add openings
This commit is contained in:
1 parent
9c5c599a26
commit
3f8dacfe1c
5 files changed
+22
-24
No files matched your search
@@ -16,6 +16,17 @@ MAX_PLIES = int(os.environ.get("MAX_PLIES", "500"))
|
||||
MATE_SCORE_CP = 100_000
|
||||
|
||||
|
||||
def _opening_name(headers) -> str | None:
|
||||
url = headers.get("ECOUrl", "")
|
||||
slug = url.rstrip("/").rsplit("/", 1)[-1]
|
||||
words = []
|
||||
for token in slug.split("-"):
|
||||
if token[:1].isdigit():
|
||||
break
|
||||
words.append(token)
|
||||
return " ".join(words) or headers.get("ECO") or None
|
||||
|
||||
|
||||
def _win_pct(cp: int) -> float:
|
||||
return 50 + 50 * (2 / (1 + math.exp(-0.00368208 * cp)) - 1)
|
||||
|
||||
@@ -115,6 +126,7 @@ async def analyze_pgn(pgn_text: str, username: str | None = None, depth: int = D
|
||||
"white_rating": white_rating if white_rating.isdigit() else None,
|
||||
"black_rating": black_rating if black_rating.isdigit() else None,
|
||||
"game_url": link if link.startswith("https://www.chess.com/") else None,
|
||||
"opening": _opening_name(game.headers),
|
||||
"result": game.headers.get("Result", ""),
|
||||
"initial_eval_cp": white_pov_evals[0],
|
||||
"initial_fen": game.headers.get("FEN", chess.STARTING_FEN),
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Chess.Sistav.com</title>
|
||||
<link rel="icon" href="/static/pieces/wN.svg" type="image/svg+xml" />
|
||||
<link rel="icon" href="/static/pieces/bQ.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/static/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="masthead">
|
||||
<div class="masthead-inner">
|
||||
<a href="/">Chess.Sistav.com</a>
|
||||
<a href="/" class="brand" aria-label="Chess.Sistav.com"><img src="/static/pieces/bQ.svg" alt="Chess.Sistav.com" width="26" height="26" /></a>
|
||||
<a href="https://sistav.com">← sistav.com</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<header>
|
||||
<a href="/" class="back-link">← Back to games</a>
|
||||
<h1 id="game-title"></h1>
|
||||
<p id="game-opening" class="subtitle"></p>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Chess.Sistav.com</title>
|
||||
<link rel="icon" href="/static/pieces/wN.svg" type="image/svg+xml" />
|
||||
<link rel="icon" href="/static/pieces/bQ.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/static/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="masthead">
|
||||
<div class="masthead-inner">
|
||||
<a href="/">Chess.Sistav.com</a>
|
||||
<a href="/" class="brand" aria-label="Chess.Sistav.com"><img src="/static/pieces/bQ.svg" alt="Chess.Sistav.com" width="26" height="26" /></a>
|
||||
<a href="https://sistav.com">← sistav.com</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,12 +20,8 @@ async function init() {
|
||||
const title = `${analysis.white} vs ${analysis.black}`;
|
||||
document.title = title;
|
||||
el("game-title").replaceChildren(gameLink(title));
|
||||
el("game-opening").textContent = analysis.opening || "";
|
||||
renderPlayerPlates();
|
||||
const back = document.querySelector(".back-link");
|
||||
if (back && analysis.username) {
|
||||
back.href = `/u/${encodeURIComponent(analysis.username)}`;
|
||||
back.textContent = `← Back to ${analysis.username}'s games`;
|
||||
}
|
||||
el("analysis-panel").hidden = false;
|
||||
renderMoveList();
|
||||
renderSummary();
|
||||
|
||||
+4
-14
@@ -34,10 +34,10 @@ body {
|
||||
.masthead-inner {
|
||||
max-width: 68rem;
|
||||
margin: 0 auto;
|
||||
padding: 0.9rem 1.5rem;
|
||||
padding: 0.6rem 1.5rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
font-variant: small-caps;
|
||||
@@ -46,6 +46,7 @@ body {
|
||||
color: var(--muted);
|
||||
}
|
||||
.masthead a { color: var(--ink); text-decoration: none; }
|
||||
.masthead .brand img { height: 26px; display: block; }
|
||||
.masthead a:hover { color: var(--gold); }
|
||||
|
||||
header { padding: 1.5rem 1.5rem 0; text-align: center; }
|
||||
@@ -53,7 +54,7 @@ header { padding: 1.5rem 1.5rem 0; text-align: center; }
|
||||
h1 {
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
font-size: clamp(1.7rem, 4vw, 2.5rem);
|
||||
font-size: clamp(1.45rem, 3.2vw, 2.1rem);
|
||||
line-height: 1.15;
|
||||
margin: 0 0 0.35rem;
|
||||
text-wrap: balance;
|
||||
@@ -63,17 +64,6 @@ h1 {
|
||||
.quiet-link { color: inherit; text-decoration: none; }
|
||||
.quiet-link:hover { color: var(--gold); }
|
||||
|
||||
.back-link {
|
||||
display: inline-block;
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
letter-spacing: 0.14em;
|
||||
font-size: 0.85rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.back-link:hover { color: var(--gold); }
|
||||
|
||||
main {
|
||||
padding: 0.75rem 1.5rem 3rem;
|
||||
max-width: 68rem;
|
||||
|
||||
Reference in new issue
Block a user