A pick is a repository edit, so the picker shows the Commons candidates cropped to the poster's frame, natural or bw as the service treats them, beside the picks of the circuit's other layouts, and gives the entry to copy (the picks file's "$comment" kept first). The builder sends every option of docs/posters.md as a query parameter, renders only on request and shows the answer's X-Credits and X-License. The licences page shows /licences: each source, its credit and the licence a picture made from it gets. Every page now carries the Formula 1 disclaimer at its foot, as F1's guidelines ask of an unofficial site, and the posters page lists the backgrounds the design keeps (no Esri). Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
221 lines
9.7 KiB
HTML
221 lines
9.7 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Posters · F1 Circuits API examples</title>
|
||
<meta name="description" content="Render F1 race posters, season posters and session thumbnails for Plex from the F1 Circuits API.">
|
||
<link rel="icon" href="data:,">
|
||
<link rel="stylesheet" href="site.css">
|
||
</head>
|
||
<body>
|
||
<header class="site">
|
||
<a class="brand" href="index.html">F1 <span>Circuits</span> API</a>
|
||
<nav aria-label="Examples">
|
||
<a href="index.html">Overview</a>
|
||
<a href="circuits.html">Circuit browser</a>
|
||
<a href="tracks.html">Track images</a>
|
||
<a href="map.html">GPS traces</a>
|
||
<a href="grand-prix.html">Grand prix lookup</a>
|
||
<a href="posters.html" aria-current="page">Posters</a>
|
||
<a href="builder.html">Poster builder</a>
|
||
<a href="kometa.html">Kometa</a>
|
||
<a href="library.html">Library</a>
|
||
<a href="picker.html">Photo picker</a>
|
||
<a href="licences.html">Licences</a>
|
||
</nav>
|
||
<div id="api-base"></div>
|
||
</header>
|
||
|
||
<main>
|
||
<h1>Posters</h1>
|
||
<p class="lead">
|
||
The API renders artwork for a Formula 1 library in Plex: a 1000×1500 poster per race and per season, and a
|
||
1920×1080 thumbnail per session of a race weekend. The server draws each one on request, fetching map tiles for its
|
||
background, and keeps it on disk afterwards; so this page renders only the one you ask for, when you press its
|
||
button.
|
||
</p>
|
||
|
||
<section class="card" id="races">
|
||
<h2>1. Choose a race</h2>
|
||
<p>The race poster and the session thumbnails name the race as Jolpica’s <code>raceName</code>; this list comes from Jolpica.</p>
|
||
<div class="controls" id="race-picker"></div>
|
||
<div class="request"></div>
|
||
<div class="status"></div>
|
||
</section>
|
||
|
||
<div class="grid-2">
|
||
<section class="card" id="race-poster">
|
||
<h2>Race poster</h2>
|
||
<p><code>/posters/race/{race name}/{season}.png?bg={background}</code>, 1000×1500: the round, the race’s name, the track and its date over a map of the circuit. Every other option is on the <a href="builder.html">poster builder</a>.</p>
|
||
<div class="controls">
|
||
<label><span>Background (<code>bg</code>)</span>
|
||
<select id="bg">
|
||
<option value="satellite">satellite: the layout’s picked Commons photo, the national aerial photo, or EOxCloudless (the default)</option>
|
||
<option value="osm">osm: OpenStreetMap street map</option>
|
||
<option value="dark">dark: OpenStreetMap, recoloured dark</option>
|
||
<option value="light">light: OpenStreetMap, recoloured light</option>
|
||
<option value="none">none: plain black, no tiles (fastest)</option>
|
||
</select>
|
||
</label>
|
||
<button type="button" class="primary" id="render-race">Render the race poster</button>
|
||
</div>
|
||
<div class="request compact"></div>
|
||
<div class="status idle">Not rendered yet.</div>
|
||
<div class="result preview"></div>
|
||
</section>
|
||
|
||
<section class="card" id="season-poster">
|
||
<h2>Season poster</h2>
|
||
<p><code>/posters/season/{season}.png</code>, 1000×1500: the year over a photo of that season’s cars, or over black when the server has no photo for it.</p>
|
||
<div class="controls">
|
||
<label>Season <input type="number" id="season" min="1950" max="2100"></label>
|
||
<button type="button" class="primary" id="render-season">Render the season poster</button>
|
||
</div>
|
||
<div class="request compact"></div>
|
||
<div class="status idle">Not rendered yet.</div>
|
||
<div class="result preview"></div>
|
||
</section>
|
||
</div>
|
||
|
||
<section class="card" id="session-thumb">
|
||
<h2>Session thumbnail</h2>
|
||
<p>
|
||
<code>/posters/session/{race name}/{season}/{session}.png</code>, 1920×1080: an aerial view of the circuit with
|
||
the race’s name and the session’s label. Kometa numbers a weekend’s episodes differently for a standard weekend
|
||
(10 episodes) and a sprint weekend (15); the list shows the chosen race’s format first, in episode order.
|
||
</p>
|
||
<div class="controls">
|
||
<label><span>Session (<code>session</code>)</span> <select id="session"></select></label>
|
||
<button type="button" class="primary" id="render-session">Render the thumbnail</button>
|
||
</div>
|
||
<div class="request"></div>
|
||
<div class="status idle">Not rendered yet.</div>
|
||
<div class="result preview"></div>
|
||
</section>
|
||
|
||
<h2>Every session slug</h2>
|
||
<table>
|
||
<thead><tr><th>Slug</th><th>Label on the thumbnail</th><th>Episode, standard weekend</th><th>Episode, sprint weekend</th></tr></thead>
|
||
<tbody id="slugs"></tbody>
|
||
</table>
|
||
</main>
|
||
|
||
<footer class="pager">
|
||
<a rel="prev" href="grand-prix.html">← Grand prix lookup</a>
|
||
<a class="home" href="index.html">All examples</a>
|
||
<a rel="next" href="builder.html">Poster builder →</a>
|
||
</footer>
|
||
<footer class="disclaimer">
|
||
<p>This website is unofficial and is not associated in any way with the Formula 1 companies. F1, FORMULA ONE,
|
||
FORMULA 1, FIA FORMULA ONE WORLD CHAMPIONSHIP, GRAND PRIX and related marks are trade marks of Formula One
|
||
Licensing B.V.</p>
|
||
<p><a href="licences.html">Licences and credits</a>: every source the pictures are made from, the licence each
|
||
picture takes from its sources, and the licence of the track files and the GPS traces (MIT).</p>
|
||
</footer>
|
||
|
||
<script src="site.js"></script>
|
||
<script>
|
||
(function () {
|
||
const { h, api, path, call, setRequest, setStatus, showImage, racePicker } = F1;
|
||
const $ = (id) => document.getElementById(id);
|
||
|
||
const STANDARD = F1.SESSIONS.standard;
|
||
const SPRINT = F1.SESSIONS.sprint;
|
||
const LABEL = Object.fromEntries([...STANDARD, ...SPRINT]);
|
||
const ALL = Object.keys(LABEL);
|
||
|
||
$('slugs').replaceChildren(...ALL.map((slug) => {
|
||
const std = STANDARD.findIndex(([s]) => s === slug);
|
||
const spr = SPRINT.findIndex(([s]) => s === slug);
|
||
return h('tr', {}, h('td', {}, h('code', {}, slug)), h('td', {}, LABEL[slug]),
|
||
h('td', {}, std >= 0 ? String(std + 1) : '–'), h('td', {}, spr >= 0 ? String(spr + 1) : '–'));
|
||
}));
|
||
|
||
let chosen = null;
|
||
let seasonTouched = false;
|
||
|
||
/** Shows the URL a button will call, without calling it; a result of another URL is cleared. */
|
||
function preview(card, url) {
|
||
card._wanted = url;
|
||
if (card._shown === url) return;
|
||
setRequest(card.querySelector('.request'), url);
|
||
card.querySelector('.result').replaceChildren();
|
||
card._shown = null;
|
||
if (!card.querySelector('.status').classList.contains('pending')) {
|
||
setStatus(card.querySelector('.status'), 'idle', 'Not rendered yet: press the button.');
|
||
}
|
||
}
|
||
|
||
async function render(card, button, url, alt, portrait) {
|
||
button.disabled = true;
|
||
try {
|
||
const answer = await call(card, url, { waiting: 'Rendering on the server: it fetches map tiles first, a few seconds the first time…' });
|
||
const out = card.querySelector('.result');
|
||
if (card._wanted !== url) {
|
||
setRequest(card.querySelector('.request'), card._wanted);
|
||
setStatus(card.querySelector('.status'), 'idle', 'The choice changed while it rendered: press the button again.');
|
||
return;
|
||
}
|
||
if (!answer) { out.replaceChildren(); return; }
|
||
await showImage(out, answer, 'png', { alt, tile: false, className: portrait ? 'poster portrait' : 'poster', status: card.querySelector('.status') });
|
||
card._shown = url;
|
||
} finally {
|
||
button.disabled = false;
|
||
}
|
||
}
|
||
|
||
const raceURL = () => api(path`/posters/race/${chosen.name}/${chosen.season}.png`) + `?bg=${encodeURIComponent($('bg').value)}`;
|
||
const seasonURL = () => api(path`/posters/season/${$('season').value}.png`);
|
||
const sessionURL = () => api(path`/posters/session/${chosen.name}/${chosen.season}/${$('session').value}.png`);
|
||
|
||
function fillSessions() {
|
||
const keep = $('session').value || 'race';
|
||
const own = chosen && chosen.sprint ? SPRINT : STANDARD;
|
||
const ownSlugs = new Set(own.map(([s]) => s));
|
||
const rest = ALL.filter((s) => !ownSlugs.has(s));
|
||
const format = chosen && chosen.race ? (chosen.sprint ? 'a sprint weekend' : 'a standard weekend') : 'format unknown, standard order';
|
||
$('session').replaceChildren(
|
||
h('optgroup', { label: `This race (${format})` },
|
||
...own.map(([s, label], i) => h('option', { value: s }, `Episode ${i + 1} · ${label} (${s})`))),
|
||
h('optgroup', { label: 'The other format’s slugs' },
|
||
...rest.map((s) => h('option', { value: s }, `${LABEL[s]} (${s})`))));
|
||
$('session').value = ALL.includes(keep) ? keep : 'race';
|
||
}
|
||
|
||
function previews() {
|
||
if (chosen && chosen.name) {
|
||
preview($('race-poster'), raceURL());
|
||
preview($('session-thumb'), sessionURL());
|
||
}
|
||
if ($('season').value) preview($('season-poster'), seasonURL());
|
||
}
|
||
|
||
$('bg').addEventListener('change', previews);
|
||
$('session').addEventListener('change', previews);
|
||
$('season').addEventListener('input', () => { seasonTouched = true; previews(); });
|
||
|
||
$('render-race').addEventListener('click', () => {
|
||
if (chosen && chosen.name) render($('race-poster'), $('render-race'), raceURL(), `${chosen.name} ${chosen.season} poster`, true);
|
||
});
|
||
$('render-season').addEventListener('click', () => {
|
||
if ($('season').value) render($('season-poster'), $('render-season'), seasonURL(), `${$('season').value} season poster`, true);
|
||
});
|
||
$('render-session').addEventListener('click', () => {
|
||
if (chosen && chosen.name) render($('session-thumb'), $('render-session'), sessionURL(), `${chosen.name} ${chosen.season} ${$('session').value} thumbnail`, false);
|
||
});
|
||
|
||
racePicker($('race-picker'), {
|
||
card: $('races'),
|
||
onChange: (c) => {
|
||
chosen = c;
|
||
if (!seasonTouched) $('season').value = c.season;
|
||
fillSessions();
|
||
previews();
|
||
},
|
||
});
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|