Upload 3 files
Browse files- leaderboard.html +16 -3
leaderboard.html
CHANGED
|
@@ -636,8 +636,21 @@
|
|
| 636 |
// ββββββββββββββββββββββββββββββββββββββββββββ
|
| 637 |
// CONFIG
|
| 638 |
// ββββββββββββββββββββββββββββββββββββββββββββ
|
| 639 |
-
|
| 640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
|
| 642 |
const FALLBACK_ENTRIES = [
|
| 643 |
{
|
|
@@ -723,7 +736,7 @@
|
|
| 723 |
// FETCH
|
| 724 |
// ββββββββββββββββββββββββββββββββββββββββββββ
|
| 725 |
async function fetchLeaderboard() {
|
| 726 |
-
const resp = await fetch(LEADERBOARD_URL);
|
| 727 |
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 728 |
const md = await resp.text();
|
| 729 |
const entries = parseLeaderboardMd(md);
|
|
|
|
| 636 |
// ββββββββββββββββββββββββββββββββββββββββββββ
|
| 637 |
// CONFIG
|
| 638 |
// ββββββββββββββββββββββββββββββββββββββββββββ
|
| 639 |
+
// Local dev (localhost) hits the local-server replica via a relative URL.
|
| 640 |
+
// Deployed (*.hf.space), we hit the Hub directly and use the OAuth Bearer
|
| 641 |
+
// token stored by the parent Messages tab in sessionStorage (same-origin
|
| 642 |
+
// iframe β shared session storage).
|
| 643 |
+
const IS_LOCAL = ['localhost', '127.0.0.1', '0.0.0.0'].includes(location.hostname);
|
| 644 |
+
const LEADERBOARD_URL = (IS_LOCAL ? '' : 'https://huggingface.co')
|
| 645 |
+
+ '/buckets/ml-agent-explorers/parameter-golf-collab/resolve/LEADERBOARD.md';
|
| 646 |
+
const TOKEN_KEY = 'parameter_golf_hf_token';
|
| 647 |
+
function authHeaders() {
|
| 648 |
+
if (IS_LOCAL) return {};
|
| 649 |
+
try {
|
| 650 |
+
const t = sessionStorage.getItem(TOKEN_KEY);
|
| 651 |
+
return t ? { Authorization: 'Bearer ' + t } : {};
|
| 652 |
+
} catch { return {}; }
|
| 653 |
+
}
|
| 654 |
|
| 655 |
const FALLBACK_ENTRIES = [
|
| 656 |
{
|
|
|
|
| 736 |
// FETCH
|
| 737 |
// ββββββββββββββββββββββββββββββββββββββββββββ
|
| 738 |
async function fetchLeaderboard() {
|
| 739 |
+
const resp = await fetch(LEADERBOARD_URL, { headers: authHeaders() });
|
| 740 |
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
| 741 |
const md = await resp.text();
|
| 742 |
const entries = parseLeaderboardMd(md);
|