Embeddable Replay Widget: - web/embed.html: Minimal standalone HTML with Open Graph and Twitter Card tags - web/src/embed.ts: TypeScript embed viewer with auto-play, progress bar, keyboard controls - R2 warm cache + B2 cold archive fallback for replay loading - ~7KB gzipped (well under 50KB target) Replay Playlists: - cmd/acb-indexer/src/playlists.ts: Auto-curated playlist generator - Featured, upsets, comebacks, domination, close games, long games, weekly categories - Uses match data to detect notable games - web/src/pages/playlists.ts: SPA page for browsing playlists - web/src/api-types.ts: Added playlist types and fetch functions Other changes: - web/src/replay-viewer.ts: Added getIsPlaying() method for embed viewer - web/vite.config.ts: Added embed.html as build entry point - web/app.html: Added Playlists nav link - web/public/img/embed-placeholder.svg: OG image placeholder Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
303 lines
7.1 KiB
HTML
303 lines
7.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>AI Code Battle - Replay</title>
|
|
|
|
<!-- Open Graph tags for social sharing -->
|
|
<meta property="og:type" content="video.other">
|
|
<meta property="og:site_name" content="AI Code Battle">
|
|
<meta property="og:title" content="AI Code Battle Replay">
|
|
<meta property="og:description" content="Watch an AI Code Battle replay - competitive bot programming at its finest.">
|
|
<meta property="og:image" content="https://ai-code-battle.pages.dev/img/embed-placeholder.svg">
|
|
<meta property="og:url" content="">
|
|
<meta property="og:video" content="">
|
|
|
|
<!-- Twitter Card -->
|
|
<meta name="twitter:card" content="player">
|
|
<meta name="twitter:site" content="@aicodebattle">
|
|
<meta name="twitter:title" content="AI Code Battle Replay">
|
|
<meta name="twitter:description" content="Watch an AI Code Battle replay">
|
|
<meta name="twitter:image" content="https://ai-code-battle.pages.dev/img/embed-placeholder.svg">
|
|
<meta name="twitter:player" content="">
|
|
<meta name="twitter:player:width" content="640">
|
|
<meta name="twitter:player:height" content="480">
|
|
|
|
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
html, body {
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
background-color: #0f172a;
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
}
|
|
|
|
.embed-container {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
position: relative;
|
|
}
|
|
|
|
.viewer-wrapper {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
background-color: #111827;
|
|
}
|
|
|
|
#replay-canvas {
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
}
|
|
|
|
/* Minimal controls bar */
|
|
.controls-bar {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 8px 12px;
|
|
background-color: #1e293b;
|
|
border-top: 1px solid #334155;
|
|
}
|
|
|
|
.controls-bar button {
|
|
background-color: #3b82f6;
|
|
color: white;
|
|
border: none;
|
|
padding: 6px 12px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
min-width: 60px;
|
|
transition: background-color 0.2s;
|
|
}
|
|
|
|
.controls-bar button:hover {
|
|
background-color: #2563eb;
|
|
}
|
|
|
|
.controls-bar button:disabled {
|
|
background-color: #475569;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.turn-display {
|
|
font-size: 12px;
|
|
color: #94a3b8;
|
|
min-width: 80px;
|
|
text-align: center;
|
|
}
|
|
|
|
.progress-bar {
|
|
flex: 1;
|
|
height: 4px;
|
|
background-color: #334155;
|
|
border-radius: 2px;
|
|
cursor: pointer;
|
|
position: relative;
|
|
}
|
|
|
|
.progress-fill {
|
|
height: 100%;
|
|
background-color: #3b82f6;
|
|
border-radius: 2px;
|
|
width: 0%;
|
|
transition: width 0.05s linear;
|
|
}
|
|
|
|
/* Speed control */
|
|
.speed-control {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.speed-control label {
|
|
font-size: 11px;
|
|
color: #64748b;
|
|
}
|
|
|
|
.speed-control select {
|
|
background-color: #0f172a;
|
|
border: 1px solid #334155;
|
|
color: #e2e8f0;
|
|
padding: 4px 8px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
/* Loading/error states */
|
|
.loading-overlay, .error-overlay {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background-color: rgba(15, 23, 42, 0.9);
|
|
color: #e2e8f0;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.loading-overlay .spinner {
|
|
width: 40px;
|
|
height: 40px;
|
|
border: 3px solid #334155;
|
|
border-top-color: #3b82f6;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
margin-right: 12px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.error-overlay {
|
|
color: #ef4444;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
|
|
.error-overlay .retry-btn {
|
|
background-color: #ef4444;
|
|
color: white;
|
|
border: none;
|
|
padding: 8px 16px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
/* Score overlay on canvas */
|
|
.score-overlay {
|
|
position: absolute;
|
|
top: 10px;
|
|
left: 10px;
|
|
background-color: rgba(0, 0, 0, 0.7);
|
|
border-radius: 4px;
|
|
padding: 8px 12px;
|
|
font-size: 12px;
|
|
color: #f1f5f9;
|
|
}
|
|
|
|
.score-overlay .player-score {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.score-overlay .player-score:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.score-overlay .color-dot {
|
|
width: 10px;
|
|
height: 10px;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
/* Match end overlay */
|
|
.end-overlay {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
display: none;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background-color: rgba(0, 0, 0, 0.75);
|
|
}
|
|
|
|
.end-overlay.visible {
|
|
display: flex;
|
|
}
|
|
|
|
.end-overlay .end-message {
|
|
text-align: center;
|
|
color: #f1f5f9;
|
|
}
|
|
|
|
.end-overlay .end-message h2 {
|
|
font-size: 24px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.end-overlay .end-message p {
|
|
font-size: 14px;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
/* Logo watermark */
|
|
.watermark {
|
|
position: absolute;
|
|
bottom: 60px;
|
|
right: 10px;
|
|
font-size: 10px;
|
|
color: rgba(255, 255, 255, 0.3);
|
|
text-decoration: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="embed-container">
|
|
<div class="viewer-wrapper">
|
|
<canvas id="replay-canvas"></canvas>
|
|
<div class="score-overlay" id="score-overlay"></div>
|
|
</div>
|
|
|
|
<div class="controls-bar">
|
|
<button id="play-btn" disabled>Play</button>
|
|
<button id="reset-btn" disabled>Reset</button>
|
|
<div class="turn-display" id="turn-display">0 / 0</div>
|
|
<div class="progress-bar" id="progress-bar">
|
|
<div class="progress-fill" id="progress-fill"></div>
|
|
</div>
|
|
<div class="speed-control">
|
|
<label>Speed:</label>
|
|
<select id="speed-select">
|
|
<option value="200">0.5x</option>
|
|
<option value="100" selected>1x</option>
|
|
<option value="50">2x</option>
|
|
<option value="25">4x</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="loading-overlay" id="loading-overlay">
|
|
<div class="spinner"></div>
|
|
<span>Loading replay...</span>
|
|
</div>
|
|
|
|
<div class="error-overlay" id="error-overlay" style="display: none;">
|
|
<span id="error-message">Failed to load replay</span>
|
|
<button class="retry-btn" id="retry-btn">Retry</button>
|
|
</div>
|
|
|
|
<div class="end-overlay" id="end-overlay">
|
|
<div class="end-message">
|
|
<h2 id="end-title">Match Complete</h2>
|
|
<p id="end-subtitle">Click replay to watch again</p>
|
|
</div>
|
|
</div>
|
|
|
|
<a href="https://ai-code-battle.pages.dev" target="_blank" class="watermark">AI Code Battle</a>
|
|
</div>
|
|
|
|
<script type="module" src="/src/embed.ts"></script>
|
|
</body>
|
|
</html>
|